@import url('https://fonts.googleapis.com/css2?family=Tajawal:wght@400;500;700&family=JetBrains+Mono:wght@400;500;600&display=swap');

:root {
    /* الألوان مستخرجة من شعار إشراق طيبة الفعلي */
    --navy: #052951;
    --navy-light: #0d3a70;
    --gold: #b8860b;      /* نص/أرقام — نسخة أعمق من أصفر الشمس تصلح للقراءة على خلفية فاتحة */
    --gold-bright: #f0c419; /* خلفيات/تمييز صغير فقط — أصفر الشمس الفعلي */
    --green: #4c8a2e;     /* أخضر مطابق لكلمتي TAYBA / TURIZM بالشعار */
    --danger: #c0392b;
    --info: #2563eb;

    --bg: #f3f5f8;
    --surface: #ffffff;
    --surface-2: #edf1f5;
    --border: #e1e6ec;
    --text: #16212e;
    --text-muted: #64748b;
    --radius: 10px;
    --font-ar: 'Tajawal', 'Segoe UI', sans-serif;
    --font-mono: 'JetBrains Mono', 'Consolas', monospace;
}

* { box-sizing: border-box; }

body {
    font-family: var(--font-ar);
    direction: rtl;
    background: var(--bg);
    color: var(--text);
    margin: 0;
    -webkit-font-smoothing: antialiased;
}

.container { max-width: 1080px; margin: 0 auto; padding: 28px 24px 60px; }

