/* ==========================================================================
   TikTok Downloader — Apple Dark Aesthetic Design System
   ========================================================================== */

/* --- CSS Variables & Design Tokens --- */
:root {
    /* Color Palette */
    --bg-base: #040407;
    --bg-surface-1: rgba(18, 18, 28, 0.65);
    --bg-surface-2: rgba(28, 28, 42, 0.75);
    --bg-surface-input: rgba(12, 12, 20, 0.7);
    --bg-card-hover: rgba(35, 35, 52, 0.85);

    /* Text Colors */
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --text-accent: #60a5fa;

    /* Accent & Gradients */
    --accent-purple: #8b5cf6;
    --accent-blue: #3b82f6;
    --accent-cyan: #06b6d4;
    --accent-pink: #ec4899;
    --accent-gradient: linear-gradient(135deg, #a855f7 0%, #3b82f6 50%, #06b6d4 100%);
    --accent-gradient-btn: linear-gradient(135deg, #6366f1 0%, #3b82f6 100%);
    --accent-gradient-btn-hover: linear-gradient(135deg, #4f46e5 0%, #2563eb 100%);

    /* Borders & Glassmorphism */
    --border-subtle: rgba(255, 255, 255, 0.08);
    --border-highlight: rgba(255, 255, 255, 0.16);
    --border-focus: rgba(99, 102, 241, 0.5);
    --glass-blur: blur(24px) saturate(180%);

    /* Shadows & Glows */
    --shadow-sm: 0 4px 12px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 12px 32px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 35px rgba(99, 102, 241, 0.25);
    --shadow-glow-pink: 0 0 30px rgba(236, 72, 153, 0.2);

    /* Transitions & Radii */
    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 22px;
    --radius-pill: 9999px;
    --transition-fast: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    --transition-smooth: all 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

/* --- Base & Reset --- */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'SF Pro Text', sans-serif;
    background-color: var(--bg-base);
    color: var(--text-primary);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    scroll-behavior: smooth;
    overflow-x: hidden;
}

body {
    min-height: 100vh;
    position: relative;
    overflow-x: hidden;
}

/* Three.js Background Canvas */
#bg-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: -2;
    pointer-events: none;
    filter: blur(6px);
    -webkit-filter: blur(6px);
    opacity: 0.85;
}

/* Ambient Blurred Glow Orbs */
.bg-blur-orbs {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: -1;
    pointer-events: none;
    overflow: hidden;
}

.orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(100px);
    -webkit-filter: blur(100px);
    will-change: transform;
    opacity: 0.65;
}

.orb-1 {
    width: 650px;
    height: 650px;
    background: radial-gradient(circle, rgba(139, 92, 246, 0.45) 0%, rgba(0, 0, 0, 0) 70%);
    top: -15%;
    left: 10%;
    animation: floatOrb1 18s ease-in-out infinite alternate;
}

.orb-2 {
    width: 580px;
    height: 580px;
    background: radial-gradient(circle, rgba(59, 130, 246, 0.4) 0%, rgba(0, 0, 0, 0) 70%);
    top: 35%;
    right: 5%;
    animation: floatOrb2 22s ease-in-out infinite alternate;
}

.orb-3 {
    width: 620px;
    height: 620px;
    background: radial-gradient(circle, rgba(236, 72, 153, 0.3) 0%, rgba(0, 0, 0, 0) 70%);
    bottom: -10%;
    left: 25%;
    animation: floatOrb3 20s ease-in-out infinite alternate;
}

@keyframes floatOrb1 {
    0% { transform: translate(0, 0) scale(1); }
    100% { transform: translate(60px, 80px) scale(1.15); }
}

@keyframes floatOrb2 {
    0% { transform: translate(0, 0) scale(1); }
    100% { transform: translate(-70px, -50px) scale(1.2); }
}

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

.app-wrapper {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* --- Utility Classes --- */
.hidden {
    display: none !important;
}

.card-glass {
    background: var(--bg-surface-1);
    backdrop-filter: blur(32px) saturate(190%);
    -webkit-backdrop-filter: blur(32px) saturate(190%);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    transition: var(--transition-smooth);
}

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

.text-gradient {
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* --- Toast Notifications --- */
.toast-container {
    position: fixed;
    top: 24px;
    right: 24px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

.toast {
    pointer-events: auto;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 20px;
    background: rgba(18, 18, 28, 0.92);
    backdrop-filter: blur(16px);
    border: 1px solid var(--border-highlight);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 0.92rem;
    font-weight: 500;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
    transform: translateX(120%);
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.4s ease;
    opacity: 0;
}

.toast.show {
    transform: translateX(0);
    opacity: 1;
}

.toast.toast-success i {
    color: #10b981;
}

.toast.toast-error i {
    color: #f43f5e;
}

.toast.toast-info i {
    color: var(--accent-blue);
}

/* --- Header --- */
.site-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(4, 4, 7, 0.75);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border-subtle);
}

.header-container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 18px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.brand-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: var(--text-primary);
}

.logo-icon {
    width: 38px;
    height: 38px;
    border-radius: 12px;
    background: var(--accent-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    color: #fff;
    box-shadow: 0 4px 14px rgba(139, 92, 246, 0.35);
}

.logo-icon.small {
    width: 28px;
    height: 28px;
    font-size: 0.9rem;
    border-radius: 8px;
}

.logo-text {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.logo-accent {
    font-weight: 400;
    color: var(--text-secondary);
}

.header-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-pill);
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    color: var(--text-secondary);
}

.badge-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #10b981;
    box-shadow: 0 0 8px #10b981;
}

