/* ==========================================================================
   ReelFlow Pro - Design System Variables & Tokens
   ========================================================================== */
:root {
    /* Color Palette */
    --bg-dark: #09090e;
    --bg-card: rgba(15, 15, 27, 0.7);
    --bg-card-hover: rgba(22, 22, 38, 0.75);
    --border-color: rgba(255, 255, 255, 0.08);
    --border-hover: rgba(139, 92, 246, 0.25);
    
    /* Text Colors */
    --text-primary: #f8fafc;
    --text-secondary: #cbd5e1;
    --text-muted: #64748b;
    
    /* Accent Tones */
    --accent-indigo: #4f46e5;
    --accent-purple: #7c3aed;
    --accent-pink: #db2777;
    --accent-rose: #f43f5e;
    --accent-emerald: #10b981;
    
    /* Gradients */
    --gradient-primary: linear-gradient(135deg, #6366f1, #8b5cf6, #d946ef);
    --gradient-btn-hover: linear-gradient(135deg, #4f46e5, #7c3aed, #c084fc);
    --gradient-success: linear-gradient(135deg, #10b981, #059669);
    
    /* Font Stack */
    --font-sans: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    
    /* Border Radii */
    --radius-xl: 20px;
    --radius-lg: 16px;
    --radius-md: 12px;
    --radius-sm: 8px;
    
    /* Shadows & Effects */
    --card-shadow: 0 20px 40px -15px rgba(0, 0, 0, 0.6);
    --glow-shadow: 0 0 25px rgba(139, 92, 246, 0.25);
    --transition-smooth: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ==========================================================================
   Global Reset & Base Styles
   ========================================================================== */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-primary);
    font-family: var(--font-sans);
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Scrollbar Customization */
::-webkit-scrollbar {
    width: 8px;
}
::-webkit-scrollbar-track {
    background: rgba(0,0,0,0.1);
}
::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.08);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.15);
}

/* Screen Reader Utility */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

/* ==========================================================================
   Background & Ambient Blobs
   ========================================================================== */
.ambient-blob {
    position: fixed;
    border-radius: 50%;
    filter: blur(120px);
    opacity: 0.12;
    pointer-events: none;
    z-index: -1;
}

.blob-1 {
    width: 500px;
    height: 500px;
    background-color: var(--accent-indigo);
    top: -150px;
    left: -100px;
    animation: drift-blob-1 25s infinite alternate ease-in-out;
}

.blob-2 {
    width: 600px;
    height: 600px;
    background-color: var(--accent-pink);
    bottom: -200px;
    right: -100px;
    animation: drift-blob-2 30s infinite alternate-reverse ease-in-out;
}

.blob-3 {
    width: 400px;
    height: 400px;
    background-color: var(--accent-purple);
    top: 35%;
    left: 45%;
    animation: pulse-blob 18s infinite alternate ease-in-out;
}

@keyframes drift-blob-1 {
    0% { transform: translate(0, 0) scale(1); }
    100% { transform: translate(100px, 60px) scale(1.1); }
}

@keyframes drift-blob-2 {
    0% { transform: translate(0, 0) scale(1); }
    100% { transform: translate(-120px, -80px) scale(1.15); }
}

@keyframes pulse-blob {
    0% { transform: scale(0.9); opacity: 0.08; }
    100% { transform: scale(1.12); opacity: 0.16; }
}

/* ==========================================================================
   Layout Structures (Centered Design System)
   ========================================================================== */
.app-container {
    width: 100%;
    max-width: 730px;
    margin: 0 auto;
    padding: 32px 24px;
    display: flex;
    flex-direction: column;
    gap: 28px;
    z-index: 10;
}

