/* =========================================================
   مركز الرضا للرياضة والصحة — نظام التصميم
   Minimal SaaS: مساحة بيضاء، عناوين كبيرة، حقول بخط سفلي، أزرار بيضاوية
   ========================================================= */

:root {
    --brand: #35653f;
    --brand-600: #2b5333;
    --brand-50: #eef4ef;
    --gold: #ad803d;
    --gold-50: #f8f1e6;

    --ink: #111512;
    --ink-2: #3d4540;
    --muted: #7a837d;
    --line: #e7eae7;
    --line-2: #d4d9d5;
    --bg: #ffffff;
    --bg-soft: #f7f8f7;

    --ok: #2f7a45;
    --ok-50: #ecf6ef;
    --warn: #a86a12;
    --warn-50: #fdf4e4;
    --bad: #b4372f;
    --bad-50: #fcefed;
    --info: #3d5a73;
    --info-50: #eef3f7;

    --radius: 14px;
    --sidebar-w: 256px;
    --font: 'Tajawal', 'Segoe UI', Tahoma, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    font-family: var(--font);
    font-size: 16px;
    line-height: 1.6;
    color: var(--ink);
    background: var(--bg);
}
a { color: inherit; text-decoration: none; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; letter-spacing: -.01em; }
p { margin: 0; }
img { max-width: 100%; }
.icon { flex-shrink: 0; vertical-align: middle; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.nowrap { white-space: nowrap; }
.ltr { direction: ltr; unicode-bidi: embed; display: inline-block; }
.hidden { display: none !important; }

/* ---------- الهيكل ---------- */
.app { display: flex; min-height: 100vh; }

.sidebar {
    position: fixed; inset-block: 0; right: 0;
    width: var(--sidebar-w);
    background: var(--bg);
    border-left: 1px solid var(--line);
    display: flex; flex-direction: column;
    z-index: 40;
    transition: transform .25s ease;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 24px 22px 18px; }
.brand-mark {
    width: 40px; height: 40px; border-radius: 12px;
    display: grid; place-items: center;
    background: var(--brand); color: #fff;
}
.brand-text strong { display: block; font-size: 18px; font-weight: 800; }
.brand-text small { color: var(--gold); font-weight: 700; font-size: 13px; }

.nav { flex: 1; overflow-y: auto; padding: 6px 14px 16px; }
.nav-group { font-size: 12px; font-weight: 700; color: var(--muted); padding: 16px 10px 6px; letter-spacing: .02em; }
.nav-link {
    display: flex; align-items: center; gap: 12px;
    padding: 9px 12px; margin-bottom: 2px;
    border-radius: 999px;
    color: var(--ink-2); font-weight: 500; font-size: 15px;
    width: 100%; border: 0; background: none; font-family: inherit; cursor: pointer; text-align: right;
}
.nav-link:hover { background: var(--bg-soft); color: var(--ink); }
.nav-link.active { background: var(--brand-50); color: var(--brand); font-weight: 700; }
.nav-footer { padding: 12px 14px 20px; border-top: 1px solid var(--line); }
.nav-link.logout:hover { background: var(--bad-50); color: var(--bad); }

.main { flex: 1; margin-right: var(--sidebar-w); min-width: 0; display: flex; flex-direction: column; }
.topbar {
    display: flex; align-items: center; gap: 16px;
    padding: 26px 40px 18px;
    position: sticky; top: 0; z-index: 20;
    background: rgba(255,255,255,.92); backdrop-filter: blur(8px);
}
.topbar-title { flex: 1; min-width: 0; }
.topbar-title h1 { font-size: 30px; font-weight: 800; }
.topbar-title p { color: var(--muted); margin-top: 2px; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.icon-btn {
    position: relative; width: 42px; height: 42px; border-radius: 999px;
    display: grid; place-items: center; border: 1px solid var(--line); background: #fff; color: var(--ink-2); cursor: pointer;
}
.icon-btn:hover { border-color: var(--line-2); color: var(--ink); }
.dot-count {
    position: absolute; top: -4px; left: -4px; min-width: 20px; height: 20px; padding: 0 5px;
    border-radius: 999px; background: var(--bad); color: #fff; font-size: 11px; font-weight: 700;
    display: grid; place-items: center; border: 2px solid #fff;
}
.user-chip { display: flex; align-items: center; gap: 10px; padding: 4px 4px 4px 14px; border-radius: 999px; border: 1px solid var(--line); }
.user-chip:hover { border-color: var(--line-2); }
.avatar {
    width: 34px; height: 34px; border-radius: 999px; background: var(--gold-50); color: var(--gold);
    display: grid; place-items: center; font-weight: 800;
}
.user-chip-text { display: flex; flex-direction: column; line-height: 1.2; }
.user-chip-text strong { font-size: 14px; }
.user-chip-text small { font-size: 12px; color: var(--muted); }

.content { padding: 10px 40px 40px; flex: 1; width: 100%; max-width: 1360px; }
.app-footer { padding: 18px 40px 26px; color: var(--muted); font-size: 13px; }
.only-mobile { display: none; }
.sidebar-backdrop { display: none; }

/* ---------- عناوين الأقسام ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin: 6px 0 22px; }
.page-head h2 { font-size: 22px; font-weight: 800; }
.page-head p { color: var(--muted); margin-top: 4px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.section-title { font-size: 18px; font-weight: 800; margin-bottom: 4px; }
.section-sub { color: var(--muted); font-size: 14px; }

/* ---------- البطاقات ---------- */
.card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 22px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 20px 24px 0; }
.card-head h3 { font-size: 18px; font-weight: 800; }
.card-head p { color: var(--muted); font-size: 14px; }
.card-body { padding: 20px 24px 24px; }
.card-narrow { max-width: 760px; }

.grid { display: grid; gap: 22px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-main { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }

/* ---------- الإحصائيات ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-bottom: 26px; }
.stat { border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; background: #fff; }
.stat-label { color: var(--muted); font-size: 14px; display: flex; align-items: center; gap: 8px; }
.stat-value { font-size: 28px; font-weight: 800; margin-top: 6px; letter-spacing: -.02em; }
.stat-value small { font-size: 14px; font-weight: 500; color: var(--muted); }
.stat-note { font-size: 13px; color: var(--muted); margin-top: 2px; }
.stat.is-brand { background: var(--brand); border-color: var(--brand); color: #fff; }
.stat.is-brand .stat-label, .stat.is-brand .stat-note, .stat.is-brand small { color: rgba(255,255,255,.75); }
.tone-ok { color: var(--ok); } .tone-bad { color: var(--bad); } .tone-warn { color: var(--warn); } .tone-gold { color: var(--gold); }

@media (min-width: 1100px) { .stats-6 { grid-template-columns: repeat(6, minmax(0, 1fr)); } }
.stats-6 .stat { padding: 16px; min-width: 0; }
.stats-6 .stat-value { font-size: clamp(17px, 1.55vw, 24px); white-space: nowrap; }
.stats-6 .stat-value small { font-size: 12px; }
.stat-value { overflow-wrap: anywhere; }
.table tr.muted td, .table tr.muted td strong { color: var(--muted) !important; font-weight: 400; }

/* ---------- الأزرار (بيضاوية) ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    height: 44px; padding: 0 22px; border-radius: 999px;
    border: 1px solid transparent; font-family: inherit; font-size: 15px; font-weight: 700;
    cursor: pointer; white-space: nowrap; transition: background .15s, border-color .15s, color .15s, transform .05s;
    background: var(--bg-soft); color: var(--ink);
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-600); }
.btn-dark { background: var(--ink); color: #fff; }
.btn-dark:hover { background: #2a302c; }
.btn-gold { background: var(--gold); color: #fff; }
.btn-gold:hover { background: #976e33; }
.btn-light, .btn-ghost { background: #fff; border-color: var(--line-2); color: var(--ink); }
.btn-light:hover, .btn-ghost:hover { border-color: var(--ink-2); }
.btn-danger { background: var(--bad-50); color: var(--bad); }
.btn-danger:hover { background: var(--bad); color: #fff; }
.btn-sm { height: 34px; padding: 0 14px; font-size: 13px; gap: 6px; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .5; pointer-events: none; }
.link { color: var(--brand); font-weight: 700; }
.link:hover { text-decoration: underline; }

/* ---------- النماذج (حقول بخط سفلي) ---------- */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 22px 28px; }
.form-grid .span-2 { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field > label, .label { font-size: 13px; font-weight: 700; color: var(--ink-2); }
.field .hint { font-size: 12.5px; color: var(--muted); }
.req::after { content: ' *'; color: var(--bad); }

.input, .field input:not([type=checkbox]):not([type=radio]):not([type=file]), .field select, .field textarea {
    width: 100%;
    font-family: inherit; font-size: 16px; color: var(--ink);
    padding: 10px 2px 9px;
    border: 0; border-bottom: 1.5px solid var(--line-2); border-radius: 0;
    background: transparent; outline: none;
    transition: border-color .15s;
}
.field textarea { resize: vertical; min-height: 84px; line-height: 1.7; }
.field select { appearance: none; -webkit-appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%237a837d' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-position: left 4px center; background-repeat: no-repeat; padding-left: 24px; cursor: pointer; }
.input:focus, .field input:focus, .field select:focus, .field textarea:focus { border-bottom-color: var(--brand); }
.field input::placeholder, .field textarea::placeholder { color: #a9b0ab; }
.field.has-error input, .field.has-error select { border-bottom-color: var(--bad); }
.field input[type=file] { font-family: inherit; font-size: 14px; padding: 8px 0; }
.form-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 30px; }
.form-section { font-size: 15px; font-weight: 800; color: var(--brand); margin: 34px 0 16px; display: flex; align-items: center; gap: 8px; }
.form-section:first-child { margin-top: 0; }
.input-suffix { position: relative; }
.input-suffix span { position: absolute; left: 2px; bottom: 10px; color: var(--muted); font-size: 14px; }

/* اختيار بأزرار بيضاوية */
.segmented { display: flex; flex-wrap: wrap; gap: 8px; padding-top: 6px; }
.segmented label { cursor: pointer; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented span {
    display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 16px;
    border-radius: 999px; border: 1px solid var(--line-2); font-size: 14px; font-weight: 500; color: var(--ink-2);
}
.segmented input:checked + span { background: var(--ink); border-color: var(--ink); color: #fff; }
.segmented input:focus-visible + span { outline: 2px solid var(--brand); outline-offset: 2px; }
.seg-present input:checked + span { background: var(--ok); border-color: var(--ok); }
.seg-late input:checked + span { background: var(--warn); border-color: var(--warn); }
.seg-absent input:checked + span { background: var(--bad); border-color: var(--bad); }
.seg-excused input:checked + span { background: var(--info); border-color: var(--info); }

.check { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-weight: 500; }
.check input { width: 18px; height: 18px; accent-color: var(--brand); }

/* شريط الفلاتر */
.filters { display: flex; flex-wrap: wrap; gap: 14px 18px; align-items: flex-end; margin-bottom: 18px; }
.filters .field { min-width: 150px; }
.filters .field.grow { flex: 1; min-width: 220px; }

/* ---------- الجداول ---------- */
.table-wrap { overflow-x: auto; margin: 0 -24px; padding: 0 24px; }
.table { width: 100%; border-collapse: collapse; font-size: 15px; }
.table th { text-align: right; font-size: 13px; font-weight: 700; color: var(--muted); padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 14px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: #fbfcfb; }
.table .num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.table .row-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.table tfoot td { font-weight: 800; border-top: 1.5px solid var(--ink); }
.cell-title { font-weight: 700; display: block; }
.cell-sub { color: var(--muted); font-size: 13px; display: block; }
.empty { text-align: center; color: var(--muted); padding: 40px 10px !important; }
.money-paid { color: var(--ok); font-weight: 700; }
.money-debt { color: var(--bad); font-weight: 700; }
.row-void td { color: var(--muted); text-decoration: line-through; }

/* ---------- الشارات ---------- */
.badge { display: inline-flex; align-items: center; height: 26px; padding: 0 12px; border-radius: 999px; font-size: 12.5px; font-weight: 700; white-space: nowrap; background: var(--bg-soft); color: var(--ink-2); }
.badge-active, .badge-sent, .badge-present, .badge-ok { background: var(--ok-50); color: var(--ok); }
.badge-soon, .badge-late, .badge-pending, .badge-upcoming { background: var(--warn-50); color: var(--warn); }
.badge-expired, .badge-failed, .badge-absent, .badge-cancelled, .badge-bad { background: var(--bad-50); color: var(--bad); }
.badge-frozen, .badge-excused, .badge-info { background: var(--info-50); color: var(--info); }
.badge-gold { background: var(--gold-50); color: var(--gold); }
.badge-skipped, .badge-inactive { background: var(--bg-soft); color: var(--muted); }

/* ---------- التنبيهات ---------- */
.alert { display: flex; gap: 10px; align-items: flex-start; padding: 14px 18px; border-radius: 12px; margin-bottom: 18px; font-weight: 500; }
.alert .icon { margin-top: 3px; }
.alert-success { background: var(--ok-50); color: var(--ok); }
.alert-error { background: var(--bad-50); color: var(--bad); }
.alert-warning { background: var(--warn-50); color: var(--warn); }
.alert-info { background: var(--info-50); color: var(--info); }

/* ---------- قائمة مفتاح/قيمة ---------- */
.kv { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 18px 24px; }
.kv div span { display: block; font-size: 13px; color: var(--muted); }
.kv div strong { display: block; font-size: 16px; margin-top: 2px; word-break: break-word; }

.profile-head { display: flex; align-items: center; gap: 18px; margin-bottom: 24px; flex-wrap: wrap; }
.profile-photo { width: 84px; height: 84px; border-radius: 999px; object-fit: cover; background: var(--brand-50); color: var(--brand); display: grid; place-items: center; font-size: 32px; font-weight: 800; flex-shrink: 0; }
.profile-head h2 { font-size: 26px; font-weight: 800; }

/* ---------- قائمة بسيطة ---------- */
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.list li:last-child { border-bottom: 0; }

/* ---------- رسم بياني بسيط ---------- */
.bars { display: flex; align-items: flex-end; gap: 14px; height: 200px; padding-top: 10px; }
.bar { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 8px; height: 100%; }
.bar-fill { width: 100%; max-width: 46px; background: var(--brand-50); border-radius: 10px 10px 4px 4px; min-height: 4px; position: relative; }
.bar.current .bar-fill { background: var(--brand); }
.bar-val { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.bar-label { font-size: 13px; color: var(--ink-2); }

/* ---------- ترقيم ---------- */
.pagination { display: flex; gap: 6px; align-items: center; margin-top: 18px; flex-wrap: wrap; }
.pagination a { min-width: 36px; height: 36px; border-radius: 999px; display: grid; place-items: center; border: 1px solid var(--line); font-weight: 700; font-size: 14px; }
.pagination a.active { background: var(--ink); color: #fff; border-color: var(--ink); }
.pagination .muted { margin-right: 8px; font-size: 13px; }

/* ---------- تبويبات ---------- */
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 20px; }
.tabs a { height: 36px; padding: 0 16px; border-radius: 999px; display: inline-flex; align-items: center; gap: 6px; font-weight: 700; font-size: 14px; color: var(--ink-2); border: 1px solid var(--line); }
.tabs a.active { background: var(--ink); color: #fff; border-color: var(--ink); }
.tabs a .count { font-size: 12px; opacity: .7; }

/* ---------- الرسائل ---------- */
.sms-preview { background: var(--bg-soft); border-radius: 18px 18px 4px 18px; padding: 14px 18px; white-space: pre-wrap; line-height: 1.8; }
.code-box { background: var(--bg-soft); border: 1px dashed var(--line-2); border-radius: 12px; padding: 12px 14px; font-size: 14px; white-space: pre-wrap; word-break: break-word; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; height: 30px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--line-2); font-size: 13px; cursor: pointer; background: #fff; font-family: inherit; color: var(--ink-2); }
.chip:hover { border-color: var(--brand); color: var(--brand); }
.search-results { border: 1px solid var(--line); border-radius: 12px; margin-top: 8px; max-height: 280px; overflow-y: auto; }
.search-results button { display: flex; width: 100%; justify-content: space-between; gap: 10px; padding: 10px 14px; border: 0; border-bottom: 1px solid var(--line); background: #fff; font-family: inherit; font-size: 15px; cursor: pointer; text-align: right; }
.search-results button:hover { background: var(--brand-50); }
.selected-person { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 16px; border-radius: 12px; background: var(--brand-50); margin-top: 10px; }

/* ---------- صفحة الدخول (Minimal SaaS Auth) ---------- */
.auth-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 40px 22px; background: #fff; }
.auth { width: 100%; max-width: 400px; }
.auth-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 56px; }
.auth h1 { font-size: 38px; font-weight: 800; letter-spacing: -.02em; margin-bottom: 10px; }
.auth .lead { color: var(--muted); font-size: 17px; margin-bottom: 40px; }
.auth .field { margin-bottom: 28px; }
.auth .field input { font-size: 17px; padding: 12px 2px; }
.auth .btn { height: 52px; font-size: 16px; margin-top: 8px; }
.auth-foot { margin-top: 40px; color: var(--muted); font-size: 13px; text-align: center; }
.password-wrap { position: relative; }
.password-wrap input { padding-left: 40px !important; }
.password-toggle { position: absolute; left: 0; bottom: 8px; border: 0; background: none; color: var(--muted); cursor: pointer; padding: 4px; }
.password-toggle:hover { color: var(--ink); }

/* ---------- الطباعة ---------- */
.print-only { display: none !important; }
.print-sheet { background: #fff; }
.print-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; padding-bottom: 16px; border-bottom: 2px solid var(--ink); margin-bottom: 20px; }
.print-header h2 { font-size: 22px; font-weight: 800; }
.print-header .en { font-size: 11px; letter-spacing: .14em; color: var(--gold); font-weight: 700; }
.signatures { display: grid; grid-template-columns: 1fr 1fr; gap: 40px; margin-top: 50px; }
.signatures div { border-top: 1px solid var(--ink-2); padding-top: 8px; text-align: center; font-size: 14px; color: var(--ink-2); }

@media print {
    @page { size: A4; margin: 14mm; }
    body { font-size: 13px; }
    .sidebar, .topbar, .app-footer, .no-print, .sidebar-backdrop, .alert { display: none !important; }
    .main { margin: 0 !important; }
    .content { padding: 0 !important; max-width: none; }
    .print-only { display: block !important; }
    .print-header.print-only { display: flex !important; }
    .signatures.print-only { display: grid !important; }
    .card { border: 0; margin: 0 0 14px; break-inside: avoid; }
    .card-head, .card-body { padding-inline: 0; }
    .stats { grid-template-columns: repeat(4, 1fr); gap: 8px; }
    .stats-6 { grid-template-columns: repeat(6, 1fr); }
    .stat { padding: 10px 12px; break-inside: avoid; }
    .stat-value { font-size: 18px; }
    .stat.is-brand { background: #fff !important; color: var(--ink) !important; border: 2px solid var(--ink); }
    .stat.is-brand .stat-label, .stat.is-brand .stat-note { color: var(--muted) !important; }
    .table { font-size: 12px; }
    .table td, .table th { padding: 7px 8px; }
    .table-wrap { margin: 0; padding: 0; overflow: visible; }
    a { text-decoration: none; }
}

/* ---------- الشاشات الصغيرة ---------- */
@media (max-width: 1100px) {
    .grid-main, .grid-3 { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
    .sidebar { transform: translateX(100%); box-shadow: none; }
    body.sidebar-open .sidebar { transform: none; box-shadow: -20px 0 60px rgba(0,0,0,.12); }
    body.sidebar-open .sidebar-backdrop { display: block; position: fixed; inset: 0; background: rgba(17,21,18,.3); z-index: 30; }
    .main { margin-right: 0; }
    .only-mobile { display: grid; }
    .topbar { padding: 18px 16px 12px; }
    .topbar-title h1 { font-size: 22px; }
    .topbar-title p { display: none; }
    .user-chip-text { display: none; }
    .user-chip { padding: 4px; }
    .content { padding: 6px 16px 30px; }
    .app-footer { padding: 16px; }
    .grid-2, .form-grid { grid-template-columns: 1fr; }
    .card-head { padding: 16px 16px 0; }
    .card-body { padding: 16px; }
    .table-wrap { margin: 0 -16px; padding: 0 16px; }
    .table-wrap .table { min-width: 680px; }
    .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .stat-value { font-size: 22px; }
    .auth h1 { font-size: 32px; }
}

