/* ============================================
   VideoForge — Modern Universal Downloader
   ============================================ */

/* --- CSS Variables (Theme) --- */
:root {
    --bg-primary: #0a0a1a;
    --bg-secondary: #12122a;
    --bg-card: rgba(255, 255, 255, 0.04);
    --bg-glass: rgba(255, 255, 255, 0.06);
    --border-glass: rgba(255, 255, 255, 0.08);
    --text-primary: #f0f0ff;
    --text-secondary: #a0a0c0;
    --text-muted: #6a6a8a;
    --accent-1: #6c5ce7;
    --accent-2: #a855f7;
    --accent-3: #3b82f6;
    --gradient-primary: linear-gradient(135deg, #6c5ce7, #a855f7);
    --gradient-secondary: linear-gradient(135deg, #3b82f6, #6c5ce7);
    --gradient-glow: linear-gradient(135deg, rgba(108, 92, 231, 0.4), rgba(168, 85, 247, 0.4));
    --shadow-card: 0 8px 32px rgba(0, 0, 0, 0.3);
    --shadow-glow: 0 0 40px rgba(108, 92, 231, 0.15);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="light"] {
    --bg-primary: #f5f5ff;
    --bg-secondary: #eeedff;
    --bg-card: rgba(255, 255, 255, 0.8);
    --bg-glass: rgba(255, 255, 255, 0.7);
    --border-glass: rgba(108, 92, 231, 0.15);
    --text-primary: #1a1a2e;
    --text-secondary: #4a4a6a;
    --text-muted: #8a8aaa;
    --shadow-card: 0 8px 32px rgba(108, 92, 231, 0.1);
    --shadow-glow: 0 0 40px rgba(108, 92, 231, 0.08);
}

/* --- Reset & Base --- */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    transition: var(--transition);
    line-height: 1.6;
}

/* --- Animated Background --- */
.bg-gradient {
    position: fixed;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: 
        radial-gradient(ellipse at 20% 50%, rgba(108, 92, 231, 0.12) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 20%, rgba(168, 85, 247, 0.08) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 80%, rgba(59, 130, 246, 0.06) 0%, transparent 50%);
    animation: bgShift 20s ease-in-out infinite;
    z-index: 0;
    pointer-events: none;
}

[data-theme="light"] .bg-gradient {
    background: 
        radial-gradient(ellipse at 20% 50%, rgba(108, 92, 231, 0.06) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 20%, rgba(168, 85, 247, 0.04) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 80%, rgba(59, 130, 246, 0.03) 0%, transparent 50%);
}

@keyframes bgShift {
    0%, 100% { transform: translate(0, 0) rotate(0deg); }
    25% { transform: translate(2%, -2%) rotate(1deg); }
    50% { transform: translate(-1%, 1%) rotate(-0.5deg); }
    75% { transform: translate(1%, 2%) rotate(0.5deg); }
}

/* --- Particles --- */
.particles {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}

.particle {
    position: absolute;
    width: 4px;
    height: 4px;
    background: var(--accent-1);
    border-radius: 50%;
    opacity: 0.3;
    animation: float 15s infinite ease-in-out;
}

@keyframes float {
    0%, 100% {
        transform: translateY(0) translateX(0) scale(1);
        opacity: 0.3;
    }
    25% {
        transform: translateY(-100px) translateX(50px) scale(1.2);
        opacity: 0.6;
    }
    50% {
        transform: translateY(-200px) translateX(-30px) scale(0.8);
        opacity: 0.2;
    }
    75% {
        transform: translateY(-100px) translateX(80px) scale(1.1);
        opacity: 0.5;
    }
}

/* --- Container --- */
.container {
    position: relative;
    z-index: 1;
    max-width: 900px;
    margin: 0 auto;
    padding: 20px;
}

/* --- Header --- */
.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 0;
    margin-bottom: 10px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 14px;
}

.logo-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    background: var(--gradient-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    color: white;
    box-shadow: 0 4px 15px rgba(108, 92, 231, 0.3);
    animation: pulseGlow 3s ease-in-out infinite;
}

@keyframes pulseGlow {
    0%, 100% { box-shadow: 0 4px 15px rgba(108, 92, 231, 0.3); }
    50% { box-shadow: 0 4px 25px rgba(108, 92, 231, 0.5); }
}