/* --- Main Layout --- */
.main-content {
    max-width: 1040px;
    width: 100%;
    margin: 0 auto;
    padding: 50px 24px 80px;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 64px;
}

/* --- Hero Section --- */
.hero-section {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.hero-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 18px;
    background: rgba(139, 92, 246, 0.12);
    border: 1px solid rgba(139, 92, 246, 0.3);
    border-radius: var(--radius-pill);
    font-size: 0.85rem;
    font-weight: 600;
    color: #c084fc;
    margin-bottom: 24px;
}

.hero-title {
    font-size: clamp(2.4rem, 5vw, 3.8rem);
    font-weight: 800;
    line-height: 1.15;
    letter-spacing: -0.03em;
    margin-bottom: 18px;
}

.hero-subtitle {
    font-size: clamp(1rem, 2vw, 1.2rem);
    color: var(--text-secondary);
    max-width: 620px;
    margin: 0 auto 40px;
    font-weight: 400;
}

/* --- Input Form Card --- */
.input-card {
    width: 100%;
    max-width: 780px;
    background: var(--bg-surface-1);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 10px;
    box-shadow: var(--shadow-md), var(--shadow-glow);
    transition: var(--transition-smooth);
}

.input-card:focus-within {
    border-color: var(--border-focus);
    box-shadow: var(--shadow-md), 0 0 45px rgba(99, 102, 241, 0.35);
}

.url-form {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
}

.input-wrapper {
    flex: 1;
    position: relative;
    display: flex;
    align-items: center;
    background: var(--bg-surface-input);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 0 16px;
    height: 56px;
    transition: var(--transition-fast);
}

.input-wrapper:focus-within {
    border-color: var(--border-highlight);
    background: rgba(18, 18, 30, 0.85);
}

.input-icon {
    font-size: 1.1rem;
    color: var(--text-muted);
    margin-right: 12px;
}

.url-input {
    width: 100%;
    height: 100%;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 1rem;
    font-weight: 400;
}

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

.action-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.1rem;
    cursor: pointer;
    padding: 8px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition-fast);
    position: relative;
}

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