/* Header */
.app-header {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

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

.logo-icon {
    width: 42px;
    height: 42px;
    color: var(--accent-pink);
    filter: drop-shadow(0 0 10px rgba(217, 70, 239, 0.45));
}

.logo-text {
    font-size: 2.5rem;
    font-weight: 800;
    letter-spacing: -0.75px;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.logo-text span {
    font-weight: 300;
    color: var(--text-primary);
    -webkit-text-fill-color: var(--text-primary);
}

.tagline {
    font-size: 1.05rem;
    color: var(--text-secondary);
    font-weight: 300;
    letter-spacing: 0.2px;
}

/* Tab Navigation Switcher */
.tab-navigation {
    display: inline-flex;
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid var(--border-color);
    border-radius: 30px;
    padding: 4px;
    margin: 8px auto 0 auto;
    gap: 4px;
}

.tab-btn {
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-secondary);
    font-family: var(--font-sans);
    font-size: 0.9rem;
    font-weight: 600;
    padding: 10px 22px;
    border-radius: 26px;
    cursor: pointer;
    transition: var(--transition-smooth);
}

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

.tab-btn.active {
    background: var(--gradient-primary);
    color: white;
    box-shadow: 0 4px 12px -2px rgba(139, 92, 246, 0.35);
}

/* Tab Panel Transitions */
.tab-panel {
    animation: fadeIn 0.4s ease forwards;
}

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

/* ==========================================================================
   Card Foundations (Glassmorphism)
   ========================================================================== */
.glassmorphic {
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border-color);
    box-shadow: var(--card-shadow);
}

.card {
    border-radius: var(--radius-xl);
    padding: 32px;
    transition: var(--transition-smooth);
}

.card:hover {
    border-color: var(--border-hover);
}

.card-title {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.card-title svg {
    width: 20px;
    height: 20px;
    color: var(--accent-purple);
}

/* ==========================================================================
   Interactive Downloader Form
   ========================================================================== */
.downloader-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    background: rgba(0, 0, 0, 0.35);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 2px;
    transition: var(--transition-smooth);
}

.input-wrapper:focus-within {
    border-color: var(--accent-purple);
    box-shadow: 0 0 0 2px rgba(124, 58, 237, 0.15), var(--glow-shadow);
    background: rgba(0, 0, 0, 0.45);
}

.input-icon {
    position: absolute;
    left: 18px;
    width: 20px;
    height: 20px;
    color: var(--text-muted);
    pointer-events: none;
}

.input-wrapper input {
    width: 100%;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 1rem;
    padding: 18px 54px 18px 50px;
}

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

.icon-btn {
    position: absolute;
    right: 14px;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 8px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition-smooth);
}

.icon-btn svg {
    width: 20px;
    height: 20px;
}

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

/* ==========================================================================
   Buttons
   ========================================================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    font-family: var(--font-sans);
    font-size: 0.95rem;
    font-weight: 600;
    padding: 14px 24px;
    border-radius: var(--radius-md);
    border: none;
    cursor: pointer;
    transition: var(--transition-smooth);
    text-decoration: none;
}

.primary-btn {
    background: var(--gradient-primary);
    color: white;
    box-shadow: 0 4px 15px -3px rgba(139, 92, 246, 0.45);
}

.primary-btn:hover {
    background: var(--gradient-btn-hover);
    box-shadow: 0 10px 25px -4px rgba(217, 70, 239, 0.5);
    transform: translateY(-2px);
}

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

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

.secondary-btn:hover {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.18);
    transform: translateY(-2px);
}

.secondary-btn:active {
    transform: translateY(1px);
}

.text-btn {
    background: transparent;
    color: var(--text-secondary);
}

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

/* ==========================================================================
   Auto-Fetch Loader Overlay
   ========================================================================== */
.fetching-loader {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 32px;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    margin-top: 20px;
    animation: slideUpFade 0.4s ease forwards;
}

.spinner-glow {
    width: 44px;
    height: 44px;
    border: 3.5px solid rgba(255, 255, 255, 0.04);
    border-top: 3.5px solid var(--accent-pink);
    border-right: 3.5px solid var(--accent-purple);
    border-radius: 50%;
    animation: spin 0.9s linear infinite;
    filter: drop-shadow(0 0 10px rgba(139, 92, 246, 0.5));
}

#fetching-text {
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text-secondary);
    animation: pulse-text 1.6s infinite ease-in-out;
}

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

@keyframes pulse-text {
    0%, 100% { opacity: 0.6; }
    50% { opacity: 1; }
}

/* ==========================================================================
   Reel Preview Container
   ========================================================================== */
