/* =====================================================
   threadsave.pro – Main Stylesheet
   Dark/Light + RTL Support + Bootstrap Overrides
   ===================================================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

/* ─── CSS Variables (Light Theme) ─────────────────── */
:root {
    --bg-primary:    #ffffff;
    --bg-secondary:  #f8f9fa;
    --bg-card:       #ffffff;
    --bg-navbar:     #ffffff;
    --bg-footer:     #0f0f1a;
    --text-primary:  #1a1a2e;
    --text-secondary:#6c757d;
    --text-footer:   #adb5bd;
    --border-color:  #e9ecef;
    --accent:        #6366f1;
    --accent-hover:  #4f46e5;
    --accent-light:  #eef2ff;
    --shadow-sm:     0 2px 8px rgba(0,0,0,.06);
    --shadow-md:     0 8px 24px rgba(0,0,0,.10);
    --shadow-lg:     0 16px 48px rgba(0,0,0,.14);
    --radius:        12px;
    --radius-sm:     8px;
    --transition:    .25s ease;
    --navbar-height: 65px;
}

/* ─── Dark Theme ────────────────────────────────── */
[data-theme="dark"] {
    --bg-primary:    #0f0f1a;
    --bg-secondary:  #1a1a2e;
    --bg-card:       #1e1e35;
    --bg-navbar:     #0f0f1a;
    --text-primary:  #f1f5f9;
    --text-secondary:#94a3b8;
    --border-color:  #2d2d4e;
    --accent-light:  #1e1e40;
    --shadow-sm:     0 2px 8px rgba(0,0,0,.3);
    --shadow-md:     0 8px 24px rgba(0,0,0,.4);
    --shadow-lg:     0 16px 48px rgba(0,0,0,.5);
}

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

html {
    scroll-behavior: smooth;
    transition: background-color var(--transition);
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.7;
    font-size: 15px;
    transition: background-color var(--transition), color var(--transition);
}

/* RTL support */
[dir="rtl"] body { font-family: 'Inter', 'Segoe UI', Tahoma, sans-serif; }
[dir="rtl"] .me-auto { margin-left: auto !important; margin-right: 0 !important; }
[dir="rtl"] .ms-auto { margin-right: auto !important; margin-left: 0 !important; }
[dir="rtl"] .text-start { text-align: right !important; }

/* ─── Navbar ────────────────────────────────────── */
.navbar {
    background-color: var(--bg-navbar) !important;
    border-bottom: 1px solid var(--border-color);
    min-height: var(--navbar-height);
    padding: 0 1rem;
    box-shadow: var(--shadow-sm);
    transition: background-color var(--transition);
    position: sticky; top: 0; z-index: 1000;
}

@media (max-width: 991px) {
    .navbar-collapse {
        background-color: var(--bg-card);
        padding: 1.5rem;
        border-radius: var(--radius);
        box-shadow: var(--shadow-lg);
        margin-top: 10px;
        position: absolute;
        top: 100%;
        left: 1rem;
        right: 1rem;
        border: 1px solid var(--border-color);
    }
    .nav-item, .dropdown-menu {
        margin-bottom: 0.5rem;
    }
}

.navbar-brand {
    font-weight: 800;
    font-size: 1.35rem;
    color: var(--accent) !important;
    display: flex;
    align-items: center;
    gap: 8px;
}

.navbar-brand svg { width: 28px; height: 28px; }

.navbar-brand span.brand-threads { color: var(--accent); }
.navbar-brand span.brand-own    { color: var(--text-primary); }

.nav-link {
    font-weight: 500;
    color: var(--text-primary) !important;
    padding: .4rem .8rem !important;
    border-radius: var(--radius-sm);
    transition: background var(--transition), color var(--transition);
    font-size: .9rem;
}

.nav-link:hover, .nav-link.active {
    background: var(--accent-light);
    color: var(--accent) !important;
}

.dropdown-menu {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-md);
    border-radius: var(--radius-sm);
    padding: .4rem;
}

