/* تي ماس — أساسيات التنسيق (Mobile-first, RTL) */

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    font-family: var(--font-family);
    background: var(--surface-alt);
    color: var(--ink);
    direction: rtl;
    line-height: 1.6;
    font-size: 15px;
    padding-bottom: calc(var(--bottom-nav-height) + env(safe-area-inset-bottom, 0));
    -webkit-font-smoothing: antialiased;
}

img { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; }

h1, h2, h3, h4 { margin: 0 0 8px; line-height: 1.3; }
p { margin: 0 0 12px; }

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 16px;
}

/* ---------- الشريط العلوي ---------- */
.app-header {
    position: sticky;
    top: 0;
    z-index: 40;
    height: var(--header-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    padding: 0 16px;
}

.app-header__logo { display: flex; align-items: center; gap: 8px; font-weight: 700; }
.app-header__logo img { height: 32px; width: auto; }
.app-header__actions { display: flex; align-items: center; gap: 14px; }
.icon-btn {
    width: 40px; height: 40px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    background: var(--surface-alt); border: 1px solid var(--line);
    cursor: pointer; transition: transform .12s ease;
}
.icon-btn:active { transform: scale(.9); }
.icon-btn__badge {
    position: absolute; top: -3px; left: -3px;
    background: var(--danger); color: #fff;
    font-size: 10px; font-weight: 800;
    min-width: 17px; height: 17px; border-radius: 999px;
    display: flex; align-items: center; justify-content: center;
    padding: 0 4px;
    border: 2px solid var(--surface);
}

/* ---------- شريط التنقل السفلي (جوال) ---------- */
.bottom-nav {
    position: fixed;
    bottom: 0; right: 0; left: 0;
    z-index: 50;
    display: flex;
    background: var(--surface);
    border-top: 1px solid var(--line);
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom, 0));
}

.bottom-nav__item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    padding: 6px 2px;
    color: var(--muted);
    font-size: 11px;
    border-radius: var(--radius-sm);
    transition: transform .12s ease, color .15s ease;
}
.bottom-nav__item.is-active { color: var(--brand-blue); }
.bottom-nav__item:active { transform: scale(.92); }
.bottom-nav__icon { width: 22px; height: 22px; }

@media (min-width: 900px) {
    .bottom-nav { display: none; }
    body { padding-bottom: 0; }
}

/* ---------- الأزرار ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 22px;
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: 14px;
    border: none;
    cursor: pointer;
    transition: transform .12s ease, opacity .15s ease;
    text-align: center;
}
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--brand-gradient); color: #fff; }
.btn-outline { background: transparent; color: var(--brand-blue); border: 1.5px solid var(--brand-blue); }
.btn-ghost { background: var(--surface-alt); color: var(--ink); }
.btn-block { width: 100%; }

/* ---------- البطاقات ---------- */
.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    padding: 16px;
    box-shadow: var(--shadow-sm);
}

/* ---------- Hero ---------- */
.hero {
    background-color: var(--brand-blue);
    background-repeat: no-repeat;
    background-position: center;
    background-size: cover;
    background-image: linear-gradient(180deg, rgba(9,45,110,.55), rgba(9,45,110,.82)), var(--hero-bg);
    color: #fff;
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
    padding: 40px 16px 56px;
    position: relative;
    overflow: hidden;
}
.hero::after {
    content: "";
    position: absolute;
    inset: 0;
    background-image: radial-gradient(circle at 20% 20%, rgba(255,255,255,.10) 0, transparent 40%),
                       radial-gradient(circle at 80% 60%, rgba(255,255,255,.08) 0, transparent 45%);
    pointer-events: none;
}
@media (min-width: 900px) {
    .hero {
        min-height: 460px;
        display: flex;
        align-items: center;
        background-image: linear-gradient(180deg, rgba(9,45,110,.55), rgba(9,45,110,.82)), var(--hero-bg-desktop);
    }
    .hero > .container { width: 100%; }
}
.hero h1 { font-size: 26px; margin-bottom: 10px; position: relative; }
.hero p { opacity: .92; font-size: 15px; position: relative; max-width: 480px; }
.hero__actions { display: flex; gap: 10px; margin-top: 18px; flex-wrap: wrap; position: relative; }