.preview-area {
    margin-top: 24px;
    padding-top: 24px;
    border-top: 1px solid var(--border-color);
    animation: slideUpFade 0.4s ease forwards;
}

.preview-card {
    display: flex;
    gap: 24px;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 20px;
}

.thumbnail-wrapper {
    position: relative;
    width: 130px;
    height: 180px;
    flex-shrink: 0;
    border-radius: var(--radius-sm);
    overflow: hidden;
    border: 1px solid var(--border-color);
}

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

.duration-tag {
    position: absolute;
    bottom: 8px;
    right: 8px;
    background: rgba(9, 9, 14, 0.85);
    backdrop-filter: blur(4px);
    color: white;
    font-size: 0.75rem;
    padding: 3px 7px;
    border-radius: 4px;
    font-weight: 600;
}

.preview-details {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    flex-grow: 1;
}

.creator-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(219, 39, 119, 0.08);
    border: 1px solid rgba(219, 39, 119, 0.18);
    color: var(--accent-pink);
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    align-self: flex-start;
}

.creator-badge svg {
    width: 12px;
    height: 12px;
}

.preview-title {
    font-size: 0.95rem;
    font-weight: 400;
    color: var(--text-primary);
    line-height: 1.45;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin: 10px 0;
}

.preview-actions {
    display: flex;
    gap: 12px;
    align-items: center;
}

.preview-actions .btn {
    padding: 11px 20px;
    font-size: 0.88rem;
}

/* ==========================================================================
   Download Started & Success Actions
   ========================================================================== */
.success-actions {
    margin-top: 24px;
    padding-top: 24px;
    border-top: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 16px;
    align-items: center;
    animation: slideUpFade 0.4s ease forwards;
}

.success-header {
    display: flex;
    align-items: center;
    gap: 12px;
}

.success-icon-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(16, 185, 129, 0.12);
    color: var(--accent-emerald);
}

.success-icon-wrapper svg {
    width: 22px;
    height: 22px;
}

.success-header h3 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
}

/* ==========================================================================
   Guides & Instruction Steps
   ========================================================================== */
.guide-steps {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.guide-step {
    display: flex;
    gap: 16px;
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid var(--border-color);
    padding: 20px;
    border-radius: var(--radius-md);
    transition: var(--transition-smooth);
}

.guide-step:hover {
    background: rgba(255, 255, 255, 0.02);
    border-color: rgba(255, 255, 255, 0.12);
}

.step-num {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: rgba(139, 92, 246, 0.12);
    border: 1px solid rgba(139, 92, 246, 0.25);
    color: #a78bfa;
    font-size: 0.9rem;
    font-weight: 700;
    flex-shrink: 0;
}

.step-content h4 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 4px;
    color: var(--text-primary);
}

.step-content p {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.45;
}

/* ==========================================================================
   Accordion component (Privacy Policy)
   ========================================================================== */
.accordion-group {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.accordion-item {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: rgba(0, 0, 0, 0.15);
    overflow: hidden;
    transition: var(--transition-smooth);
}

.accordion-header {
    width: 100%;
    background: transparent;
    border: none;
    padding: 16px 20px;
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 0.95rem;
    font-weight: 600;
    text-align: left;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    outline: none;
}

.accordion-icon {
    width: 16px;
    height: 16px;
    color: var(--text-secondary);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.accordion-item.active .accordion-icon {
    transform: rotate(180deg);
    color: var(--text-primary);
}

.accordion-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.accordion-inner {
    padding: 0 20px 20px 20px;
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.5;
    border-top: 1px solid rgba(255, 255, 255, 0.03);
    padding-top: 16px;
}

.accordion-inner p {
    margin-bottom: 10px;
}
.accordion-inner p:last-child {
    margin-bottom: 0;
}

/* ==========================================================================
   Features Grid
   ========================================================================== */
.features-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.feature-box {
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid var(--border-color);
    padding: 20px;
    border-radius: var(--radius-md);
    display: flex;
    flex-direction: column;
    gap: 8px;
    transition: var(--transition-smooth);
}

.feature-box:hover {
    border-color: rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.01);
}

.feature-icon-wrapper {
    color: var(--accent-pink);
    display: flex;
    align-items: center;
}

.feature-icon-wrapper svg {
    width: 24px;
    height: 24px;
}

.feature-box h4 {
    font-size: 0.95rem;
    font-weight: 600;
}

.feature-box p {
    font-size: 0.82rem;
    color: var(--text-secondary);
    line-height: 1.4;
}

/* ==========================================================================
   Download History List
   ========================================================================== */
.library-section {
    margin-top: 0;
}

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

.library-header h2 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
}

