/* ============================================================
   Design tokens
   لوحة الألوان مستوحاة من الهوية اليونانية (أزرق إيجة) ممزوجة
   بذهبي "الختم الرسمي" — بما يلائم موقع خدمات ومعاملات رسمية.
   ============================================================ */
:root {
    --bg: #F5F2EA;
    --surface: #FFFFFF;
    --surface-2: #FBF9F4;
    --ink: #16324A;
    --ink-soft: #4C6478;
    --line: #E4DECE;
    --primary: #0B5D8C;
    --primary-dark: #073B59;
    --primary-soft: #E6F0F6;
    --accent: #B98A2E;
    --accent-soft: #F5E9CC;
    --success: #2F7D5B;
    --success-soft: #E4F3EC;
    --danger: #C0432F;
    --danger-soft: #FBE7E2;
    --radius-lg: 18px;
    --radius-md: 12px;
    --radius-sm: 8px;
    --shadow-card: 0 2px 4px rgba(22,50,74,.06), 0 10px 24px rgba(22,50,74,.07);
    --shadow-card-hover: 0 6px 10px rgba(22,50,74,.08), 0 18px 34px rgba(22,50,74,.12);
    --font-display: 'Tajawal', system-ui, sans-serif;
    --font-mono: 'IBM Plex Mono', ui-monospace, monospace;
}

[data-theme="dark"] {
    --bg: #0F2130;
    --surface: #16324A;
    --surface-2: #132A3D;
    --ink: #F3EFE3;
    --ink-soft: #B8C7D3;
    --line: #24455F;
    --primary: #4FA3D1;
    --primary-dark: #7FC0E6;
    --primary-soft: #1B3E56;
    --accent: #E0B45C;
    --accent-soft: #2C3A28;
    --success: #5FCB9A;
    --success-soft: #16332A;
    --shadow-card: 0 2px 4px rgba(0,0,0,.25), 0 10px 24px rgba(0,0,0,.3);
    --shadow-card-hover: 0 6px 14px rgba(0,0,0,.3), 0 20px 40px rgba(0,0,0,.35);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
    margin: 0;
    font-family: var(--font-display);
    background: var(--bg);
    color: var(--ink);
    transition: background .25s ease, color .25s ease;
}
a { color: inherit; text-decoration: none; }
:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }
img { max-width: 100%; display: block; }
h1, h2, h3 { font-weight: 900; margin: 0 0 .5em; }

/* ---------- الترويسة ---------- */
.site-header {
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    position: sticky;
    top: 0;
    z-index: 30;
}
.site-header-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 14px 20px;
    display: flex;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
}
.site-brand {
    font-weight: 900;
    font-size: 1.15rem;
    color: var(--primary-dark);
    display: flex;
    align-items: center;
    gap: 10px;
    margin-inline-start: auto;
}
.site-brand-text { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.25; }
.site-brand-title { font-size: 1.05rem; }
.site-brand-subtitle { font-size: .72rem; font-weight: 700; color: var(--accent); }
.site-brand-seal {
    width: 38px; height: 38px;
    display: flex; align-items: center; justify-content: center;
    background: var(--primary-soft);
    border: 1.5px dashed var(--accent);
    border-radius: 50%;
    font-size: 1.1rem;
}
.search-wrap { flex: 1; min-width: 220px; max-width: 420px; }
#card-search {
    width: 100%;
    padding: 10px 16px;
    border-radius: 999px;
    border: 1.5px solid var(--line);
    background: var(--surface-2);
    color: var(--ink);
    font-family: inherit;
    font-size: .95rem;
}
#card-search:focus { border-color: var(--primary); }

/* ---------- شرائح تصفية الأقسام ---------- */
.filter-pills {
    max-width: 1200px;
    margin: 18px auto 0;
    padding: 0 20px;
    display: flex;
    gap: 10px;
    overflow-x: auto;
    scrollbar-width: none;
}
.filter-pills::-webkit-scrollbar { display: none; }
.pill {
    flex: 0 0 auto;
    padding: 9px 18px;
    border-radius: 999px;
    border: 1.5px solid var(--line);
    background: var(--surface);
    color: var(--ink-soft);
    font-family: inherit;
    font-weight: 700;
    font-size: .88rem;
    cursor: pointer;
    transition: all .15s ease;
}
.pill:hover { border-color: var(--primary); color: var(--primary); }
.pill.active { background: var(--primary); border-color: var(--primary); color: #fff; }

/* ---------- شبكة البطاقات ---------- */
.card-grid {
    max-width: 1200px;
    margin: 26px auto 60px;
    padding: 0 20px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 20px;
}
.card-tile {
    position: relative;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-card);
    transition: transform .18s ease, box-shadow .18s ease;
    display: flex;
    flex-direction: column;
}
.card-tile:hover { transform: translateY(-4px); box-shadow: var(--shadow-card-hover); }

