/* ==========================================================
   حسابات أبو جمال — نظام التصميم
   ========================================================== */

:root {
    --brand:        #123C34;
    --brand-dark:   #0D2C26;
    --brand-light:  #1B5348;
    --brand-soft:   #E8F0ED;
    --gold:         #E2A954;
    --gold-soft:    #FDF4E6;
    --bg:           #F4F6F5;
    --card:         #FFFFFF;
    --text:         #1F2A28;
    --muted:        #7A8783;
    --line:         #E7EBEA;
    --green:        #1E9E6A;
    --amber:        #D98E1F;
    --red:          #D0453B;
    --radius:       16px;
    --radius-sm:    10px;
    --shadow:       0 1px 2px rgba(18,60,52,.04), 0 8px 24px rgba(18,60,52,.06);
    --shadow-sm:    0 1px 3px rgba(18,60,52,.07);
    --sidebar-w:    262px;
}

* { -webkit-tap-highlight-color: transparent; }

html, body { height: 100%; }

body {
    font-family: 'Cairo', 'Segoe UI', Tahoma, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14.5px;
    margin: 0;
}

a { text-decoration: none; }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: #cdd6d3; border-radius: 8px; }
::-webkit-scrollbar-track { background: transparent; }

/* ================= الشريط الجانبي ================= */
.sidebar {
    position: fixed;
    top: 0; right: 0; bottom: 0;
    width: var(--sidebar-w);
    background: linear-gradient(180deg, var(--brand) 0%, var(--brand-dark) 100%);
    color: #DCE7E3;
    display: flex;
    flex-direction: column;
    z-index: 1045;
    transition: transform .28s ease;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 20px 18px 16px;
    border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar-brand .logo-box {
    width: 42px; height: 42px;
    background: #fff;
    border-radius: 12px;
    display: grid; place-items: center;
    overflow: hidden;
    flex: 0 0 auto;
    padding: 4px;
}
.sidebar-brand .logo-box img { max-width: 100%; max-height: 100%; }
.sidebar-brand .t1 { color: #fff; font-weight: 700; font-size: 15px; line-height: 1.2; }
.sidebar-brand .t2 { color: var(--gold); font-size: 11px; letter-spacing: .3px; }

.sidebar-nav {
    padding: 12px 10px 20px;
    overflow-y: auto;
    flex: 1;
}
.nav-section {
    font-size: 10.5px;
    color: rgba(255,255,255,.4);
    padding: 14px 10px 6px;
    letter-spacing: .6px;
    font-weight: 600;
}
.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 10px 12px;
    border-radius: 11px;
    color: #C9D8D3;
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 3px;
    transition: all .16s ease;
}
.sidebar-nav a i { width: 19px; text-align: center; font-size: 14.5px; opacity: .85; }
.sidebar-nav a:hover { background: rgba(255,255,255,.07); color: #fff; }
.sidebar-nav a.active {
    background: rgba(226,169,84,.16);
    color: #fff;
    box-shadow: inset 3px 0 0 var(--gold);
}
.sidebar-nav a.active i { color: var(--gold); opacity: 1; }

.sidebar-foot {
    padding: 12px 14px 16px;
    border-top: 1px solid rgba(255,255,255,.08);
    font-size: 11px;
    color: rgba(255,255,255,.42);
    text-align: center;
}

.sidebar-backdrop {
    position: fixed; inset: 0;
    background: rgba(11,30,26,.5);
    z-index: 1040;
    display: none;
}
.sidebar-backdrop.show { display: block; }

/* ================= المحتوى ================= */
.main-wrap {
    margin-right: var(--sidebar-w);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.topbar {
    background: #fff;
    border-bottom: 1px solid var(--line);
    padding: 12px 22px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    position: sticky;
    top: 0;
    z-index: 1030;
}
.topbar .page-title { font-size: 17px; font-weight: 700; margin: 0; color: var(--brand); }
.topbar .page-sub { font-size: 12px; color: var(--muted); margin: 0; }

.btn-burger {
    display: none;
    background: var(--brand-soft);
    border: none;
    color: var(--brand);
    width: 38px; height: 38px;
    border-radius: 10px;
}

.user-chip {
    display: flex; align-items: center; gap: 9px;
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: 40px;
    padding: 5px 6px 5px 12px;
    cursor: pointer;
}
.user-chip .avatar {
    width: 30px; height: 30px; border-radius: 50%;
    background: var(--brand); color: #fff;
    display: grid; place-items: center;
    font-size: 12px; font-weight: 700;
    flex: 0 0 auto;
}
.user-chip .u-name { font-size: 12.5px; font-weight: 600; line-height: 1.1; }
.user-chip .u-role { font-size: 10.5px; color: var(--muted); }

.content { padding: 22px; flex: 1; }

/* ================= البطاقات ================= */
.card-x {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}
.card-x .card-x-head {
    padding: 15px 18px;
    border-bottom: 1px solid var(--line);
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
    flex-wrap: wrap;
}
.card-x .card-x-head h6 { margin: 0; font-weight: 700; font-size: 15px; color: var(--brand); }
.card-x .card-x-body { padding: 18px; }

/* بطاقات الإحصائيات */
.stat-card {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: var(--shadow-sm);
    height: 100%;
    transition: transform .16s ease, box-shadow .16s ease;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.stat-card .st-icon {
    width: 42px; height: 42px; border-radius: 12px;
    display: grid; place-items: center;
    font-size: 17px; margin-bottom: 12px;
}
.st-brand { background: var(--brand-soft); color: var(--brand); }
.st-gold  { background: var(--gold-soft); color: #B57C25; }
.st-green { background: #E4F5EC; color: var(--green); }
.st-red   { background: #FCEAE8; color: var(--red); }
.st-amber { background: #FDF2E0; color: var(--amber); }
.st-gray  { background: #EEF1F0; color: #566966; }

.stat-card .st-label { font-size: 12.5px; color: var(--muted); margin: 0 0 3px; }
.stat-card .st-value { font-size: 21px; font-weight: 700; color: var(--text); margin: 0; letter-spacing: -.3px; }
.stat-card .st-value small { font-size: 12px; font-weight: 600; color: var(--muted); }

/* ================= الجداول ================= */
.table-wrap { overflow-x: auto; }
.table-x { width: 100%; margin: 0; border-collapse: separate; border-spacing: 0; }
.table-x thead th {
    background: #FAFBFB;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    padding: 11px 14px;
    white-space: nowrap;
    border-bottom: 1px solid var(--line);
    text-align: right;
}
.table-x tbody td {
    padding: 12px 14px;
    border-bottom: 1px solid #F1F4F3;
    font-size: 13.5px;
    vertical-align: middle;
    white-space: nowrap;
}
.table-x tbody tr:last-child td { border-bottom: 0; }
.table-x tbody tr:hover { background: #FAFCFB; }
.table-x .num { font-variant-numeric: tabular-nums; font-weight: 600; }
.text-money { color: var(--brand); font-weight: 700; }
.text-rest  { color: var(--red); font-weight: 700; }
.text-paid  { color: var(--green); font-weight: 700; }

/* ================= الشارات ================= */
.status-badge {
    display: inline-block;
    padding: 4px 11px;
    border-radius: 30px;
    font-size: 11.5px;
    font-weight: 700;
    white-space: nowrap;
}
.badge-paid    { background: #E4F5EC; color: #157A50; }
.badge-partial { background: #FDF2E0; color: #A9700F; }
.badge-unpaid  { background: #FCEAE8; color: #B5342B; }
.badge-soft    { background: var(--brand-soft); color: var(--brand); padding: 4px 10px; border-radius: 30px; font-size: 11.5px; font-weight: 600; }
.badge-gold    { background: var(--gold-soft); color: #A5701C; padding: 4px 10px; border-radius: 30px; font-size: 11.5px; font-weight: 600; }

/* ================= الأزرار ================= */
.btn { border-radius: 10px; font-size: 13.5px; font-weight: 600; padding: 8px 16px; }
.btn-brand { background: var(--brand); color: #fff; border: 1px solid var(--brand); }
.btn-brand:hover { background: var(--brand-light); color: #fff; }
.btn-gold { background: var(--gold); color: #3B2A0C; border: 1px solid var(--gold); }
.btn-gold:hover { background: #D89A40; color: #3B2A0C; }
.btn-ghost { background: #fff; color: var(--brand); border: 1px solid var(--line); }
.btn-ghost:hover { background: var(--brand-soft); color: var(--brand); }
.btn-sm { padding: 5px 11px; font-size: 12.5px; border-radius: 9px; }
.btn-icon { width: 32px; height: 32px; padding: 0; display: inline-grid; place-items: center; border-radius: 9px; }

/* ================= النماذج ================= */
.form-label { font-size: 13px; font-weight: 600; color: #43524F; margin-bottom: 6px; }
.form-label .req { color: var(--red); }
.form-control, .form-select {
    border: 1px solid #DFE5E3;
    border-radius: var(--radius-sm);
    padding: 9px 13px;
    font-size: 14px;
    background: #fff;
}
.form-control:focus, .form-select:focus {
    border-color: var(--brand-light);
    box-shadow: 0 0 0 3px rgba(18,60,52,.09);
}
.form-control[readonly] { background: #F7F9F8; }
.input-group-text { background: #F7F9F8; border: 1px solid #DFE5E3; border-radius: var(--radius-sm); font-size: 13px; color: var(--muted); }
.form-text { font-size: 11.5px; color: var(--muted); }
textarea.form-control { min-height: 88px; }

/* حالة فارغة */
.empty-state { text-align: center; padding: 46px 20px; }
.empty-state .empty-icon {
    width: 62px; height: 62px; margin: 0 auto 14px;
    border-radius: 50%;
    background: var(--brand-soft);
    color: var(--brand);
    display: grid; place-items: center;
    font-size: 23px;
}
.empty-state h6 { font-weight: 700; color: #43524F; margin-bottom: 4px; }
.empty-state p { color: var(--muted); font-size: 13px; margin: 0; }

/* شريط البحث/الفلاتر */
.filter-bar {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 14px 16px;
    margin-bottom: 16px;
    box-shadow: var(--shadow-sm);
}

/* الترقيم */
.pagination { --bs-pagination-color: var(--brand); --bs-pagination-active-bg: var(--brand); --bs-pagination-active-border-color: var(--brand); }
.page-link { border-radius: 9px !important; margin: 0 2px; border-color: var(--line); font-size: 13px; }

/* صفحة الدخول */
.login-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    background:
        radial-gradient(1000px 500px at 100% 0%, rgba(226,169,84,.10), transparent 60%),
        radial-gradient(900px 500px at 0% 100%, rgba(18,60,52,.10), transparent 60%),
        var(--bg);
}
.login-card {
    width: 100%;
    max-width: 420px;
    background: #fff;
    border-radius: 22px;
    box-shadow: 0 18px 50px rgba(18,60,52,.12);
    border: 1px solid var(--line);
    overflow: hidden;
}
.login-head {
    background: linear-gradient(160deg, var(--brand) 0%, var(--brand-dark) 100%);
    padding: 28px 26px 24px;
    text-align: center;
    color: #fff;
}
.login-head .logo-circle {
    width: 76px; height: 76px;
    margin: 0 auto 14px;
    background: #fff;
    border-radius: 22px;
    display: grid; place-items: center;
    padding: 9px;
    box-shadow: 0 8px 22px rgba(0,0,0,.16);
}
.login-head .logo-circle img { max-width: 100%; max-height: 100%; }
.login-head h1 { font-size: 19px; font-weight: 700; margin: 0 0 3px; }
.login-head p { font-size: 12.5px; margin: 0; color: rgba(255,255,255,.66); }
.login-body { padding: 26px 26px 28px; }
.pw-toggle {
    position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
    background: none; border: 0; color: var(--muted); padding: 4px 6px; z-index: 5;
}

/* تفاصيل */
.detail-row { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: 1px dashed #EDF1F0; font-size: 13.5px; }
.detail-row:last-child { border-bottom: 0; }
.detail-row .k { color: var(--muted); }
.detail-row .v { font-weight: 600; text-align: left; }

.summary-box { background: var(--brand-soft); border-radius: var(--radius-sm); padding: 14px; }
.summary-box .sb-label { font-size: 12px; color: #4B5D59; }
.summary-box .sb-value { font-size: 18px; font-weight: 700; color: var(--brand); }

/* ================= الطباعة ================= */
.print-sheet { background: #fff; padding: 28px; max-width: 900px; margin: 0 auto; }
.print-head { display: flex; justify-content: space-between; align-items: flex-start; border-bottom: 2px solid var(--brand); padding-bottom: 14px; margin-bottom: 18px; }
.print-head .ph-logo { width: 78px; }
.print-head .ph-logo img { max-width: 100%; }
.print-title { font-size: 20px; font-weight: 700; color: var(--brand); margin: 0; }
.print-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.print-table th, .print-table td { border: 1px solid #D8E0DE; padding: 7px 9px; text-align: right; }
.print-table thead th { background: var(--brand-soft); color: var(--brand); font-weight: 700; }
.print-foot { margin-top: 22px; font-size: 12px; color: var(--muted); text-align: center; border-top: 1px dashed var(--line); padding-top: 12px; }

@media print {
    .no-print, .sidebar, .topbar, .sidebar-backdrop { display: none !important; }
    body { background: #fff; }
    .main-wrap { margin: 0 !important; }
    .content { padding: 0 !important; }
    .print-sheet { box-shadow: none; padding: 0; max-width: 100%; }
    a[href]::after { content: none !important; }
}

/* ================= الاستجابة ================= */
@media (max-width: 991.98px) {
    .sidebar { transform: translateX(100%); box-shadow: -6px 0 24px rgba(0,0,0,.16); }
    .sidebar.open { transform: translateX(0); }
    .main-wrap { margin-right: 0; }
    .btn-burger { display: inline-grid; place-items: center; }
    .content { padding: 16px 14px; }
    .topbar { padding: 10px 14px; }
    .user-chip .u-info { display: none; }
}

@media (max-width: 575.98px) {
    body { font-size: 14px; }
    .stat-card { padding: 14px; }
    .stat-card .st-value { font-size: 18px; }
    .topbar .page-title { font-size: 15px; }
    .card-x .card-x-body { padding: 14px; }
    .btn { padding: 8px 13px; font-size: 13px; }
    .modal-body { padding: 16px; }
}