.dropdown-item {
    color: var(--text-primary);
    border-radius: 6px;
    padding: .5rem .9rem;
    font-size: .875rem;
    font-weight: 500;
}

.dropdown-item:hover { background: var(--accent-light); color: var(--accent); }

/* Language switcher */
.lang-switcher .dropdown-toggle {
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: .3rem .8rem;
    font-size: .82rem;
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 5px;
}

.lang-switcher .dropdown-toggle:hover { border-color: var(--accent); }
.lang-switcher .dropdown-menu { min-width: 160px; }

/* Theme toggle button */
#themeToggle {
    background: none;
    border: 1px solid var(--border-color);
    border-radius: 20px;
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-primary);
    transition: all var(--transition);
    font-size: 1rem;
}

#themeToggle:hover { background: var(--accent-light); border-color: var(--accent); color: var(--accent); }

/* ─── Hero Section ──────────────────────────────── */
.hero {
    background: linear-gradient(135deg, var(--bg-secondary) 0%, var(--bg-primary) 100%);
    padding: 70px 0 60px;
    text-align: center;
    position: relative;
    overflow: hidden;
}

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

.hero::after {
    content: '';
    position: absolute;
    top: -30%; right: -10%;
    width: 50%; height: 150%;
    background: radial-gradient(circle, rgba(99,102,241,.05) 0%, transparent 70%);
    pointer-events: none;
}

.hero-title {
    font-size: clamp(2rem, 5vw, 3.2rem);
    font-weight: 800;
    line-height: 1.15;
    margin-bottom: .6rem;
    background: linear-gradient(135deg, var(--accent) 0%, #a855f7 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.hero-subtitle {
    color: var(--text-secondary);
    font-size: 1.1rem;
    margin-bottom: 2rem;
    font-weight: 400;
}

/* ─── Download Form ─────────────────────────────── */
.download-form-wrap {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 1rem;
    display: flex;
    gap: .6rem;
    max-width: 720px;
    margin: 0 auto 1.5rem;
    box-shadow: var(--shadow-md);
}

.download-form-wrap input {
    flex: 1;
    border: none;
    outline: none;
    background: transparent;
    font-size: .95rem;
    color: var(--text-primary);
    font-family: inherit;
}

.download-form-wrap input::placeholder { color: var(--text-secondary); }

.btn-input-action {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 1.15rem;
    cursor: pointer;
    padding: 0 .3rem;
    transition: color var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-input-action:hover {
    color: var(--accent);
}

.btn-download {
    background: linear-gradient(135deg, var(--accent), #a855f7);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    padding: .6rem 1.5rem;
    font-weight: 600;
    font-size: .95rem;
    cursor: pointer;
    white-space: nowrap;
    transition: all var(--transition);
    box-shadow: 0 4px 14px rgba(99,102,241,.35);
}

.btn-download:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(99,102,241,.5);
}

.btn-download:active { transform: translateY(0); }
.btn-download:disabled { opacity: .7; cursor: not-allowed; transform: none; }

/* ─── Download Result ───────────────────────────── */
#downloadResult {
    max-width: 720px;
    margin: 0 auto;
    animation: slideDown .3s ease;
}

@keyframes slideDown {
    from { opacity:0; transform: translateY(-12px); }
    to   { opacity:1; transform: translateY(0); }
}

.result-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow-md);
}

.result-card .result-title {
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--accent);
    margin-bottom: .8rem;
    display: flex;
    align-items: center;
    gap: .5rem;
}

.result-thumb {
    width: 100%;
    max-height: 300px;
    object-fit: cover;
    border-radius: var(--radius-sm);
    margin-bottom: 1rem;
}

.download-btns {
    display: flex;
    flex-wrap: wrap;
    gap: .6rem;
}

.btn-dl {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: .55rem 1.2rem;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: .875rem;
    text-decoration: none;
    transition: all var(--transition);
}