.logo-text h1 {
    font-size: 24px;
    font-weight: 800;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.5px;
}

.logo-subtitle {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 500;
    letter-spacing: 1px;
    text-transform: uppercase;
}

.theme-toggle {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 1px solid var(--border-glass);
    background: var(--bg-glass);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    transition: var(--transition);
    backdrop-filter: blur(10px);
}

.theme-toggle:hover {
    background: var(--gradient-primary);
    color: white;
    border-color: transparent;
    transform: rotate(45deg);
}

/* --- Glass Card --- */
.section-card {
    background: var(--bg-glass);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-lg);
    padding: 28px;
    margin-bottom: 24px;
    backdrop-filter: blur(20px);
    box-shadow: var(--shadow-card);
    transition: var(--transition);
}

.section-card:hover {
    box-shadow: var(--shadow-glow);
}

.section-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}

.section-header i {
    font-size: 20px;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.section-header h2 {
    font-size: 18px;
    font-weight: 700;
}

.section-desc {
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 20px;
}

/* --- URL Input --- */
.input-group {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
}

.input-wrapper {
    flex: 1;
    position: relative;
    display: flex;
    align-items: center;
}

.input-icon {
    position: absolute;
    left: 16px;
    color: var(--text-muted);
    font-size: 16px;
    z-index: 1;
}

.input-wrapper input {
    width: 100%;
    padding: 16px 50px 16px 48px;
    border-radius: var(--radius-md);
    border: 2px solid var(--border-glass);
    background: var(--bg-card);
    color: var(--text-primary);
    font-size: 15px;
    font-family: inherit;
    transition: var(--transition);
    outline: none;
}

.input-wrapper input:focus {
    border-color: var(--accent-1);
    box-shadow: 0 0 0 4px rgba(108, 92, 231, 0.15);
}

.input-wrapper input::placeholder {
    color: var(--text-muted);
}

.btn-paste {
    position: absolute;
    right: 8px;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    font-size: 14px;
}

.btn-paste:hover {
    background: var(--bg-glass);
    color: var(--accent-1);
}

/* --- Buttons --- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    border-radius: var(--radius-md);
    border: none;
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}

.btn-primary {
    background: var(--gradient-primary);
    color: white;
    box-shadow: 0 4px 15px rgba(108, 92, 231, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(108, 92, 231, 0.4);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.btn-analyze {
    padding: 16px 28px;
    font-size: 15px;
}

.btn-lg {
    padding: 16px 36px;
    font-size: 16px;
}

.btn-sm {
    padding: 8px 14px;
    font-size: 13px;
}

.btn-refresh {
    background: var(--bg-glass);
    color: var(--text-secondary);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-sm);
    margin-left: auto;
}

.btn-refresh:hover {
    background: var(--gradient-primary);
    color: white;
    border-color: transparent;
}

/* --- Quick Examples --- */
.quick-examples {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.quick-examples span {
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 500;
}

.example-btn {
    padding: 5px 14px;
    border-radius: 20px;
    border: 1px solid var(--border-glass);
    background: var(--bg-glass);
    color: var(--text-secondary);
    font-size: 12px;
    font-family: inherit;
    cursor: pointer;
    transition: var(--transition);
}

.example-btn:hover {
    background: var(--gradient-primary);
    color: white;
    border-color: transparent;
    transform: translateY(-1px);
}

/* --- Loading Overlay --- */
.loading-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    z-index: 100;
    align-items: center;
    justify-content: center;
}

.loading-overlay.active {
    display: flex;
}

.spinner-container {
    text-align: center;
    position: relative;
}

.spinner-ring {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    border: 4px solid transparent;
    border-top-color: var(--accent-1);
    border-right-color: var(--accent-2);
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

.spinner-ring-2 {
    position: absolute;
    top: -10px;
    left: 50%;
    margin-left: -40px;
    width: 80px;
    height: 80px;
    border-top-color: var(--accent-3);
    border-right-color: transparent;
    animation-direction: reverse;
    animation-duration: 1.5s;
    opacity: 0.5;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

#loadingText {
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    margin-top: 10px;
}

/* --- Video Preview --- */
.video-preview {
    display: flex;
    gap: 24px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.thumbnail-wrapper {
    position: relative;
    flex-shrink: 0;
    width: 280px;
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.thumbnail-wrapper img {
    width: 100%;
    height: auto;
    display: block;
    aspect-ratio: 16/9;
    object-fit: cover;
}

.duration-badge {
    position: absolute;
    bottom: 10px;
    right: 10px;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.video-meta {
    flex: 1;
    min-width: 200px;
}

.video-title {
    font-size: 20px;
    font-weight: 700;
    line-height: 1.4;
    margin-bottom: 14px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.meta-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-bottom: 12px;
}

.meta-item {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-secondary);
    font-size: 13px;
}

.meta-item i {
    width: 16px;
    color: var(--accent-1);
    font-size: 12px;
}

.categories {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.categories span {
    padding: 3px 10px;
    border-radius: 12px;
    background: var(--gradient-glow);
    color: var(--text-primary);
    font-size: 11px;
    font-weight: 500;
}

/* --- Download Tabs --- */
.download-tabs {
    display: flex;
    gap: 4px;
    background: var(--bg-card);
    padding: 4px;
    border-radius: var(--radius-md);
    margin-bottom: 20px;
    overflow-x: auto;
}

.tab-btn {
    flex: 1;
    padding: 10px 16px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: var(--transition);
    white-space: nowrap;
}

.tab-btn i {
    font-size: 14px;
}

.tab-btn:hover {
    color: var(--text-secondary);
    background: rgba(255, 255, 255, 0.05);
}

.tab-btn.active {
    background: var(--gradient-primary);
    color: white;
    box-shadow: 0 2px 10px rgba(108, 92, 231, 0.3);
}

/* --- Tab Content --- */
.tab-content {
    min-height: 120px;
}

.tab-pane {
    display: none;
}

.tab-pane.active {
    display: block;
}

/* --- Format Grid --- */
.format-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 10px;
}

.format-card {
    padding: 14px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-glass);
    background: var(--bg-card);
    cursor: pointer;
    transition: var(--transition);
    text-align: center;
}

.format-card:hover {
    border-color: var(--accent-1);
    box-shadow: 0 4px 15px rgba(108, 92, 231, 0.1);
    transform: translateY(-2px);
}

.format-card .format-quality {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.format-card .format-ext {
    font-size: 12px;
    color: var(--accent-2);
    font-weight: 600;
    text-transform: uppercase;
    margin-bottom: 4px;
}

.format-card .format-details {
    font-size: 11px;
    color: var(--text-muted);
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.format-card .format-size {
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 500;
    margin-top: 6px;
}

.format-card .format-note {
    font-size: 10px;
    color: var(--text-muted);
    margin-top: 2px;
}

.no-formats {
    display: none;
    color: var(--text-muted);
    font-size: 14px;
    text-align: center;
    padding: 30px;
}

/* --- Frames Tab --- */
.frames-controls {
    display: flex;
    align-items: flex-end;
    gap: 16px;
    padding: 20px;
    flex-wrap: wrap;
}

.frames-input-group {
    flex: 1;
    min-width: 150px;
}

.frames-input-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.fps-input-wrapper {
    display: flex;
    align-items: center;
    gap: 0;
}

.fps-input-wrapper input {
    width: 100%;
    padding: 12px 16px;
    border-radius: var(--radius-sm) 0 0 var(--radius-sm);
    border: 2px solid var(--border-glass);
    background: var(--bg-card);
    color: var(--text-primary);
    font-size: 16px;
    font-family: inherit;
    outline: none;
    transition: var(--transition);
}

.fps-input-wrapper input:focus {
    border-color: var(--accent-1);
}

.fps-unit {
    padding: 12px 16px;
    background: var(--bg-glass);
    border: 2px solid var(--border-glass);
    border-left: none;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    color: var(--text-muted);
    font-size: 14px;
    font-weight: 600;
}

/* --- Best Quality Card --- */
.best-quality-card {
    text-align: center;
    padding: 30px 20px;
}

.best-icon {
    width: 70px;
    height: 70px;
    border-radius: 50%;
    background: var(--gradient-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
    font-size: 30px;
    color: white;
    box-shadow: 0 4px 20px rgba(108, 92, 231, 0.3);
}

.best-quality-card h3 {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 8px;
}

.best-quality-card p {
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 20px;
}

/* --- Downloads Section --- */
.section-header .badge {
    background: var(--gradient-primary);
    color: white;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 700;
    min-width: 24px;
    text-align: center;
}

.downloads-list {
    max-height: 400px;
    overflow-y: auto;
}

.downloads-list::-webkit-scrollbar {
    width: 6px;
}

.downloads-list::-webkit-scrollbar-track {
    background: transparent;
}

.downloads-list::-webkit-scrollbar-thumb {
    background: var(--border-glass);
    border-radius: 3px;
}

.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
}

.empty-state i {
    font-size: 40px;
    margin-bottom: 12px;
    opacity: 0.5;
}

.empty-state p {
    font-size: 14px;
}

.download-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-glass);
    margin-bottom: 8px;
    transition: var(--transition);
}

.download-item:hover {
    border-color: var(--accent-1);
    background: var(--bg-card);
}

.download-item-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    background: var(--gradient-glow);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    color: var(--accent-1);
    flex-shrink: 0;
}

.download-item-info {
    flex: 1;
    min-width: 0;
}

.download-item-name {
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.download-item-size {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 2px;
}

.download-item-actions {
    display: flex;
    gap: 6px;
}

.download-item-actions button {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    font-size: 13px;
}

.btn-download-file {
    background: var(--gradient-primary);
    color: white;
}

.btn-download-file:hover {
    box-shadow: 0 4px 12px rgba(108, 92, 231, 0.3);
}

.btn-delete-file {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
}

.btn-delete-file:hover {
    background: #ef4444;
    color: white;
}

/* --- Toast Notifications --- */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 200;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 20px;
    border-radius: var(--radius-md);
    background: var(--bg-glass);
    border: 1px solid var(--border-glass);
    backdrop-filter: blur(20px);
    box-shadow: var(--shadow-card);
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 500;
    animation: slideIn 0.3s ease;
    min-width: 300px;
    max-width: 420px;
}

.toast.toast-success {
    border-color: rgba(34, 197, 94, 0.4);
}

.toast.toast-error {
    border-color: rgba(239, 68, 68, 0.4);
}

.toast i {
    font-size: 18px;
}

.toast.toast-success i {
    color: #22c55e;
}

.toast.toast-error i {
    color: #ef4444;
}

.toast.fade-out {
    animation: slideOut 0.3s ease forwards;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOut {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(100%);
        opacity: 0;
    }
}

/* --- Progress Modal --- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    z-index: 150;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal {
    width: 90%;
    max-width: 400px;
    padding: 28px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-glass);
    animation: modalIn 0.3s ease;
}

@keyframes modalIn {
    from {
        transform: scale(0.9);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

.modal-header {
    margin-bottom: 20px;
}

.modal-header h3 {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 18px;
    font-weight: 700;
}

.modal-header h3 i {
    color: var(--accent-1);
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: var(--bg-card);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 12px;
}

.progress-fill {
    height: 100%;
    width: 0%;
    background: var(--gradient-primary);
    border-radius: 4px;
    transition: width 0.5s ease;
    animation: progressShimmer 2s infinite;
}

@keyframes progressShimmer {
    0% { opacity: 1; }
    50% { opacity: 0.7; }
    100% { opacity: 1; }
}

#progressMessage {
    color: var(--text-secondary);
    font-size: 13px;
    text-align: center;
}

/* --- Responsive --- */
@media (max-width: 768px) {
    .container {
        padding: 14px;
    }

    .input-group {
        flex-direction: column;
    }

    .btn-analyze {
        width: 100%;
        justify-content: center;
    }

    .video-preview {
        flex-direction: column;
    }

    .thumbnail-wrapper {
        width: 100%;
    }

    .meta-grid {
        grid-template-columns: 1fr;
    }

    .download-tabs {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .tab-btn {
        flex: 0 0 auto;
        padding: 10px 14px;
        font-size: 12px;
    }

    .format-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    }

    .frames-controls {
        flex-direction: column;
        align-items: stretch;
    }

    .toast-container {
        left: 14px;
        right: 14px;
        bottom: 14px;
    }

    .toast {
        min-width: auto;
        max-width: none;
    }

    .logo-text h1 {
        font-size: 20px;
    }
}