/* CSS Design System - MediaDown */
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800&family=Plus+Jakarta+Sans:wght@300;400;500;600;700;800&display=swap');

:root {
    /* Color Palette - HSL (Dark Mode Default) */
    --bg-gradient: linear-gradient(135deg, #0b0c16 0%, #151630 50%, #080911 100%);
    --bg-solid: #0b0c16;
    --panel-bg: rgba(21, 23, 48, 0.4);
    --panel-border: rgba(255, 255, 255, 0.08);
    --text-primary: #f3f4f6;
    --text-secondary: #9ca3af;
    --text-muted: #6b7280;
    
    --primary-gradient: linear-gradient(135deg, #6366f1 0%, #a855f7 100%);
    --accent-gradient: linear-gradient(135deg, #3b82f6 0%, #06b6d4 100%);
    --accent-glow: rgba(99, 102, 241, 0.4);
    --primary-color: #6366f1;
    --secondary-color: #a855f7;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --danger-color: #ef4444;
    
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 8px 30px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.4);
    --shadow-glow: 0 0 25px rgba(99, 102, 241, 0.25);
    
    --font-heading: 'Outfit', sans-serif;
    --font-body: 'Plus Jakarta Sans', sans-serif;
    --border-radius-sm: 8px;
    --border-radius-md: 16px;
    --border-radius-lg: 24px;
    --transition-fast: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-smooth: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="light"] {
    /* Color Palette - HSL (Light Mode) */
    --bg-gradient: linear-gradient(135deg, #f0f2fe 0%, #e2e5ff 50%, #f9f9ff 100%);
    --bg-solid: #f0f2fe;
    --panel-bg: rgba(255, 255, 255, 0.7);
    --panel-border: rgba(99, 102, 241, 0.12);
    --text-primary: #1e1b4b;
    --text-secondary: #4b5563;
    --text-muted: #8892b0;
    
    --primary-gradient: linear-gradient(135deg, #4f46e5 0%, #9333ea 100%);
    --accent-gradient: linear-gradient(135deg, #2563eb 0%, #0891b2 100%);
    --accent-glow: rgba(79, 70, 229, 0.15);
    --primary-color: #4f46e5;
    --secondary-color: #9333ea;
    
    --shadow-sm: 0 2px 8px rgba(99, 102, 241, 0.05);
    --shadow-md: 0 8px 30px rgba(99, 102, 241, 0.08);
    --shadow-lg: 0 16px 40px rgba(99, 102, 241, 0.12);
    --shadow-glow: 0 0 25px rgba(79, 70, 229, 0.15);
}

/* Global Reset */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background: var(--bg-gradient);
    background-attachment: fixed;
    color: var(--text-primary);
    font-family: var(--font-body);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    transition: background var(--transition-smooth), color var(--transition-smooth);
}

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-heading);
    font-weight: 700;
}

/* Glassmorphism Panel Utilities */
.glass-panel {
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-radius: var(--border-radius-md);
    box-shadow: var(--shadow-md);
}

/* Header & Navigation */
header {
    padding: 1.5rem 2rem;
    position: sticky;
    top: 0;
    z-index: 100;
    transition: var(--transition-fast);
}

header.scrolled {
    background: var(--panel-bg);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--panel-border);
    padding: 1rem 2rem;
}

.nav-container {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none;
    color: var(--text-primary);
    font-family: var(--font-heading);
    font-size: 1.5rem;
    font-weight: 800;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.logo svg {
    fill: var(--primary-color);
    width: 32px;
    height: 32px;
}

.nav-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.btn-icon {
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    color: var(--text-primary);
    width: 44px;
    height: 44px;
    border-radius: var(--border-radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition-fast);
}

.btn-icon:hover {
    transform: translateY(-2px);
    background: rgba(99, 102, 241, 0.15);
    border-color: var(--primary-color);
    box-shadow: var(--shadow-glow);
}

/* Main Content Wrapper */
main {
    flex: 1;
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
    padding: 2rem 1.5rem;
}

/* Hero Section */
.hero {
    text-align: center;
    padding: 3rem 0;
    max-width: 800px;
    margin: 0 auto;
}

.hero h1 {
    font-size: 3.5rem;
    line-height: 1.15;
    margin-bottom: 1rem;
    letter-spacing: -1px;
}

.hero h1 span {
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.hero p {
    font-size: 1.125rem;
    color: var(--text-secondary);
    margin-bottom: 2.5rem;
}

/* Downloader Form Card */
.downloader-card {
    padding: 2.5rem;
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-lg);
    position: relative;
    overflow: hidden;
}

.downloader-card::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(99, 102, 241, 0.08) 0%, transparent 60%);
    pointer-events: none;
}