.btn-tooltip {
    position: absolute;
    bottom: -32px;
    left: 50%;
    transform: translateX(-50%);
    background: #1e1e2e;
    color: #fff;
    font-size: 0.72rem;
    padding: 4px 8px;
    border-radius: 4px;
    opacity: 0;
    pointer-events: none;
    transition: var(--transition-fast);
    white-space: nowrap;
}

.action-btn:hover .btn-tooltip {
    opacity: 1;
}

.btn-primary {
    height: 56px;
    padding: 0 28px;
    border-radius: var(--radius-md);
    background: var(--accent-gradient-btn);
    border: none;
    color: #fff;
    font-family: inherit;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    box-shadow: 0 4px 20px rgba(59, 130, 246, 0.4);
    transition: var(--transition-fast);
    white-space: nowrap;
}

.btn-primary:hover {
    background: var(--accent-gradient-btn-hover);
    transform: translateY(-1px);
    box-shadow: 0 6px 25px rgba(59, 130, 246, 0.55);
}

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

.input-footer {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-top: 10px;
    padding-top: 8px;
    font-size: 0.85rem;
}

.example-text {
    color: var(--text-muted);
}

.sample-link-btn {
    background: none;
    border: none;
    color: var(--accent-text, #818cf8);
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: var(--transition-fast);
    text-decoration: underline;
    text-underline-offset: 3px;
}

.sample-link-btn:hover {
    color: #a5b4fc;
}

/* --- Loading Spinner State --- */
.loading-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 20px;
    margin-top: 36px;
    padding: 30px;
}

.spinner-ring {
    position: relative;
    width: 58px;
    height: 58px;
    border-radius: 50%;
    background: conic-gradient(from 0deg, transparent 0%, var(--accent-purple) 70%, var(--accent-cyan) 100%);
    animation: spinRing 1s linear infinite;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ring-core {
    width: 46px;
    height: 46px;
    background: var(--bg-base);
    border-radius: 50%;
}

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

.loading-info {
    text-align: center;
}

.loading-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);

}

.loading-subtitle {
    font-size: 0.88rem;
    color: var(--text-muted);
    margin-top: 4px;
}

/* --- Preview & Info Card Section --- */
.preview-section {
    width: 100%;
}

.preview-card {
    padding: 28px;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 20px;
    margin-bottom: 24px;
    border-bottom: 1px solid var(--border-subtle);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 14px;
}

.user-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--accent-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    color: #fff;
}

.user-details {
    display: flex;
    flex-direction: column;
}

.user-name {
    font-weight: 700;
    font-size: 1.05rem;
    color: var(--text-primary);
}

.video-sound {
    font-size: 0.82rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 6px;
}

.quality-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    background: rgba(16, 185, 129, 0.12);
    border: 1px solid rgba(16, 185, 129, 0.3);
    border-radius: var(--radius-pill);
    color: #34d399;
    font-size: 0.82rem;
    font-weight: 600;
}

.preview-grid {
    display: grid;
    grid-template-columns: 260px 1fr;
    gap: 28px;
}

.thumbnail-wrapper {
    position: relative;
    width: 100%;
}

.thumbnail-aspect {
    position: relative;
    width: 100%;
    padding-top: 133.33%; /* 3:4 aspect ratio */
    border-radius: var(--radius-md);
    overflow: hidden;
    background: #111;
    border: 1px solid var(--border-subtle);
}

.thumbnail-img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.4s ease;
}

.thumbnail-wrapper:hover .thumbnail-img {
    transform: scale(1.05);
}

.play-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 1.2rem;
    border: 1px solid rgba(255, 255, 255, 0.2);
    pointer-events: none;
    box-shadow: 0 8px 20px rgba(0,0,0,0.5);
}

.info-wrapper {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.video-caption-title {
    font-size: 1.25rem;
    font-weight: 600;
    line-height: 1.4;
    color: var(--text-primary);
    margin-bottom: 20px;
}

.meta-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-bottom: 24px;
}