/* ---------- Navbar (كحلي مطابق لخلفية الشعار تماماً) ---------- */
.navbar { background: var(--navy); border-bottom: 1px solid var(--navy-light); position: relative; }
.navbar::after { content: ''; position: absolute; bottom: -1px; left: 0; right: 0; height: 2px; background: linear-gradient(90deg, transparent, var(--gold-bright) 50%, transparent); opacity: .8; }
.navbar-inner { max-width: 1080px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; padding: 10px 24px; }
.navbar-brand { display: flex; align-items: center; gap: 12px; text-decoration: none; }
.navbar-brand img { height: 42px; display: block; border-radius: 6px; }
.navbar-brand .brand-text { font-family: var(--font-ar); font-size: 13px; font-weight: 500; color: #d7e2f0; border-right: 1px solid rgba(255,255,255,.2); padding-right: 12px; }
.navbar-links { display: flex; gap: 4px; }
.navbar-links a { color: #b9c8dc; text-decoration: none; padding: 9px 15px; border-radius: 8px; font-size: 14px; transition: background .15s, color .15s; }
.navbar-links a:hover { background: rgba(255,255,255,.08); color: #fff; }
.navbar-links a.active { background: rgba(255,255,255,.12); color: var(--gold-bright); font-weight: 500; }

/* ---------- Layout building blocks ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; margin-bottom: 20px; box-shadow: 0 1px 3px rgba(16,24,40,.07), 0 1px 2px rgba(16,24,40,.04); overflow-x: auto; }
.top-actions { display: flex; justify-content: space-between; align-items: center; margin: 24px 0 16px; flex-wrap: wrap; gap: 10px; }
h1 { font-size: 19px; font-weight: 700; margin: 0; color: var(--navy); }
h2 { font-size: 15px; font-weight: 700; margin: 0 0 14px; color: var(--navy); }
p { color: var(--text-muted); }
a { color: inherit; }

/* ---------- Stat row ---------- */
.stat-row { display: flex; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; margin-bottom: 20px; background: var(--surface); box-shadow: 0 1px 3px rgba(16,24,40,.07), 0 1px 2px rgba(16,24,40,.04); }
.stat { flex: 1; padding: 16px 20px; border-left: 1px solid var(--border); }
.stat:last-child { border-left: none; }
.stat-label { font-size: 12px; color: var(--text-muted); margin-bottom: 6px; }
.stat-value { font-family: var(--font-mono); font-size: 24px; font-weight: 600; direction: ltr; unicode-bidi: embed; color: var(--navy); }
.stat-value.accent { color: var(--gold); }
.stat-value.positive { color: var(--green); }

/* ---------- Table (ledger register) ---------- */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: right; font-size: 12px; font-weight: 600; color: var(--text-muted); padding: 10px 12px; border-bottom: 1px solid var(--border); }
td { padding: 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--surface-2); }
.mono, .amount, .plate, .date-val { font-family: var(--font-mono); direction: ltr; unicode-bidi: embed; text-align: right; }
.plate { font-weight: 600; color: var(--navy); }
.owner-name { color: var(--text-muted); font-size: 12.5px; display: block; margin-top: 2px; }

/* ---------- Pills (status) ---------- */
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 4px 11px; border-radius: 100px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.pill::before { content: ''; width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }
.pill-success { background: rgba(76, 138, 46, .1); color: var(--green); }
.pill-success::before { background: var(--green); }
.pill-danger { background: rgba(192, 57, 43, .1); color: var(--danger); }
.pill-danger::before { background: var(--danger); }
.pill-info { background: rgba(37, 99, 235, .1); color: var(--info); }
.pill-info::before { background: var(--info); }
.pill-muted { background: var(--surface-2); color: var(--text-muted); }
.pill-muted::before { background: var(--text-muted); }

/* ---------- Buttons ---------- */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 15px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font-size: 13px; font-family: inherit; cursor: pointer; text-decoration: none; transition: border-color .15s, background .15s; }
.btn:hover { border-color: var(--navy); }
.btn-primary { background: var(--navy); border-color: var(--navy); color: #fff; font-weight: 600; }
.btn-primary:hover { background: var(--navy-light); border-color: var(--navy-light); }
.btn-danger { background: transparent; color: var(--danger); border-color: rgba(192, 57, 43, .3); }
.btn-danger:hover { background: rgba(192, 57, 43, .06); border-color: var(--danger); }
.btn-sm { padding: 5px 11px; font-size: 12px; }

/* ---------- Forms ---------- */
label { display: block; font-size: 12.5px; color: var(--text-muted); margin-bottom: 6px; }
input[type=text], input[type=number], input[type=date], input[type=month], select {
    width: 100%; padding: 9px 11px; border: 1px solid var(--border); border-radius: 8px;
    background: var(--surface); color: var(--text); font-family: var(--font-ar); font-size: 14px;
}
input[type=number], input[type=date], input[type=month] { font-family: var(--font-mono); direction: ltr; text-align: left; }
input:focus, select:focus { outline: none; border-color: var(--navy); box-shadow: 0 0 0 3px rgba(5,41,81,.08); }
input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--navy); }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 14px; }
.section { border-top: 1px solid var(--border); padding-top: 16px; margin-top: 16px; }
.checkline { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.sub-box { margin-right: 24px; background: var(--surface-2); border-radius: 8px; padding: 12px 14px; }

/* ---------- Collection register rows ---------- */
.collect-row { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; padding: 14px 4px; border-bottom: 1px solid var(--border); }
.collect-row:last-child { border-bottom: none; }
.collect-who { flex: 1; min-width: 170px; }
.collect-form { display: flex; align-items: flex-end; gap: 8px; flex-wrap: wrap; }
.collect-form .field { width: 110px; }
.collect-form .field.date { width: 145px; }
/* ---------- Unified collection table ---------- */
.collect-table { min-width: 680px; }
.collect-table th, .collect-table td { vertical-align: middle; padding: 8px 12px; }
.collect-table tbody tr:not(.history-row):hover { background: var(--surface-2); }
.collect-cell { display: flex; align-items: center; gap: 8px; }
.collect-mini-form { display: flex; align-items: center; gap: 6px; }
.collect-mini-form input[type=number] { width: 75px; padding: 6px 8px; font-size: 13px; }
.shared-date { width: 125px; padding: 6px 8px; font-size: 13px; }
.history-row td { background: var(--surface-2); padding: 14px 16px; border-bottom: 1px solid var(--border); }
.history-box-wrap table { background: var(--surface); border-radius: 8px; overflow: hidden; }
.history-box-wrap th, .history-box-wrap td { padding: 8px 10px; font-size: 13px; }

/* ---------- Active/Inactive toggle switch ---------- */
.status-toggle-row { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.toggle-switch { position: relative; display: inline-block; width: 46px; height: 26px; flex-shrink: 0; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-switch .slider { position: absolute; inset: 0; background: #cbd2db; border-radius: 26px; cursor: pointer; transition: background .2s; }
.toggle-switch .slider::before { content: ''; position: absolute; height: 20px; width: 20px; right: 3px; bottom: 3px; background: #fff; border-radius: 50%; transition: transform .2s; box-shadow: 0 1px 2px rgba(0,0,0,.25); }
.toggle-switch input:checked + .slider { background: var(--green); }
.toggle-switch input:checked + .slider::before { transform: translateX(-20px); }
.toggle-switch input:focus-visible + .slider { outline: 2px solid var(--navy); outline-offset: 2px; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 18px; }
.tabs a { padding: 10px 16px; color: var(--text-muted); text-decoration: none; font-size: 14px; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a.active { color: var(--navy); font-weight: 600; border-bottom-color: var(--gold-bright); }

/* ---------- History disclosure ---------- */
details.history summary { cursor: pointer; font-size: 12.5px; color: var(--text-muted); list-style: none; display: inline-flex; align-items: center; gap: 5px; user-select: none; }
details.history summary::-webkit-details-marker { display: none; }
details.history summary::before { content: '›'; display: inline-block; transition: transform .15s; }
details.history[open] summary::before { transform: rotate(90deg); }
details.history[open] summary { color: var(--navy); font-weight: 600; }
details.history .history-box { margin-top: 10px; background: var(--surface-2); border-radius: 8px; padding: 4px 10px; }

/* ---------- Notes ---------- */
.note-item { display: flex; justify-content: space-between; align-items: flex-start; background: var(--surface-2); border-radius: 8px; padding: 12px 14px; margin-bottom: 8px; }
.note-meta { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

/* ---------- Alerts ---------- */
.msg-ok { background: rgba(76, 138, 46, .08); border: 1px solid rgba(76, 138, 46, .3); color: var(--green); padding: 11px 15px; border-radius: 8px; margin-bottom: 18px; font-size: 13px; animation: fadeInDown .35s ease; }
.msg-error-box { background: rgba(192, 57, 43, .06); border: 1px solid rgba(192, 57, 43, .25); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 20px; animation: fadeInDown .35s ease; }

@keyframes fadeInDown {
    from { opacity: 0; transform: translateY(-6px); }
    to { opacity: 1; transform: translateY(0); }
}
.field-error { color: var(--danger); font-size: 13px; margin-bottom: 4px; }
.empty-state { color: var(--text-muted); font-size: 13.5px; padding: 8px 0; }

@media print {
    .no-print { display: none !important; }
    body { background: #fff; color: #000; }
    .card { border: none; box-shadow: none; }
}

/* عرض أعمدة جدول التحصيل — يُطبَّق فقط بعرض الشاشة العادي، ويُلغى تلقائياً عند تحويل الجدول لبطاقات بالموبايل */
.collect-table th:nth-child(2) { width: 130px; }
.collect-table th:nth-child(3) { width: 260px; }
.collect-table th:nth-child(4) { width: 260px; }
.collect-table th:nth-child(5) { width: 90px; }

@media (max-width: 700px) {
    .container { padding: 16px 12px 40px; }
    h1 { font-size: 17px; }

    .navbar-inner { flex-direction: column; align-items: stretch; gap: 8px; padding: 10px 14px; }
    .navbar-brand { justify-content: center; }
    .navbar-brand .brand-text { display: none; }
    .navbar-links { justify-content: center; gap: 2px; flex-wrap: wrap; }
    .navbar-links a { padding: 7px 10px; font-size: 13px; white-space: nowrap; }

    .row, .stat-row { flex-direction: column; }
    .stat { border-left: none; border-bottom: 1px solid var(--border); }
    .stat:last-child { border-bottom: none; }
    .stat-value { font-size: 20px; }

    .card { padding: 12px; overflow-x: visible; }
    .top-actions { align-items: flex-start; }

    #collect-search, #dashboard-search { max-width: none !important; width: 100%; }

    .sub-box { margin-right: 0; }

    /* ---- أي جدول عادي (بيانات نصية بسيطة) يتحوّل لبطاقات مكدّسة عمودياً ---- */
    table.responsive-table { min-width: 0; width: 100%; }
    table.responsive-table thead { display: none; }
    table.responsive-table, table.responsive-table tbody, table.responsive-table tr, table.responsive-table td {
        display: block; width: 100%;
    }
    table.responsive-table tr {
        border: 1px solid var(--border); border-radius: 10px; padding: 2px 12px; margin-bottom: 10px; background: var(--surface);
    }
    table.responsive-table td {
        border: none; border-bottom: 1px solid var(--border); padding: 9px 0;
        display: flex; justify-content: space-between; align-items: center; gap: 10px; text-align: left;
    }
    table.responsive-table td:last-child { border-bottom: none; }
    table.responsive-table td[data-label]::before {
        content: attr(data-label); font-weight: 600; color: var(--text-muted); font-size: 12px; flex-shrink: 0;
    }
    table.responsive-table td[data-label=""]::before { content: none; }

    /* ---- جدول التحصيل الكثيف: كل سيارة تصير بطاقة مستقلة، بدون أي عرض ثابت بالبكسل ---- */
    table.collect-table { min-width: 0; width: 100%; }
    table.collect-table thead { display: none; }
    table.collect-table, table.collect-table tbody { display: block; width: 100%; }
    table.collect-table tr.car-row {
        display: block; border: 1px solid var(--border); border-radius: 10px; padding: 12px; margin-bottom: 10px; background: var(--surface);
    }
    table.collect-table tr.car-row td {
        display: block; width: auto; border: none; padding: 7px 0;
    }
    table.collect-table tr.car-row td[data-label]:not([data-label=""])::before {
        content: attr(data-label); display: block; font-size: 11.5px; font-weight: 600; color: var(--text-muted); margin-bottom: 4px;
    }
    table.collect-table tr.car-row td:first-child {
        padding-bottom: 10px; border-bottom: 1px solid var(--border); margin-bottom: 4px;
    }
    table.collect-table tr.history-row { display: block; width: 100%; }
    table.collect-table tr.history-row td { display: block; width: 100%; padding: 0; }

    .collect-cell { flex-direction: column; align-items: flex-start; gap: 6px; width: 100%; }
    .collect-mini-form { flex-wrap: wrap; width: 100%; }
    .collect-mini-form input[type=number] { width: 100px; }
    .shared-date { width: 100%; }
}
