/* ============================================
   Video Downloader - Dark Glassmorphism Theme
   ============================================ */

:root {
    --bg-primary: #0a0a1a;
    --bg-secondary: #12122a;
    --bg-card: rgba(255, 255, 255, 0.05);
    --bg-card-hover: rgba(255, 255, 255, 0.08);
    --border-color: rgba(255, 255, 255, 0.1);
    --text-primary: #e8e8f0;
    --text-secondary: #a0a0c0;
    --text-muted: #6a6a8a;
    --accent: #6366f1;
    --accent-hover: #818cf8;
    --accent-glow: rgba(99, 102, 241, 0.3);
    --success: #22c55e;
    --danger: #ef4444;
    --warning: #f59e0b;
    --info: #3b82f6;
    --sidebar-width: 200px;
    --font-main: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Noto Sans TC', sans-serif;
}

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

body {
    font-family: var(--font-main);
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow: hidden;
}

/* ---- Layout ---- */
.app-container {
    display: flex;
    height: 100vh;
    width: 100vw;
}

/* ---- Sidebar ---- */
.sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 0;
    z-index: 10;
}

.sidebar-header {
    padding: 20px 16px;
    border-bottom: 1px solid var(--border-color);
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo-icon {
    font-size: 24px;
}

.logo-text {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
}

.nav-links {
    list-style: none;
    padding: 12px 8px;
    flex: 1;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 8px;
    color: var(--text-secondary);
    text-decoration: none;
    transition: all 0.2s;
    margin-bottom: 4px;
    font-size: 14px;
}

.nav-link:hover {
    background: var(--bg-card-hover);
    color: var(--text-primary);
}

.nav-link.active {
    background: var(--accent);
    color: white;
    box-shadow: 0 2px 12px var(--accent-glow);
}

.nav-icon {
    font-size: 18px;
    width: 24px;
    text-align: center;
}

.sidebar-footer {
    padding: 12px 16px;
    border-top: 1px solid var(--border-color);
}

.version-info {
    font-size: 11px;
    color: var(--text-muted);
    text-align: center;
}

/* ---- Main Content ---- */
.main-content {
    flex: 1;
    overflow-y: auto;
    padding: 24px 32px;
    position: relative;
    background: var(--bg-primary);
}

/* ---- Pages ---- */
.page {
    display: none;
    animation: fadeIn 0.3s ease;
}

.page.active {
    display: block;
}

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

.page-header {
    margin-bottom: 24px;
}

.page-header h1 {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 4px;
}

.page-subtitle {
    color: var(--text-secondary);
    font-size: 14px;
}

/* ---- Glass Cards ---- */
.glass-card {
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 16px;
    transition: background 0.2s;
}

.glass-card:hover {
    background: var(--bg-card-hover);
}

/* ---- Stats Grid ---- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 20px;
}

.stat-icon {
    font-size: 32px;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(99, 102, 241, 0.1);
    border-radius: 12px;
}

.stat-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
}

.stat-label {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 2px;
}

/* ---- Quick Actions ---- */
.quick-actions h3 {
    margin-bottom: 12px;
    font-size: 16px;
}

.action-buttons {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

/* ---- Buttons ---- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-family: var(--font-main);
    white-space: nowrap;
}

.btn-primary {
    background: var(--accent);
    color: white;
    box-shadow: 0 2px 8px var(--accent-glow);
}

.btn-primary:hover {
    background: var(--accent-hover);
    box-shadow: 0 4px 16px var(--accent-glow);
    transform: translateY(-1px);
}

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.12);
}

.btn-danger {
    background: rgba(239, 68, 68, 0.15);
    color: var(--danger);
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.btn-danger:hover {
    background: rgba(239, 68, 68, 0.25);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
}

/* ---- Tab Bar ---- */
.tab-bar {
    display: flex;
    gap: 4px;
    padding: 6px;
    margin-bottom: 16px;
}

.tab-btn {
    flex: 1;
    padding: 10px 16px;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-family: var(--font-main);
}

.tab-btn:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
}

.tab-btn.active {
    background: var(--accent);
    color: white;
    box-shadow: 0 2px 8px var(--accent-glow);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* ---- Download Form ---- */
.download-form h3 {
    margin-bottom: 12px;
    font-size: 16px;
}

.form-group {
    display: flex;
    gap: 8px;
    align-items: center;
}

.form-input {
    flex: 1;
    padding: 10px 16px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
    font-size: 14px;
    font-family: var(--font-main);
    outline: none;
    transition: border-color 0.2s;
}

.form-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.form-input::placeholder {
    color: var(--text-muted);
}

/* ---- Progress ---- */
.progress-area {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 12px;
    padding: 12px;
    background: rgba(99, 102, 241, 0.1);
    border-radius: 8px;
}

.progress-area.hidden {
    display: none;
}

.spinner {
    width: 20px;
    height: 20px;
    border: 3px solid var(--border-color);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.progress-text {
    font-size: 13px;
    color: var(--text-secondary);
}

/* ---- Video Preview ---- */
.video-preview {
    margin-top: 16px;
    padding: 16px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    border-radius: 8px;
}

.video-preview.hidden {
    display: none;
}

.preview-info {
    display: flex;
    gap: 16px;
}

.preview-cover {
    width: 120px;
    height: 160px;
    border-radius: 8px;
    object-fit: cover;
    background: var(--bg-secondary);
}

.preview-details {
    flex: 1;
}

.preview-title {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 8px;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.preview-author {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.preview-duration {
    font-size: 13px;
    color: var(--text-muted);
}

/* ---- Download List ---- */
.download-list {
    margin-top: 8px;
}

.list-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.list-header h3 {
    font-size: 16px;
}

.downloads-container {
    max-height: 400px;
    overflow-y: auto;
}

.empty-state {
    text-align: center;
    padding: 32px;
    color: var(--text-muted);
    font-size: 14px;
}

.download-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    margin-bottom: 8px;
    background: rgba(255, 255, 255, 0.02);
    transition: background 0.2s;
}

.download-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

.download-thumb {
    width: 64px;
    height: 48px;
    border-radius: 6px;
    object-fit: cover;
    background: var(--bg-secondary);
    flex-shrink: 0;
}

.download-info {
    flex: 1;
    min-width: 0;
}

.download-title {
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 4px;
}

.download-meta {
    font-size: 11px;
    color: var(--text-muted);
    display: flex;
    gap: 12px;
}

.download-actions {
    flex-shrink: 0;
}

/* ---- Toast Notifications ---- */
.toast-container {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    padding: 12px 20px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    color: white;
    backdrop-filter: blur(12px);
    animation: toastIn 0.3s ease, toastOut 0.3s ease 2.7s;
    max-width: 360px;
    word-break: break-word;
}

.toast-info {
    background: rgba(59, 130, 246, 0.9);
}

.toast-success {
    background: rgba(34, 197, 94, 0.9);
}

.toast-error {
    background: rgba(239, 68, 68, 0.9);
}

.toast-warning {
    background: rgba(245, 158, 11, 0.9);
}

@keyframes toastIn {
    from { opacity: 0; transform: translateX(40px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes toastOut {
    from { opacity: 1; }
    to { opacity: 0; }
}

/* ---- Scrollbar ---- */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* ---- Responsive ---- */
@media (max-width: 768px) {
    .sidebar {
        width: 60px;
        min-width: 60px;
    }

    .logo-text,
    .nav-text {
        display: none;
    }

    .sidebar-header {
        padding: 16px 12px;
        text-align: center;
    }

    .nav-link {
        justify-content: center;
        padding: 10px;
    }

    .main-content {
        padding: 16px;
    }

    .form-group {
        flex-direction: column;
    }

    .form-group .btn {
        width: 100%;
        justify-content: center;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .preview-info {
        flex-direction: column;
    }

    .preview-cover {
        width: 100%;
        height: 200px;
    }
}