.badge {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-height: 380px;
    overflow-y: auto;
    padding-right: 4px;
}

.history-item {
    display: flex;
    gap: 16px;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 12px;
    transition: var(--transition-smooth);
    animation: slideUpFade 0.3s ease forwards;
}

.history-item:hover {
    border-color: rgba(139, 92, 246, 0.25);
    background: rgba(0, 0, 0, 0.25);
}

.history-thumb {
    position: relative;
    width: 60px;
    height: 80px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    flex-shrink: 0;
}

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

.history-info {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    flex-grow: 1;
    min-width: 0;
}

.history-title-row {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.history-title {
    font-size: 0.88rem;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.history-meta {
    font-size: 0.78rem;
    color: var(--text-secondary);
}

.history-actions {
    display: flex;
    gap: 8px;
}

.history-actions .btn {
    padding: 6px 12px;
    font-size: 0.78rem;
    border-radius: var(--radius-sm);
    gap: 6px;
}

.history-actions svg {
    width: 14px;
    height: 14px;
}

.history-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    color: var(--text-muted);
    text-align: center;
    gap: 12px;
}

.history-empty svg {
    width: 48px;
    height: 48px;
}

.history-empty p {
    font-size: 0.9rem;
}

/* ==========================================================================
   Toast Notification System
   ========================================================================== */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    z-index: 2000;
    max-width: 340px;
}

.toast {
    background: rgba(10, 10, 18, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    padding: 16px 20px;
    border-radius: var(--radius-md);
    color: var(--text-primary);
    box-shadow: 0 10px 30px rgba(0,0,0,0.4);
    display: flex;
    align-items: center;
    gap: 12px;
    animation: slideInLeft 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) forwards,
               fadeOut 0.3s ease 4.7s forwards;
}

.toast.success {
    border-left: 4px solid var(--accent-emerald);
}

.toast.error {
    border-left: 4px solid var(--accent-rose);
}

.toast-icon {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
}

.toast.success .toast-icon {
    color: var(--accent-emerald);
}

.toast.error .toast-icon {
    color: var(--accent-rose);
}

.toast-message {
    font-size: 0.88rem;
    font-weight: 500;
}

/* ==========================================================================
   Animations & Transitions
   ========================================================================== */
.hidden {
    display: none !important;
}

@keyframes slideUpFade {
    0% { opacity: 0; transform: translateY(18px); }
    100% { opacity: 1; transform: translateY(0); }
}

@keyframes slideInLeft {
    0% { transform: translateX(120%); opacity: 0; }
    100% { transform: translateX(0); opacity: 1; }
}

@keyframes fadeOut {
    0% { opacity: 1; }
    100% { opacity: 0; transform: translateY(-10px); }
}

/* ==========================================================================
   Responsive Adaptations
   ========================================================================== */
@media (max-width: 600px) {
    .app-container {
        padding: 16px 12px;
        gap: 20px;
    }
    
    .card {
        padding: 22px;
    }
    
    .features-grid {
        grid-template-columns: 1fr;
    }
    
    .preview-card {
        flex-direction: column;
        gap: 16px;
    }
    
    .thumbnail-wrapper {
        width: 100%;
        height: 250px;
    }
}

/* ==========================================================================
   Footer Styles
   ========================================================================== */
.app-footer {
    margin-top: 40px;
    padding-top: 24px;
    border-top: 1px solid var(--border-color);
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.footer-disclosure {
    font-size: 0.8rem;
    color: var(--text-muted);
    line-height: 1.6;
    max-width: 620px;
    margin: 0 auto;
}

.footer-copyright {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-top: 8px;
}