.downloader-form {
    display: flex;
    gap: 1rem;
    position: relative;
    z-index: 2;
}

.input-wrapper {
    position: relative;
    flex: 1;
}

.input-wrapper svg {
    position: absolute;
    left: 1.25rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    width: 20px;
    height: 20px;
    transition: var(--transition-fast);
}

.input-wrapper input {
    width: 100%;
    padding: 1.25rem 1rem 1.25rem 3.5rem;
    background: rgba(8, 9, 17, 0.6);
    border: 2px solid var(--panel-border);
    border-radius: var(--border-radius-md);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 1rem;
    outline: none;
    transition: var(--transition-fast);
}

.input-wrapper input:focus {
    border-color: var(--primary-color);
    box-shadow: var(--shadow-glow);
}

.input-wrapper input:focus + svg {
    color: var(--primary-color);
}

.btn-primary {
    background: var(--primary-gradient);
    border: none;
    color: white;
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 1.1rem;
    padding: 0 2rem;
    border-radius: var(--border-radius-md);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: var(--transition-fast);
    box-shadow: var(--shadow-sm);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 25px rgba(99, 102, 241, 0.4);
    filter: brightness(1.1);
}

.btn-primary:active {
    transform: translateY(0);
}

/* Supported Platforms Banner */
.supported-platforms {
    margin-top: 2rem;
    display: flex;
    justify-content: center;
    gap: 1.5rem;
    flex-wrap: wrap;
}

.platform-badge {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--panel-border);
    padding: 0.5rem 1rem;
    border-radius: 50px;
    font-size: 0.875rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: var(--transition-fast);
}

.platform-badge:hover {
    background: rgba(99, 102, 241, 0.1);
    color: var(--text-primary);
    transform: translateY(-2px);
}

/* Fetching Loader state */
.loader-wrapper {
    display: none;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    margin: 3rem 0;
}

