/* ============================================
   TikTok Downloader - Dark Mode Support
   Primary: #3399cc (blue)
   ============================================ */

:root {
    --primary: #3399cc;
    --primary-light: #e8f4fb;
    --primary-dark: #2277aa;
    --primary-shadow: rgba(51, 153, 204, 0.25);

    --success: #339966;
    --success-light: #e6f5ee;
    --danger: #e64e4e;
    --danger-light: #fdf0f0;

    --bg: #f8fafc;
    --bg-elevated: #ffffff;
    --bg-secondary: #f1f5f9;
    --bg-tertiary: #e2e8f0;

    --text: #1e293b;
    --text-secondary: #475569;
    --text-muted: #64748b;

    --border: #e2e8f0;
    --border-light: #f1f5f9;

    --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1);

    --radius-sm: 6px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-full: 9999px;

    --input-bg: #ffffff;
    --input-border: #e2e8f0;

    --transition: 0.25s ease;
}

[data-theme="dark"] {
    --primary: #4aabdf;
    --primary-light: rgba(74, 171, 223, 0.15);
    --primary-dark: #3399cc;
    --primary-shadow: rgba(74, 171, 223, 0.2);

    --success: #4ade80;
    --success-light: rgba(74, 222, 128, 0.15);
    --danger: #f87171;
    --danger-light: rgba(248, 113, 113, 0.15);

    --bg: #0f172a;
    --bg-elevated: #1e293b;
    --bg-secondary: #334155;
    --bg-tertiary: #475569;

    --text: #f1f5f9;
    --text-secondary: #cbd5e1;
    --text-muted: #94a3b8;

    --border: #334155;
    --border-light: #475569;

    --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.4);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.4);

    --input-bg: #334155;
    --input-border: #475569;
}

* { box-sizing: border-box; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    margin: 0;
    padding: 0;
    transition: background-color var(--transition), color var(--transition);
}

/* ── Tool Container ── */
.tool-container {
    max-width: 900px;
    margin: 0 auto;
    padding: 24px 20px 48px;
}

/* ── Tool Header ── */
.tool-header {
    text-align: center;
    margin-bottom: 32px;
}

.tool-title-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    margin-bottom: 12px;
}

.tool-icon-wrapper {
    width: 52px;
    height: 52px;
    background: var(--primary-light);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary);
    flex-shrink: 0;
}

.tool-icon-wrapper i { width: 28px; height: 28px; }

.tool-title {
    font-size: 2rem;
    font-weight: 800;
    color: var(--text);
    margin: 0;
    letter-spacing: -0.5px;
}

.tool-description {
    color: var(--text-secondary);
    font-size: 1rem;
    max-width: 800px;
    margin: 0 auto;
    line-height: 1.7;
}

/* ── URL Card ── */
.url-card {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 28px;
    box-shadow: var(--shadow-md);
    margin-bottom: 20px;
}

.url-label {
    display: block;
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.url-input-row {
    display: flex;
    gap: 10px;
    margin-bottom: 16px;
}

.url-input {
    flex: 1;
    padding: 13px 16px;
    background: var(--input-bg);
    border: 1.5px solid var(--input-border);
    border-radius: var(--radius-md);
    font-size: 0.95rem;
    color: var(--text);
    transition: border-color var(--transition), box-shadow var(--transition);
    outline: none;
}

.url-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-shadow);
}

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

.btn-paste {
    padding: 13px 16px;
    background: var(--bg-secondary);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all var(--transition);
    white-space: nowrap;
}

.btn-paste:hover { background: var(--bg-tertiary); color: var(--text); }
.btn-paste i { width: 16px; height: 16px; }

/* ── Options Row ── */
.options-row {
    display: flex;
    align-items: flex-end;
    gap: 16px;
    flex-wrap: wrap;
}

