/* ===== المتغيرات ===== */
:root {
    --primary: #1a73e8;
    --primary-dark: #1557b0;
    --bg: #f8fafc;
    --white: #ffffff;
    --text: #1f2937;
    --text-light: #6b7280;
    --border: #e5e7eb;
    --radius: 14px;
    --shadow: 0 4px 20px rgba(0, 0, 0, .08);
    --yt: #ff0000;
    --fb: #1877f2;
    --ig: #e4405f;
    --tt: #000000;
}

/* ===== إعادة تعيين ===== */
* { margin: 0; padding: 0; box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
    font-family: 'Cairo', sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.7;
    dir: rtl;
}

.container { max-width: 1100px; margin: 0 auto; padding: 0 16px; }
.container.narrow { max-width: 800px; }

img { max-width: 100%; display: block; }

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ===== الهيدر ===== */
.site-header {
    background: var(--white);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.site-header .container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 64px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 800;
    font-size: 1.3rem;
    color: var(--text);
    text-decoration: none;
}

.logo-icon {
    background: var(--primary);
    color: var(--white);
    width: 34px;
    height: 34px;
    border-radius: 10px;
    display: grid;
    place-items: center;
    font-size: 1rem;
}

.main-nav { display: flex; gap: 24px; align-items: center; }

.main-nav a {
    color: var(--text);
    font-weight: 600;
    font-size: .95rem;
    text-decoration: none;
    transition: color .2s;
}

.main-nav a:hover,
.main-nav a.active { color: var(--primary); }

.nav-toggle {
    display: none;
    flex-direction: column;
    gap: 5px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px;
}

.nav-toggle span {
    width: 24px;
    height: 2.5px;
    background: var(--text);
    border-radius: 3px;
}

/* ===== البانر الرئيسي ===== */
.hero {
    background: linear-gradient(160deg, #eef4ff 0%, #f8fafc 100%);
    padding: 56px 0 48px;
    text-align: center;
    /* منع أي overflow أفقي داخل السيكشن */
    overflow-x: hidden;
}

.hero .container {
    padding: 0 16px;
    box-sizing: border-box;
}

.hero h1 {
    font-size: clamp(1.7rem, 4.5vw, 2.7rem);
    font-weight: 800;
    line-height: 1.4;
    margin-bottom: 14px;
}

.highlight { color: var(--primary); }

.hero-sub {
    color: var(--text-light);
    font-size: 1.1rem;
    max-width: 640px;
    margin: 0 auto 32px;
    padding: 0 8px;
}

/* ===== صندوق التحميل ===== */

/* ─── الإعلانات فوق مربع التحميل (728x90) ─── */
.hero-ad-top {
    width: 100%;
    max-width: 728px;
    margin: 0 auto 16px;
    text-align: center;
    overflow: hidden;   /* يمنع أي تجاوز أفقي */
}

/* على الشاشات الأصغر من 728px: نُقلّص الإطار بـ CSS scale */
.hero-ad-top iframe {
    max-width: 100%;
}

/* ─── Wrapper: إعلان يمين + مربع + إعلان يسار ─── */
.downloader-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin: 0 auto;
    width: 100%;
    box-sizing: border-box;
}

/* ─── الإعلانات الجانبية (300x250) ─── */
.hero-ad-side {
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    /* مخفية افتراضياً على الشاشات الصغيرة — تُفعَّل بـ breakpoint أعلى */
    display: none;
}

/* ─── مربع التحميل الرئيسي ─── */
.downloader-box {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 24px;
    width: 100%;
    max-width: 720px;
    box-sizing: border-box;
    text-align: right;
    flex: 1 1 auto;
    min-width: 0;      /* يمنع flex overflow */
}

/* ─── إعلان أسفل مربع التحميل (320x50) ─── */
.hero-ad-bottom {
    width: 100%;
    max-width: 320px;
    margin: 16px auto 0;
    text-align: center;
    overflow: hidden;
}