.meta-item {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-subtle);
    padding: 12px 16px;
    border-radius: var(--radius-md);
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.meta-label {
    font-size: 0.78rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 6px;
}

.meta-value {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
}

.download-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.btn-download {
    width: 100%;
    height: 52px;
    border-radius: var(--radius-md);
    border: none;
    font-family: inherit;
    font-size: 0.98rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: var(--transition-fast);
}

.btn-download-primary {
    background: var(--accent-gradient);
    color: #fff;
    box-shadow: 0 4px 18px rgba(139, 92, 246, 0.35);
}

.btn-download-primary:hover {
    box-shadow: 0 6px 24px rgba(139, 92, 246, 0.5);
    transform: translateY(-2px);
}

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

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

/* Simulated Download Progress Box */
.progress-box {
    margin-top: 18px;
    padding: 16px;
    background: rgba(12, 12, 22, 0.85);
    border: 1px solid var(--border-highlight);
    border-radius: var(--radius-md);
}

.progress-header {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    margin-bottom: 8px;
}

.progress-status {
    color: var(--text-primary);
    font-weight: 500;
}

.progress-percent {
    color: var(--accent-cyan);
    font-weight: 700;
}

.progress-bar-track {
    width: 100%;
    height: 8px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-pill);
    overflow: hidden;
    margin-bottom: 8px;
}

.progress-bar-fill {
    width: 0%;
    height: 100%;
    background: var(--accent-gradient);
    border-radius: var(--radius-pill);
    transition: width 0.15s ease-out;
}

.progress-meta {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* --- Features Section --- */
.section-title {
    text-align: center;
    font-size: 1.8rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin-bottom: 32px;
}

.features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
}

.feature-card {
    padding: 28px 22px;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 14px;
}

.feature-icon {
    width: 46px;
    height: 46px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    color: var(--accent-text, #818cf8);
}

.feature-card h3 {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text-primary);
}

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

/* --- FAQ Accordion --- */
.faq-section {
    max-width: 820px;
    margin: 0 auto;
    width: 100%;
}

.faq-accordion {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.faq-item {
    padding: 0;
    overflow: hidden;
}

.faq-question {
    width: 100%;
    padding: 20px 24px;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 1.02rem;
    font-weight: 600;
    text-align: left;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.faq-icon {
    font-size: 0.88rem;
    color: var(--text-muted);
    transition: transform 0.3s ease;
}

.faq-item.active .faq-icon {
    transform: rotate(180deg);
    color: var(--accent-blue);
}

.faq-answer {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.35s cubic-bezier(0.16, 1, 0.3, 1), padding 0.35s ease;
    padding: 0 24px;
}

.faq-item.active .faq-answer {
    padding: 0 24px 20px 24px;
    max-height: 200px;
}

.faq-answer p {
    font-size: 0.92rem;
    color: var(--text-secondary);
    line-height: 1.6;
}

/* --- Footer --- */
.site-footer {
    border-top: 1px solid var(--border-subtle);
    background: rgba(4, 4, 7, 0.9);
    padding: 30px 24px;
}

.footer-container {
    max-width: 1040px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 20px;
}

.footer-brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

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

.footer-links {
    display: flex;
    gap: 20px;
}

.footer-links a {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.85rem;
    transition: var(--transition-fast);
}

.footer-links a:hover {
    color: var(--text-primary);
}

/* --- Responsive Queries --- */
@media (max-width: 840px) {
    .preview-grid {
        grid-template-columns: 1fr;
    }

    .thumbnail-aspect {
        max-width: 280px;
        margin: 0 auto;
        padding-top: 133.33%;
    }

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

    .btn-primary {
        width: 100%;
    }

    .input-wrapper {
        width: 100%;
    }
}

@media (max-width: 600px) {
    .main-content {
        padding: 30px 16px 60px;
        gap: 48px;
    }

    .meta-grid {
        grid-template-columns: 1fr;
    }

    .footer-container {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }
}