.spinner {
    width: 60px;
    height: 60px;
    border: 4px solid rgba(255, 255, 255, 0.1);
    border-top: 4px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Results Section */
.results-section {
    display: none;
    margin: 3rem 0;
    animation: fadeInUp 0.5s ease-out;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.results-card {
    display: grid;
    grid-template-columns: 350px 1fr;
    gap: 2rem;
    padding: 2rem;
}

.video-preview {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.thumbnail-container {
    width: 100%;
    aspect-ratio: 16/9;
    border-radius: var(--border-radius-sm);
    overflow: hidden;
    position: relative;
    border: 1px solid var(--panel-border);
}

.thumbnail-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.duration-badge {
    position: absolute;
    bottom: 0.5rem;
    right: 0.5rem;
    background: rgba(0, 0, 0, 0.8);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    color: white;
}

.video-details h3 {
    font-size: 1.25rem;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.video-details p {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

/* Formats Table */
.formats-container {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.formats-table {
    width: 100%;
    border-collapse: collapse;
}

.formats-table th {
    text-align: left;
    padding: 1rem;
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
    border-bottom: 1px solid var(--panel-border);
}

.formats-table td {
    padding: 1rem;
    border-bottom: 1px solid var(--panel-border);
    vertical-align: middle;
}

.formats-table tr:last-child td {
    border-bottom: none;
}

.badge-format {
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
}

.badge-video {
    background: rgba(99, 102, 241, 0.15);
    color: var(--primary-color);
}

.badge-audio {
    background: rgba(16, 185, 129, 0.15);
    color: var(--success-color);
}

.badge-video-only {
    background: rgba(245, 158, 11, 0.15);
    color: var(--warning-color);
}

.btn-download {
    background: var(--accent-gradient);
    border: none;
    color: white;
    padding: 0.5rem 1.25rem;
    border-radius: var(--border-radius-sm);
    font-family: var(--font-heading);
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    text-decoration: none;
    transition: var(--transition-fast);
}

.btn-download:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(6, 182, 212, 0.3);
}

/* How to Use Section */
.how-to-use {
    margin: 5rem 0 3rem 0;
    text-align: center;
}

.how-to-use h2 {
    font-size: 2.25rem;
    margin-bottom: 3rem;
}

.steps-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 2rem;
}

.step-card {
    padding: 2.5rem 2rem;
    text-align: center;
    position: relative;
    transition: var(--transition-smooth);
}

.step-card:hover {
    transform: translateY(-5px);
    border-color: var(--primary-color);
    box-shadow: var(--shadow-glow);
}

.step-num {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: var(--primary-gradient);
    color: white;
    font-weight: 800;
    font-size: 1.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1.5rem auto;
    box-shadow: var(--shadow-sm);
}

.step-card h3 {
    margin-bottom: 0.75rem;
    font-size: 1.25rem;
}

.step-card p {
    color: var(--text-secondary);
    font-size: 0.95rem;
    line-height: 1.5;
}

/* Footer Section */
footer {
    background: rgba(8, 9, 17, 0.8);
    border-top: 1px solid var(--panel-border);
    padding: 3rem 2rem 1.5rem 2rem;
    margin-top: auto;
}

.footer-content {
    max-width: 1200px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 3rem;
    margin-bottom: 3rem;
}

.footer-brand h4 {
    font-size: 1.5rem;
    margin-bottom: 1rem;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.footer-brand p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.6;
}

.footer-links h5 {
    font-size: 1.1rem;
    margin-bottom: 1.25rem;
}

.footer-links ul {
    list-style: none;
}

.footer-links ul li {
    margin-bottom: 0.75rem;
}

.footer-links ul li a {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.9rem;
    transition: var(--transition-fast);
}

.footer-links ul li a:hover {
    color: var(--primary-color);
    padding-left: 4px;
}

.footer-bottom {
    max-width: 1200px;
    margin: 0 auto;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    padding-top: 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.footer-bottom p {
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* Admin Panel Page Styles */
.admin-container {
    display: grid;
    grid-template-columns: 280px 1fr;
    min-height: 100vh;
    background: var(--bg-solid);
}

/* Admin Sidebar */
.admin-sidebar {
    background: rgba(11, 12, 22, 0.85);
    border-right: 1px solid var(--panel-border);
    padding: 2rem 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 2.5rem;
}

.admin-logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-primary);
    text-decoration: none;
    font-family: var(--font-heading);
    font-size: 1.25rem;
    font-weight: 800;
}

.admin-menu {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.admin-menu-item a {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: var(--border-radius-sm);
    font-size: 0.95rem;
    font-weight: 500;
    transition: var(--transition-fast);
}

.admin-menu-item a svg {
    width: 20px;
    height: 20px;
}

.admin-menu-item.active a,
.admin-menu-item a:hover {
    background: rgba(99, 102, 241, 0.15);
    color: var(--text-primary);
}

.admin-menu-item.active a {
    border-left: 3px solid var(--primary-color);
}

.admin-logout {
    margin-top: auto;
}

/* Admin Main Content */
.admin-main {
    padding: 2rem 3rem;
    overflow-y: auto;
}

.admin-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2.5rem;
}

.admin-title h1 {
    font-size: 2rem;
    margin-bottom: 0.25rem;
}

.admin-title p {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* Analytics Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2.5rem;
}

.stat-card {
    padding: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1.25rem;
}

.stat-icon {
    width: 50px;
    height: 50px;
    border-radius: var(--border-radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
}

.stat-icon.primary { background: var(--primary-gradient); }
.stat-icon.accent { background: var(--accent-gradient); }
.stat-icon.success { background: linear-gradient(135deg, #10b981 0%, #059669 100%); }

.stat-info h3 {
    font-size: 1.75rem;
    margin-bottom: 0.25rem;
}

.stat-info p {
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* Dashboard Grid Layout (Charts + Logs) */
.dashboard-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 2rem;
    margin-bottom: 2.5rem;
}

.chart-card {
    padding: 1.5rem;
    min-height: 350px;
}

.chart-card h3 {
    margin-bottom: 1.5rem;
}

/* Settings Form Styles */
.settings-section {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.settings-group {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    padding: 2rem;
}

.settings-group h3 {
    font-size: 1.25rem;
    border-bottom: 1px solid var(--panel-border);
    padding-bottom: 0.75rem;
    margin-bottom: 0.5rem;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-group label {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.form-group input, 
.form-group textarea,
.form-group select {
    background: rgba(8, 9, 17, 0.4);
    border: 1px solid var(--panel-border);
    border-radius: var(--border-radius-sm);
    padding: 0.75rem 1rem;
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 0.95rem;
    outline: none;
    transition: var(--transition-fast);
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    border-color: var(--primary-color);
}

.form-group textarea {
    min-height: 120px;
    resize: vertical;
}

.code-textarea {
    font-family: monospace !important;
    font-size: 0.85rem !important;
    background: #080911 !important;
    color: #34d399 !important;
}

/* Switch component */
.switch-container {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.switch {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 24px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--text-muted);
    transition: .4s;
    border-radius: 24px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

input:checked + .slider {
    background: var(--primary-gradient);
}

input:checked + .slider:before {
    transform: translateX(24px);
}

.btn-save {
    background: var(--primary-gradient);
    border: none;
    color: white;
    padding: 0.75rem 2rem;
    border-radius: var(--border-radius-sm);
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 1rem;
    cursor: pointer;
    transition: var(--transition-fast);
    align-self: flex-start;
}

.btn-save:hover {
    filter: brightness(1.1);
    transform: translateY(-1px);
}

/* Modal and Login overlay */
.login-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(8, 9, 17, 0.85);
    backdrop-filter: blur(20px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-card {
    width: 100%;
    max-width: 420px;
    padding: 2.5rem;
}

.login-card h2 {
    font-size: 1.75rem;
    margin-bottom: 0.5rem;
    text-align: center;
}

.login-card p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 2rem;
    text-align: center;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

/* Alert system */
.alert {
    padding: 1rem;
    border-radius: var(--border-radius-sm);
    margin-bottom: 1rem;
    display: none;
    font-size: 0.9rem;
    font-weight: 500;
}

.alert-success {
    background: rgba(16, 185, 129, 0.15);
    border: 1px solid rgba(16, 185, 129, 0.3);
    color: #34d399;
}

.alert-danger {
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #fca5a5;
}

/* Media Queries */
@media (max-width: 900px) {
    .results-card {
        grid-template-columns: 1fr;
    }
    
    .hero h1 {
        font-size: 2.5rem;
    }
    
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .admin-container {
        grid-template-columns: 1fr;
    }
    .admin-sidebar {
        display: none; /* In real production we would build a drawer menu */
    }
    .downloader-form {
        flex-direction: column;
    }
    
    .btn-primary {
        padding: 1.25rem;
        justify-content: center;
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
}

/* Progress Loader Styles */
.progress-container {
    width: 100%;
    max-width: 350px;
    height: 10px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--panel-border);
    border-radius: 50px;
    overflow: hidden;
    margin-top: 1.5rem;
    margin-bottom: 0.5rem;
    box-shadow: var(--shadow-sm);
}

.progress-bar {
    width: 0%;
    height: 100%;
    background: var(--primary-gradient);
    border-radius: 50px;
    transition: width 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 0 10px rgba(99, 102, 241, 0.5);
}

.progress-counter {
    font-family: var(--font-heading);
    font-weight: 800;
    font-size: 1.25rem;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-top: 0.25rem;
}