.btn-dl-hd  { background: var(--accent); color: #fff; }
.btn-dl-sd  { background: #10b981; color: #fff; }
.btn-dl-aud { background: #f59e0b; color: #fff; }

.btn-dl:hover { opacity: .9; transform: translateY(-1px); color: #fff; }

/* Alert / info notice */
.info-notice {
    max-width: 720px;
    margin: 0 auto;
    background: #fef3c7;
    border: 1px solid #f59e0b;
    border-radius: var(--radius-sm);
    padding: .8rem 1rem;
    display: flex;
    align-items: flex-start;
    gap: .6rem;
    font-size: .875rem;
    color: #92400e;
}

[data-theme="dark"] .info-notice { background: #2d1f00; border-color: #7c5a00; color: #fcd34d; }

/* ─── Section Cards ─────────────────────────────── */
.section-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 2.5rem;
    box-shadow: var(--shadow-sm);
    transition: box-shadow var(--transition);
}

.section-card:hover { box-shadow: var(--shadow-md); }

.section-title {
    font-size: 1.65rem;
    font-weight: 700;
    color: var(--text-primary);
    text-align: center;
    margin-bottom: 1.5rem;
}

.section-title span { color: var(--accent); }

/* ─── How to Download Steps ───────────────────────── */
.step-item {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.4rem;
    align-items: flex-start;
}

.step-num {
    background: linear-gradient(135deg, var(--accent), #a855f7);
    color: #fff;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: .9rem;
    flex-shrink: 0;
    box-shadow: 0 3px 10px rgba(99,102,241,.3);
}

.step-content h5 {
    font-weight: 700;
    font-size: 1rem;
    margin-bottom: .2rem;
    color: var(--text-primary);
}

.step-content p {
    color: var(--text-secondary);
    font-size: .9rem;
    margin: 0;
}

/* ─── FAQ Accordion ─────────────────────────────── */
.faq-item {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    margin-bottom: .6rem;
    overflow: hidden;
    transition: box-shadow var(--transition);
}

.faq-item:hover { box-shadow: var(--shadow-sm); }

.faq-question {
    width: 100%;
    background: var(--bg-card);
    border: none;
    padding: 1rem 1.2rem;
    text-align: left;
    font-weight: 600;
    font-size: .95rem;
    color: var(--text-primary);
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    transition: background var(--transition);
    font-family: inherit;
}

[dir="rtl"] .faq-question { text-align: right; }

.faq-question:hover { background: var(--accent-light); }
.faq-question.active { color: var(--accent); }

.faq-icon {
    width: 20px; height: 20px; flex-shrink: 0;
    border: 2px solid currentColor; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    transition: transform .3s ease;
    font-size: .75rem;
}

.faq-question.active .faq-icon { transform: rotate(45deg); }

.faq-answer {
    display: none;
    padding: .8rem 1.2rem 1rem;
    color: var(--text-secondary);
    font-size: .9rem;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
}

.faq-answer.open { display: block; animation: fadeIn .2s ease; }
@keyframes fadeIn { from { opacity:0; } to { opacity:1; } }

/* ─── How-to-Use page steps ─────────────────────── */
.htu-step {
    display: flex;
    gap: 1.5rem;
    margin-bottom: 2rem;
    padding: 1.5rem;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    transition: box-shadow var(--transition), transform var(--transition);
}

.htu-step:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }

.htu-step-icon {
    background: linear-gradient(135deg, var(--accent), #a855f7);
    color: #fff;
    width: 52px; height: 52px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    flex-shrink: 0;
    box-shadow: 0 4px 14px rgba(99,102,241,.3);
}

.htu-step-content h4 { font-weight: 700; font-size: 1.05rem; margin-bottom: .4rem; }
.htu-step-content p  { color: var(--text-secondary); font-size: .9rem; margin: 0; }

/* ─── Tips Cards ─────────────────────────────────── */
.tip-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-left: 3px solid var(--accent);
    border-radius: var(--radius-sm);
    padding: 1rem 1.2rem;
    margin-bottom: .7rem;
    font-size: .9rem;
    color: var(--text-secondary);
    display: flex;
    align-items: flex-start;
    gap: .7rem;
}

[dir="rtl"] .tip-card { border-left: none; border-right: 3px solid var(--accent); }

.tip-card i { color: var(--accent); margin-top: 2px; flex-shrink: 0; }

/* ─── Bookmark page ─────────────────────────────── */
.bm-method {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: .9rem 1.2rem;
    margin-bottom: .6rem;
    display: flex;
    align-items: center;
    gap: .8rem;
    font-size: .9rem;
    color: var(--text-primary);
    font-weight: 500;
}

.bm-method i { color: var(--accent); font-size: 1.1rem; }

.btn-bookmark {
    background: linear-gradient(135deg, var(--accent), #a855f7);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    padding: .8rem 2rem;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: all var(--transition);
    box-shadow: 0 4px 14px rgba(99,102,241,.35);
}

.btn-bookmark:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(99,102,241,.5); }

/* ─── About / Policy / ToS pages ────────────────── */
.page-hero {
    background: linear-gradient(135deg, var(--bg-secondary), var(--bg-primary));
    padding: 60px 0 40px;
    border-bottom: 1px solid var(--border-color);
}

.page-hero h1 {
    font-size: 2.2rem;
    font-weight: 800;
    color: var(--text-primary);
    margin-bottom: .5rem;
}

.page-hero p { color: var(--text-secondary); font-size: 1.05rem; }

.content-section {
    padding: 2.5rem 0;
}

.policy-section {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 2rem 2.5rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow-sm);
}

.policy-section h3 {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--accent);
    margin-bottom: .7rem;
    display: flex;
    align-items: center;
    gap: .5rem;
}

.policy-section p { color: var(--text-secondary); line-height: 1.8; margin: 0; }

/* ─── Footer ─────────────────────────────────────── */
footer {
    background: var(--bg-footer);
    color: var(--text-footer);
    padding: 50px 0 0;
    margin-top: 60px;
}

.footer-brand {
    color: #fff;
    font-weight: 800;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: .8rem;
}

.footer-brand span { color: var(--accent); }

footer p { font-size: .85rem; line-height: 1.7; color: var(--text-footer); }

footer h6 {
    color: #fff;
    font-weight: 700;
    font-size: .8rem;
    text-transform: uppercase;
    letter-spacing: .08em;
    margin-bottom: 1rem;
}

footer ul { list-style: none; padding: 0; margin: 0; }
footer ul li { margin-bottom: .45rem; }
footer ul li a {
    color: var(--text-footer);
    text-decoration: none;
    font-size: .85rem;
    transition: color var(--transition);
}
footer ul li a:hover { color: var(--accent); }

.footer-bottom {
    border-top: 1px solid rgba(255,255,255,.08);
    margin-top: 2.5rem;
    padding: 1.2rem 0;
    text-align: center;
    font-size: .8rem;
    color: #6c757d;
}

.footer-social a {
    color: var(--text-footer);
    font-size: 1.1rem;
    margin-right: 12px;
    text-decoration: none;
    transition: color var(--transition);
}

.footer-social a:hover { color: var(--accent); }

/* ─── Responsive ─────────────────────────────────── */
@media (max-width: 768px) {
    .download-form-wrap { flex-direction: column; }
    .btn-download { width: 100%; }
    .hero { padding: 50px 0 40px; }
    .policy-section { padding: 1.5rem; }
    .htu-step { flex-direction: column; gap: 1rem; }
    .section-card { padding: 1.5rem; }
}

/* ─── Loading spinner ────────────────────────────── */
.spinner {
    width: 20px; height: 20px;
    border: 2px solid rgba(255,255,255,.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin .7s linear infinite;
    display: inline-block;
    vertical-align: middle;
    margin-right: 6px;
}

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

/* ─── Utilities ──────────────────────────────────── */
.text-accent   { color: var(--accent) !important; }
.bg-card       { background: var(--bg-card) !important; }
.border-custom { border-color: var(--border-color) !important; }