.option-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.option-group > label {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.option-select {
    padding: 10px 12px;
    background: var(--input-bg);
    border: 1.5px solid var(--input-border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 0.9rem;
    cursor: pointer;
    outline: none;
    transition: border-color var(--transition);
    min-width: 130px;
}

.option-select:focus { border-color: var(--primary); }

/* Toggle */
.toggle-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.toggle-group > label:first-child {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.toggle-row {
    display: flex;
    align-items: center;
    gap: 10px;
    height: 40px;
}

.toggle-switch {
    position: relative;
    width: 44px;
    height: 24px;
    flex-shrink: 0;
}

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

.toggle-slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background: var(--bg-tertiary);
    border-radius: var(--radius-full);
    transition: background var(--transition);
}

.toggle-slider:before {
    content: "";
    position: absolute;
    width: 18px;
    height: 18px;
    left: 3px;
    top: 3px;
    background: white;
    border-radius: 50%;
    transition: transform var(--transition);
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.toggle-switch input:checked + .toggle-slider { background: var(--primary); }
.toggle-switch input:checked + .toggle-slider:before { transform: translateX(20px); }

.toggle-label {
    font-size: 0.9rem;
    color: var(--text-secondary);
    cursor: pointer;
}

/* ── Download Button ── */
.btn-fetch {
    margin-left: auto;
    padding: 10px 28px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: background var(--transition), transform var(--transition), box-shadow var(--transition);
    box-shadow: 0 4px 14px var(--primary-shadow);
    white-space: nowrap;
    height: 40px;
}

.btn-fetch:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
}

.btn-fetch:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.btn-fetch i { width: 18px; height: 18px; }

/* ── Progress ── */
.progress-section {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px 28px;
    box-shadow: var(--shadow-md);
    margin-bottom: 20px;
    display: none;
}

.progress-section.visible { display: block; }

.progress-status {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 14px;
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
}

.progress-spinner {
    width: 18px;
    height: 18px;
    border: 2px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    flex-shrink: 0;
}

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

.progress-bar-track {
    height: 6px;
    background: var(--bg-secondary);
    border-radius: var(--radius-full);
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background: var(--primary);
    border-radius: var(--radius-full);
    width: 0%;
    transition: width 0.4s ease;
}

/* ── Error ── */
.error-box {
    background: var(--danger-light);
    border: 1px solid var(--danger);
    border-radius: var(--radius-md);
    padding: 16px 20px;
    display: none;
    margin-bottom: 20px;
}

.error-box.visible { display: flex; gap: 12px; align-items: flex-start; }
.error-box > i { color: var(--danger); width: 20px; height: 20px; flex-shrink: 0; margin-top: 2px; }

.error-title {
    font-weight: 700;
    color: var(--danger);
    margin-bottom: 4px;
    font-size: 0.9rem;
}

.error-msg {
    color: var(--text-secondary);
    font-size: 0.88rem;
    line-height: 1.5;
}

.error-msg a { color: var(--primary); text-decoration: underline; }

/* ── Result Card ── */
.result-card {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-lg);
    margin-bottom: 20px;
    display: none;
}

.result-card.visible { display: block; }

.result-header {
    display: flex;
    gap: 20px;
    padding: 24px 24px 16px;
    align-items: flex-start;
}

.result-thumb {
    flex-shrink: 0;
    width: 90px;
    border-radius: var(--radius-md);
    overflow: hidden;
    background: var(--bg-secondary);
    aspect-ratio: 9/16;
}

.result-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.result-meta { flex: 1; min-width: 0; }

.result-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text);
    margin: 0 0 10px;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.result-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 12px;
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.82rem;
    color: var(--text-muted);
}

.stat-item i { width: 14px; height: 14px; }

.badge-row { display: flex; flex-wrap: wrap; gap: 6px; }

.badge {
    padding: 3px 10px;
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 600;
    background: var(--primary-light);
    color: var(--primary);
}

.badge.green {
    background: var(--success-light);
    color: var(--success);
}

.result-actions {
    padding: 0 24px 24px;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.btn-dl {
    padding: 12px 24px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all var(--transition);
    box-shadow: 0 4px 12px var(--primary-shadow);
    text-decoration: none;
}

.btn-dl:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
}

.btn-dl i { width: 17px; height: 17px; }

.btn-new {
    padding: 12px 20px;
    background: var(--bg-secondary);
    color: var(--text-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all var(--transition);
}

.btn-new:hover { background: var(--bg-tertiary); color: var(--text); }
.btn-new i { width: 16px; height: 16px; }

/* ── How It Works ── */
.how-section, .info-section, .related-section, .faq-section {
    margin: 40px 0;
}

.section-title {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text);
    margin: 0 0 18px;
}

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

.step-card {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 20px;
    text-align: center;
}

.step-num {
    width: 34px;
    height: 34px;
    background: var(--primary-light);
    color: var(--primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 0.88rem;
    margin: 0 auto 10px;
}

.step-icon { color: var(--primary); margin-bottom: 8px; }
.step-icon i { width: 22px; height: 22px; }

.step-title {
    font-weight: 700;
    font-size: 0.88rem;
    color: var(--text);
    margin: 0 0 5px;
}

.step-desc {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin: 0;
    line-height: 1.5;
}

/* ── Info Section ── */
.info-section h2 {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text);
    margin: 0 0 10px;
}

.info-section p {
    color: var(--text-secondary);
    font-size: 0.93rem;
    line-height: 1.7;
    margin: 0 0 12px;
}

.info-section a { color: var(--primary); text-decoration: none; font-weight: 600; }
.info-section a:hover { text-decoration: underline; }

/* ── Related Tools ── */
.related-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px;
}

.related-card {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 16px 12px;
    text-align: center;
    text-decoration: none;
    color: var(--text);
    transition: all var(--transition);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.related-card:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
    color: var(--primary);
}

.related-card i { width: 22px; height: 22px; color: var(--primary); }
.related-card span { font-size: 0.8rem; font-weight: 600; line-height: 1.3; }

/* ── FAQ ── */
.faq-list { display: flex; flex-direction: column; gap: 8px; }

.faq-item {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.faq-question {
    padding: 16px 20px;
    font-weight: 600;
    font-size: 0.93rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    color: var(--text);
    user-select: none;
    transition: background var(--transition);
}

.faq-question:hover { background: var(--bg-secondary); }

.faq-chevron {
    width: 18px;
    height: 18px;
    color: var(--text-muted);
    flex-shrink: 0;
    transition: transform var(--transition);
}

.faq-item.open .faq-chevron { transform: rotate(180deg); }

.faq-answer {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease, padding 0.3s ease;
    padding: 0 20px;
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.7;
}

.faq-item.open .faq-answer {
    max-height: 400px;
    padding: 0 20px 16px;
}

.faq-answer a { color: var(--primary); }

/* ── Responsive ── */
@media (max-width: 640px) {
    .tool-title { font-size: 1.6rem; }
    .url-input-row { flex-direction: column; }
    .options-row { flex-direction: column; align-items: flex-start; }
    .btn-fetch { margin-left: 0; width: 100%; justify-content: center; }
    .result-header { flex-direction: column; }
    .steps-grid { grid-template-columns: repeat(2, 1fr); }
    .related-grid { grid-template-columns: repeat(2, 1fr); }
}