.input-group {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.url-input {
    flex: 1;
    min-width: 0;         /* يمنع overflow على الموبايل */
    width: 100%;
    padding: 15px 18px;
    border: 2px solid var(--border);
    border-radius: 10px;
    font-size: 1rem;
    font-family: inherit;
    direction: ltr;
    text-align: left;
    box-sizing: border-box;
    transition: border-color .2s;
}

.url-input:focus {
    outline: none;
    border-color: var(--primary);
}

.btn-download {
    background: var(--primary);
    color: var(--white);
    border: none;
    border-radius: 10px;
    padding: 15px 34px;
    font-size: 1.05rem;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-width: 130px;
    transition: background .2s, transform .1s;
}

.btn-download:hover { background: var(--primary-dark); }
.btn-download:active { transform: scale(.97); }
.btn-download:disabled { opacity: .7; cursor: not-allowed; }

.btn-spinner {
    width: 18px;
    height: 18px;
    border: 3px solid rgba(255, 255, 255, .4);
    border-top-color: var(--white);
    border-radius: 50%;
    animation: spin .7s linear infinite;
}

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

.platform-tags {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 16px;
    justify-content: center;
}

.tag {
    font-size: .8rem;
    font-weight: 700;
    padding: 5px 12px;
    border-radius: 20px;
    background: var(--bg);
    color: var(--text-light);
    direction: ltr;
}

.tag-yt { color: var(--yt); }
.tag-fb { color: var(--fb); }
.tag-ig { color: var(--ig); }
.tag-tt { color: var(--tt); }

/* ===== نتيجة التحميل ===== */
.result { margin-top: 20px; }

.result-card {
    display: flex;
    gap: 16px;
    align-items: center;
    background: var(--bg);
    border-radius: 10px;
    padding: 14px;
    margin-bottom: 14px;
    flex-wrap: wrap;
}

.result-thumb {
    width: 120px;
    height: 70px;
    object-fit: cover;
    border-radius: 8px;
    background: var(--border);
    flex-shrink: 0;
}

.result-info { flex: 1; min-width: 180px; }

.result-title {
    font-weight: 700;
    font-size: .98rem;
    margin-bottom: 4px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.result-meta {
    font-size: .85rem;
    color: var(--text-light);
}

.quality-list { display: flex; flex-direction: column; gap: 8px; }

.quality-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 10px 14px;
    flex-wrap: wrap;
}

.quality-label { font-weight: 700; font-size: .95rem; }

.btn-q {
    background: var(--primary);
    color: var(--white);
    border: none;
    border-radius: 8px;
    padding: 9px 20px;
    font-weight: 700;
    font-family: inherit;
    font-size: .9rem;
    cursor: pointer;
    direction: ltr;
    transition: background .2s;
}

.btn-q:hover { background: var(--primary-dark); }
.btn-q.mp3 { background: #10b981; }
.btn-q.mp3:hover { background: #059669; }

.result-error {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #b91c1c;
    padding: 14px 16px;
    border-radius: 10px;
    font-size: .95rem;
}

.result-note {
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    color: #1e40af;
    padding: 12px 16px;
    border-radius: 10px;
    font-size: .9rem;
    margin-top: 10px;
}

/* ===== الإعلانات ===== */
.ad-slot {
    max-width: 1100px;
    margin: 24px auto;
    padding: 0 16px;
    text-align: center;
    position: relative;
    min-height: 90px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.ad-label {
    font-size: .7rem;
    color: var(--text-light);
    background: var(--border);
    padding: 2px 8px;
    border-radius: 4px;
    margin-bottom: 6px;
    letter-spacing: 1px;
}

/* ===== المميزات ===== */
.features { padding: 48px 0; }

.features h2,
.how h2,
.faq h2,
.content-section h2,
.legal-note h2 {
    text-align: center;
    font-size: clamp(1.4rem, 3.5vw, 2rem);
    font-weight: 800;
    margin-bottom: 32px;
}

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

.feature-card {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 26px 22px;
    transition: transform .2s, box-shadow .2s;
}

.feature-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow);
}

.feature-icon { font-size: 2rem; margin-bottom: 12px; }

.feature-card h3 {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 8px;
}

.feature-card p {
    color: var(--text-light);
    font-size: .95rem;
}

/* ===== خطوات الاستخدام ===== */
.how { padding: 48px 0; background: var(--white); }

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

.step {
    background: var(--bg);
    border-radius: var(--radius);
    padding: 26px 22px;
    text-align: center;
    position: relative;
}

.step-num {
    display: inline-grid;
    place-items: center;
    width: 44px;
    height: 44px;
    background: var(--primary);
    color: var(--white);
    font-weight: 800;
    font-size: 1.2rem;
    border-radius: 50%;
    margin-bottom: 14px;
}

.step h3 { font-size: 1.05rem; font-weight: 700; margin-bottom: 8px; }
.step p { color: var(--text-light); font-size: .93rem; }

/* ===== قسم المحتوى ===== */
.content-section { padding: 48px 0; }

.content-section h2 {
    text-align: right;
    font-size: 1.45rem;
    margin-top: 34px;
    margin-bottom: 14px;
}

.content-section h2:first-child { margin-top: 0; }

.content-section p {
    margin-bottom: 16px;
    color: #374151;
    font-size: 1rem;
}

.author-box {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    margin-top: 30px;
}

.author-info {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 12px;
}

.author-avatar {
    width: 52px;
    height: 52px;
    background: var(--primary);
    color: var(--white);
    border-radius: 50%;
    display: grid;
    place-items: center;
    font-weight: 800;
    font-size: 1.3rem;
    flex-shrink: 0;
}

.author-meta {
    display: block;
    color: var(--text-light);
    font-size: .85rem;
    font-weight: 400;
}

.author-bio {
    color: var(--text-light);
    font-size: .93rem;
}

/* ===== الأسئلة الشائعة ===== */
.faq { padding: 48px 0; background: var(--white); }

.faq-item {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 10px;
    margin-bottom: 12px;
    overflow: hidden;
}

.faq-item summary {
    padding: 16px 20px;
    font-weight: 700;
    cursor: pointer;
    list-style: none;
    position: relative;
    padding-left: 44px;
}

.faq-item summary::-webkit-details-marker { display: none; }

.faq-item summary::before {
    content: "+";
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1.4rem;
    color: var(--primary);
    font-weight: 700;
}

.faq-item[open] summary::before { content: "−"; }

.faq-item p {
    padding: 0 20px 18px;
    color: var(--text-light);
    font-size: .95rem;
}

/* ===== ملاحظة قانونية ===== */
.legal-note {
    padding: 40px 0;
    background: #fffbeb;
    border-top: 1px solid #fde68a;
    border-bottom: 1px solid #fde68a;
}

.legal-note h2 { color: #92400e; font-size: 1.3rem; }
.legal-note p { color: #78350f; text-align: center; }

/* ===== الفوتر ===== */
.site-footer {
    background: #111827;
    color: #d1d5db;
    padding: 44px 0 22px;
    margin-top: 0;
}

.footer-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 30px;
    margin-bottom: 30px;
}

.footer-col h3 {
    color: var(--white);
    font-size: 1.05rem;
    font-weight: 700;
    margin-bottom: 14px;
}

.footer-col p { font-size: .92rem; color: #9ca3af; }

.footer-col ul { list-style: none; }

.footer-col ul li { margin-bottom: 9px; }

.footer-col ul a {
    color: #9ca3af;
    font-size: .92rem;
    text-decoration: none;
    transition: color .2s;
}

.footer-col ul a:hover { color: var(--white); }

.footer-bottom {
    border-top: 1px solid #1f2937;
    padding-top: 18px;
    text-align: center;
    font-size: .87rem;
    color: #6b7280;
}

/* ===== بانر الموافقة ===== */
.consent-banner {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--white);
    border-top: 3px solid var(--primary);
    box-shadow: 0 -4px 24px rgba(0, 0, 0, .12);
    z-index: 1000;
    padding: 16px;
}

.consent-inner {
    max-width: 1100px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    flex-wrap: wrap;
}

.consent-inner p {
    font-size: .9rem;
    color: var(--text);
    flex: 1;
    min-width: 260px;
}

.consent-actions { display: flex; gap: 10px; }

.btn-consent {
    border: none;
    border-radius: 8px;
    padding: 11px 26px;
    font-weight: 700;
    font-family: inherit;
    font-size: .95rem;
    cursor: pointer;
    transition: opacity .2s;
}

.btn-consent:hover { opacity: .88; }

.btn-consent.accept { background: var(--primary); color: var(--white); }
.btn-consent.decline { background: var(--border); color: var(--text); }

/* ===== الصفحات الداخلية ===== */
.page-hero {
    background: linear-gradient(160deg, #eef4ff 0%, #f8fafc 100%);
    padding: 44px 0;
    text-align: center;
}

.page-hero h1 { font-size: clamp(1.5rem, 4vw, 2.2rem); font-weight: 800; }
.page-hero p { color: var(--text-light); margin-top: 8px; }

.page-content { padding: 40px 0; }

.page-content h2 {
    font-size: 1.3rem;
    font-weight: 700;
    margin: 30px 0 12px;
}

.page-content h2:first-child { margin-top: 0; }

.page-content p, .page-content li {
    color: #374151;
    margin-bottom: 12px;
    font-size: .98rem;
}

.page-content ul, .page-content ol { padding-right: 24px; margin-bottom: 16px; }

/* ===== التصميم للجوال ===== */
@media (max-width: 768px) {
    .nav-toggle { display: flex; }

    .main-nav {
        display: none;
        position: absolute;
        top: 64px;
        left: 0;
        right: 0;
        background: var(--white);
        flex-direction: column;
        padding: 16px;
        gap: 4px;
        border-bottom: 1px solid var(--border);
        box-shadow: var(--shadow);
    }

    .main-nav.open { display: flex; }

    .main-nav a {
        padding: 12px;
        width: 100%;
        border-radius: 8px;
    }

    .main-nav a:hover { background: var(--bg); }

    .hero { padding: 36px 0 32px; }

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

    .btn-download { width: 100%; }

    .result-card { flex-direction: column; align-items: flex-start; }
    .result-thumb { width: 100%; height: 160px; }

    .consent-inner { flex-direction: column; align-items: stretch; text-align: center; }
    .consent-actions { justify-content: center; }
    .btn-consent { flex: 1; }

    /* ── الإعلانات على الموبايل ── */

    /* مربع التحميل بالعرض الكامل */
    .downloader-box {
        max-width: 100%;
        padding: 18px 14px;
    }

    /* إخفاء إعلان 728x90 الكبير تماماً — يسبب overflow */
    .hero-ad-top { display: none; }

    /* إخفاء الإعلانات الجانبية — لا مكان لها على الموبايل */
    .hero-ad-side { display: none !important; }

    /* الـ wrapper يصبح عمود واحد بدون gap */
    .downloader-wrapper {
        flex-direction: column;
        gap: 0;
    }

    /* إعلان 320x50 أسفل المربع — يناسب الموبايل تماماً */
    .hero-ad-bottom {
        max-width: 100%;
        margin-top: 12px;
        overflow: hidden;
    }

    /* منع أي iframe من تجاوز عرض الشاشة */
    .hero-ad-bottom iframe {
        max-width: 100% !important;
        width: 100% !important;
    }
}

/* ===== التابلت (769px – 1099px) ===== */
@media (min-width: 769px) and (max-width: 1099px) {
    /* الإعلانات الجانبية لا تتسع — نخفيها */
    .hero-ad-side { display: none !important; }

    /* مربع التحميل يأخذ العرض المريح */
    .downloader-box {
        flex: unset;
        width: 100%;
        max-width: 680px;
        margin: 0 auto;
    }

    /* إعلان 728x90 — نُقلّصه إذا الشاشة أضيق منه */
    .hero-ad-top {
        max-width: 100%;
        overflow: hidden;
    }
}

/* ===== الشاشات الكبيرة (≥ 1100px) — Desktop Full ===== */
@media (min-width: 1100px) {
    /* إظهار الإعلانات الجانبية 300x250 */
    .hero-ad-side {
        display: flex;
        flex-direction: column;
        align-items: center;
        flex-shrink: 0;
        width: 300px;
        align-self: center;
    }

    /* تثبيت حجم مربع التحميل ليبقى واسعاً بين الإعلانين */
    .downloader-box {
        flex: 1 1 auto;
        min-width: 320px;
        max-width: 720px;
    }

    /* wrapper يحتوي الثلاثة بشكل أفقي */
    .downloader-wrapper {
        flex-direction: row;
        gap: 16px;
        max-width: 1200px;
        margin: 0 auto;
        padding: 0 16px;
        box-sizing: border-box;
    }
}

/* ===== تحسين الوصول ===== */
@media (prefers-reduced-motion: reduce) {
    * { animation: none !important; transition: none !important; scroll-behavior: auto; }
}

:focus-visible {
    outline: 3px solid var(--primary);
    outline-offset: 2px;
}

/* منع أي تمرير أفقي عام في الصفحة */
body, html {
    overflow-x: hidden;
    max-width: 100%;
}