/* ---------- Skeleton loaders ---------- */
.skeleton {
    background: linear-gradient(90deg, var(--line) 25%, var(--surface-alt) 37%, var(--line) 63%);
    background-size: 400% 100%;
    animation: skeleton-loading 1.4s ease infinite;
    border-radius: var(--radius-sm);
}
@keyframes skeleton-loading {
    0% { background-position: 100% 50%; }
    100% { background-position: 0 50%; }
}

/* ---------- Toast ---------- */
.toast-container {
    position: fixed;
    top: calc(var(--header-height) + 10px);
    right: 16px; left: 16px;
    z-index: 100;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}
.toast {
    background: var(--ink);
    color: #fff;
    padding: 12px 16px;
    border-radius: var(--radius-md);
    font-size: 14px;
    box-shadow: var(--shadow-md);
    opacity: 0;
    transform: translateY(-8px);
    transition: opacity .2s ease, transform .2s ease;
}
.toast.is-visible { opacity: 1; transform: translateY(0); }
.toast.toast-success { background: var(--success); }
.toast.toast-error { background: var(--danger); }

/* ---------- حالات فارغة ---------- */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--muted);
}
.empty-state .icon { font-size: 40px; margin-bottom: 10px; }

/* ---------- شبكة عامة ---------- */
.grid { display: grid; gap: 14px; grid-template-columns: repeat(2, 1fr); }
@media (min-width: 640px) { .grid { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 1024px) { .grid { grid-template-columns: repeat(4, 1fr); } }

.text-muted { color: var(--muted); }
.mt-0 { margin-top: 0; }

/* ---------- النماذج ---------- */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.field .hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
.field .error-text { font-size: 12px; color: var(--danger); margin-top: 4px; }
.form-control {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    background: var(--surface);
    color: var(--ink);
    font-family: inherit;
    font-size: 14px;
}
.form-control:focus { outline: 2px solid var(--brand-teal); border-color: var(--brand-teal); }
textarea.form-control { min-height: 110px; resize: vertical; }
.field.has-error .form-control { border-color: var(--danger); }

.chip-group { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
    padding: 9px 16px;
    border-radius: 999px;
    border: 1.5px solid var(--line);
    background: var(--surface);
    font-size: 13px;
    cursor: pointer;
    color: var(--ink);
}
.chip.is-selected { background: var(--brand-gradient); border-color: transparent; color: #fff; }
.chip input { display: none; }

.alert { padding: 12px 16px; border-radius: var(--radius-md); font-size: 13px; margin-bottom: 14px; }
.alert-success { background: var(--success-bg); color: var(--success); }
.alert-error { background: var(--danger-bg); color: var(--danger); }

/* Bottom sheet */
.sheet-overlay {
    position: fixed; inset: 0; background: rgba(10,37,82,.4);
    z-index: 60; opacity: 0; pointer-events: none; transition: opacity .2s ease;
}
.sheet-overlay.is-open { opacity: 1; pointer-events: auto; }
.sheet {
    position: fixed; right: 0; left: 0; bottom: 0; z-index: 61;
    background: var(--surface);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    padding: 16px;
    transform: translateY(100%);
    transition: transform .25s ease;
    max-height: 85vh;
    overflow-y: auto;
}
.sheet.is-open { transform: translateY(0); }
.sheet__handle { width: 40px; height: 4px; background: var(--line); border-radius: 4px; margin: 0 auto 14px; }

/* ---------- قائمة المدير في الموقع ---------- */
.admin-menu { position: relative; }
.admin-menu > summary { list-style: none; cursor: pointer; color: var(--brand-teal); }
.admin-menu > summary::-webkit-details-marker { display: none; }
.admin-menu__panel {
    position: absolute; top: calc(100% + 8px); inset-inline-end: 0; z-index: 80; min-width: 210px;
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-md);
    box-shadow: 0 12px 32px rgba(10, 37, 82, .18); padding: 6px; display: flex; flex-direction: column;
}
.admin-menu__who { padding: 8px 12px; font-size: 12px; color: var(--muted); border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.admin-menu__panel a, .admin-menu__panel button {
    display: block; width: 100%; text-align: start; padding: 9px 12px; border: 0; background: none;
    font: inherit; font-size: 14px; color: var(--ink); border-radius: var(--radius-sm); cursor: pointer;
}
.admin-menu__panel a:hover, .admin-menu__panel button:hover { background: var(--surface-alt); }
.admin-menu__panel form { border-top: 1px solid var(--line); margin-top: 4px; padding-top: 4px; }
.admin-menu__panel button { color: var(--danger); }

/* ---------- عنوان البطل: ضوء ذكي متحرك ---------- */
.hero-title { display: flex; align-items: center; gap: 12px; }
.hero-title__text {
    background: linear-gradient(100deg, #fff 0%, #fff 35%, #7EE7E2 47%, #fff 55%, #fff 100%);
    background-size: 250% 100%;
    -webkit-background-clip: text; background-clip: text;
    -webkit-text-fill-color: transparent; color: transparent;
    filter: drop-shadow(0 0 14px rgba(126, 231, 226, .55));
    animation: hero-shine 4.5s ease-in-out infinite, hero-glow 3s ease-in-out infinite;
}
@keyframes hero-shine { 0% { background-position: 120% 0; } 60%, 100% { background-position: -60% 0; } }
@keyframes hero-glow {
    0%, 100% { filter: drop-shadow(0 0 8px rgba(126, 231, 226, .35)); }
    50% { filter: drop-shadow(0 0 20px rgba(126, 231, 226, .8)); }
}
/* بصمة إصبع مضيئة يمر عليها شعاع مسح، كقفل ذكي يتعرف على صاحبه */
.hero-title__fp {
    position: relative; flex: none; width: 34px; height: 34px; color: #7EE7E2; overflow: visible;
    filter: drop-shadow(0 0 6px rgba(126, 231, 226, .9));
    animation: hero-fp-glow 2.4s ease-in-out infinite;
}
.hero-title__fp svg { position: relative; width: 100%; height: 100%; display: block; }
.hero-title__fp::before { /* هالة موجية خلف البصمة */
    content: ""; position: absolute; inset: 15%; border-radius: 50%;
    border: 2px solid rgba(126, 231, 226, .7); animation: hero-ripple 2.4s ease-out infinite;
}
.hero-title__fp::after { /* شعاع المسح */
    content: ""; position: absolute; left: -4px; right: -4px; height: 3px; top: 0; border-radius: 3px;
    background: linear-gradient(90deg, transparent, #fff, transparent);
    box-shadow: 0 0 10px 2px rgba(126, 231, 226, .95);
    animation: hero-scan 2.4s ease-in-out infinite;
}
@keyframes hero-fp-glow {
    0%, 100% { filter: drop-shadow(0 0 4px rgba(126, 231, 226, .6)); opacity: .85; }
    50% { filter: drop-shadow(0 0 12px rgba(126, 231, 226, 1)); opacity: 1; }
}
@keyframes hero-scan { 0%, 100% { top: 4%; opacity: 0; } 15%, 85% { opacity: 1; } 50% { top: 92%; } }
@keyframes hero-ripple { 0% { transform: scale(.9); opacity: .8; } 100% { transform: scale(2.6); opacity: 0; } }
@media (min-width: 900px) { .hero-title { gap: 16px; } .hero-title__fp { width: 46px; height: 46px; } }
@media (prefers-reduced-motion: reduce) {
    .hero-title__text, .hero-title__fp { animation: none; }
    .hero-title__fp::before, .hero-title__fp::after { display: none; }
}