.card-media { position: relative; aspect-ratio: 16/10; background: var(--primary-soft); overflow: hidden; }
.card-media img { width: 100%; height: 100%; object-fit: cover; }
.card-media-fallback { width:100%; height:100%; display:flex; align-items:center; justify-content:center; font-size:2.4rem; }
.section-tag {
    position: absolute;
    top: 10px; inset-inline-start: 10px;
    background: rgba(22,50,74,.78);
    color: #fff;
    font-size: .72rem;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 999px;
    backdrop-filter: blur(2px);
}

.card-body { padding: 16px 18px 18px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.verified-seal {
    align-self: flex-start;
    font-size: .72rem;
    font-weight: 700;
    color: var(--success);
    background: var(--success-soft);
    padding: 3px 9px;
    border-radius: 999px;
}
.card-title { font-size: 1.02rem; margin: 2px 0 0; }
.card-desc { font-size: .87rem; color: var(--ink-soft); margin: 0; line-height: 1.5; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card-cta {
    margin-top: auto;
    padding-top: 10px;
    font-weight: 800;
    font-size: .88rem;
    color: var(--primary);
}

/* الشارة "⭐ خدمة Premium" — عنصر مميّز أنيق أعلى البطاقة */
.premium-badge {
    position: absolute;
    top: 12px; inset-inline-start: 12px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: linear-gradient(135deg, var(--accent), #E9C876 60%, var(--accent));
    color: #3B2A08;
    font-size: .72rem;
    font-weight: 900;
    padding: 5px 12px;
    border-radius: 999px;
    box-shadow: 0 3px 8px rgba(185,138,46,.35);
    z-index: 3;
    letter-spacing: .2px;
}
.is-featured { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent), var(--shadow-card); }

/* الشارة "🕓 قيد التوثيق" وحالة البطاقة غير القابلة للنقر */
.pending-badge {
    position: absolute;
    top: 12px; inset-inline-end: 12px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: rgba(22,50,74,.85);
    color: #fff;
    font-size: .72rem;
    font-weight: 800;
    padding: 5px 12px;
    border-radius: 999px;
    z-index: 3;
}
.card-tile.is-pending {
    cursor: not-allowed;
    filter: grayscale(.35);
    opacity: .82;
}
.card-tile.is-pending:hover { transform: none; box-shadow: var(--shadow-card); }
.card-cta-disabled { color: var(--ink-soft) !important; }

/* ---------- بطاقة الإعلان ---------- */
.ad-tile {
    background: var(--surface-2);
    border: 1px dashed var(--line);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}
.ad-label {
    position: absolute;
    top: 10px; inset-inline-end: 10px;
    font-size: .68rem;
    font-weight: 700;
    color: var(--ink-soft);
    background: var(--surface);
    border: 1px solid var(--line);
    padding: 3px 9px;
    border-radius: 999px;
}

.empty-state-full { grid-column: 1/-1; text-align: center; padding: 60px 20px; color: var(--ink-soft); }

/* ---------- شريط الأخبار المتحرك ---------- */
.news-ticker {
    display: flex;
    flex-direction: row;
    align-items: center;
    width: 100%;
    box-sizing: border-box;
    background: var(--ticker-bg, #16324A);
    color: var(--ticker-fg, #fff);
    overflow: hidden;
    direction: rtl;
}
/* عند اختيار "اتجاه حركة النص: من اليسار لليمين" — تُقلَب التسمية الثابتة لتصبح على
   اليسار (بدل اليمين الافتراضي)، بحيث يبقى اختفاء النص دائماً تحت التسمية أياً كان
   اتجاه الحركة المختار، بدل اختفائه في الطرف البعيد عنها. */
.news-ticker.news-ticker-dir-ltr { flex-direction: row-reverse; }
.news-ticker-label {
    flex: 0 0 auto;
    font-weight: 900;
    font-size: .85rem;
    padding: 10px 16px;
    background: rgba(0,0,0,.15);
    white-space: nowrap;
}
.news-ticker-viewport {
    flex: 1 1 auto;
    overflow: hidden;
    position: relative;
    height: 100%;
    /* تلاشي تدريجي للنص عند طرفي الشريط (خاصة خلف كلمة التسمية الثابتة) بدل القطع
       المفاجئ — يعطي إحساس شريط أخبار حقيقي. mask-repeat/mask-size صريحان وإلزاميان
       هنا لأن بعض المتصفحات (خصوصاً أندرويد) تُكرّر التدرّج (tiling) بدل تمديده على
       كامل العرض إن تُركا على القيمة الافتراضية، مما يسبب اختفاء النص فجأة أثناء الحركة. */
    -webkit-mask-image: linear-gradient(to right, transparent 0, #000 48px, #000 calc(100% - 48px), transparent 100%);
            mask-image: linear-gradient(to right, transparent 0, #000 48px, #000 calc(100% - 48px), transparent 100%);
    -webkit-mask-repeat: no-repeat;
            mask-repeat: no-repeat;
    -webkit-mask-size: 100% 100%;
            mask-size: 100% 100%;
}
.news-ticker-track {
    display: flex;
    width: max-content;
    animation: news-ticker-scroll var(--ticker-speed, 30s) linear infinite;
    animation-direction: var(--ticker-anim-dir, normal);
}
.news-ticker:hover .news-ticker-track { animation-play-state: paused; }
.news-ticker-set {
    display: flex;
    align-items: center;
    white-space: nowrap;
    padding-inline-end: 24px;
}
.news-ticker-item {
    color: var(--ticker-fg, #fff);
    text-decoration: none;
    font-size: .88rem;
    font-weight: 700;
    padding: 10px 6px;
    white-space: nowrap;
}
.news-ticker-item:hover { text-decoration: underline; }
.news-ticker-sep { opacity: .5; padding: 0 10px; font-size: .7rem; }

/* الحركة: من اليمين إلى اليسار في RTL — المجموعة الثانية مكررة لضمان اتصال الحركة بلا فجوة */
@keyframes news-ticker-scroll {
    from { transform: translateX(0); }
    to   { transform: translateX(-50%); }
}
@media (prefers-reduced-motion: reduce) {
    .news-ticker-track { animation: none; }
}

/* عند اختيار «آخر الصفحة»: يبقى في تدفّق الصفحة الطبيعي على الكمبيوتر، لكنه
   يتحول لشريط ثابت عائم أسفل الشاشة على الهاتف لضمان رؤيته دون الحاجة للتمرير لآخر الصفحة. */
@media (max-width: 768px) {
    .news-ticker-pos-bottom {
        position: fixed;
        bottom: 0; left: 0; right: 0;
        z-index: 60;
        box-shadow: 0 -2px 10px rgba(0,0,0,.15);
    }
    body.has-bottom-ticker { padding-bottom: 46px; }
}
/* شريط كامل العرض أسفل الشاشة، وحاوية داخلية بعرض أقصى فقط — الارتفاع تلقائي
   بالكامل حسب حجم الإعلان الفعلي (لا يوجد قصّ أو تشويه للإعلان مهما كان حجمه). */
.sticky-popup-ad {
    position: fixed;
    bottom: 0;
    inset-inline-start: 0;
    inset-inline-end: 0;
    z-index: 50;
    background: var(--surface);
    box-shadow: 0 -2px 10px rgba(0,0,0,.12);
    opacity: 0;
    transform: translateY(100%);
    transition: opacity .3s ease, transform .3s ease;
}
.sticky-popup-ad.is-visible { opacity: 1; transform: translateY(0); }
.sticky-popup-inner {
    position: relative;
    width: 100%;
    max-width: var(--popup-max-w, 728px);
    margin: 0 auto;
    overflow: hidden;
    padding-top: 22px; /* مساحة لزر الإغلاق */
}
.sticky-popup-ad.pos-bottom-right .sticky-popup-inner { margin-inline-end: 16px; margin-inline-start: 0; }
.sticky-popup-ad.pos-bottom-left .sticky-popup-inner { margin-inline-start: 16px; margin-inline-end: 0; }
.sticky-popup-close {
    position: absolute;
    top: -2px; inset-inline-end: 4px;
    width: 24px; height: 24px;
    border-radius: 50%;
    border: none;
    background: var(--ink);
    color: #fff;
    font-size: 1rem;
    line-height: 1;
    cursor: pointer;
    z-index: 2;
}

/* ---------- الإعلان أعلى رأس الصفحة (وحدة خامسة) ---------- */
.top-page-ad {
    width: 100%;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
}
.top-page-ad-inner {
    position: relative;
    width: 100%;
    max-width: var(--top-ad-max-w, 970px);
    margin: 0 auto;
    overflow: hidden;
    padding: 6px 0;
    padding-inline-end: 32px;
}
.top-ad-close {
    position: absolute;
    top: 6px; inset-inline-end: 4px;
    width: 24px; height: 24px;
    border-radius: 50%;
    border: none;
    background: var(--ink);
    color: #fff;
    font-size: 1rem;
    line-height: 1;
    cursor: pointer;
    z-index: 2;
}

/* ---------- أزرار عامة ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 18px;
    border-radius: var(--radius-sm);
    border: 1.5px solid transparent;
    font-family: inherit;
    font-weight: 700;
    font-size: .9rem;
    cursor: pointer;
    text-decoration: none;
    transition: all .15s ease;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: var(--primary-soft); color: var(--primary-dark); }
.btn-secondary:hover { background: var(--accent-soft); }
.btn-ghost { background: transparent; border-color: var(--line); color: var(--ink); }
.btn-ghost:hover { border-color: var(--primary); color: var(--primary); }
.btn-danger { background: var(--danger-soft); color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-sm { padding: 6px 12px; font-size: .8rem; }
.btn-block { width: 100%; }

/* ---------- صفحة تسجيل الدخول ---------- */
.login-body {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(160deg, var(--primary-dark), var(--primary) 60%, var(--accent));
    padding: 20px;
}
.login-card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 40px 34px;
    width: 100%;
    max-width: 380px;
    text-align: center;
    box-shadow: var(--shadow-card-hover);
}
.login-seal {
    width: 60px; height: 60px;
    margin: 0 auto 14px;
    border-radius: 50%;
    border: 2px dashed var(--accent);
    background: var(--primary-soft);
    display: flex; align-items: center; justify-content: center;
    font-size: 1.6rem;
}
.login-sub { color: var(--ink-soft); font-size: .88rem; margin-top: -8px; margin-bottom: 22px; }
.login-form { display: flex; flex-direction: column; gap: 14px; text-align: start; }
.login-form label { display: flex; flex-direction: column; gap: 6px; font-size: .85rem; font-weight: 700; }
.login-form input {
    padding: 11px 14px;
    border-radius: var(--radius-sm);
    border: 1.5px solid var(--line);
    font-family: inherit;
    font-size: .95rem;
}
.login-form input:focus { border-color: var(--primary); }

.alert { padding: 10px 16px; border-radius: var(--radius-sm); font-size: .87rem; margin-bottom: 14px; }
.alert-error { background: var(--danger-soft); color: var(--danger); }
.alert-success { background: var(--success-soft); color: var(--success); }

/* ===== تذييل إحصائيات زيارات الموقع ===== */
.site-visit-stats {
    max-width: 1180px;
    margin: 42px auto 28px;
    padding: 0 20px;
}
.site-visit-stats-inner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 22px 34px;
    background: linear-gradient(135deg, var(--primary-soft), var(--accent-soft) 140%);
    border: 1.5px solid var(--line);
    border-radius: var(--radius-lg);
    padding: 18px 28px;
    box-shadow: var(--shadow-card);
}
.site-visit-stats-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 800;
    font-size: .92rem;
    color: var(--primary-dark);
    white-space: nowrap;
}
.site-visit-stats-icon {
    font-size: 1.15rem;
    line-height: 1;
}
.site-visit-stats-items {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 10px;
}
.site-visit-stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-width: 96px;
    padding: 8px 18px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
}
.site-visit-stat-value {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 700;
    font-size: 1.15rem;
    color: var(--primary);
}
.site-visit-stat-caption {
    font-size: .74rem;
    color: var(--ink-soft);
    margin-top: 2px;
}
@media (max-width: 560px) {
    .site-visit-stats-inner { padding: 16px 18px; gap: 14px 20px; }
    .site-visit-stat-item { min-width: 84px; padding: 7px 12px; }
}
