/* =========================================================
   منظومة مطعم بونو - التصميم الرئيسي (Mobile-first)
   ========================================================= */

/* ---------- الخط (محلي) ---------- */
@font-face { font-family: 'Cairo'; font-weight: 400; font-display: swap; src: url('../fonts/cairo-arabic-400-normal.woff2') format('woff2'); unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0898-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC; }
@font-face { font-family: 'Cairo'; font-weight: 600; font-display: swap; src: url('../fonts/cairo-arabic-600-normal.woff2') format('woff2'); unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0898-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC; }
@font-face { font-family: 'Cairo'; font-weight: 700; font-display: swap; src: url('../fonts/cairo-arabic-700-normal.woff2') format('woff2'); unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0898-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC; }
@font-face { font-family: 'Cairo'; font-weight: 800; font-display: swap; src: url('../fonts/cairo-arabic-800-normal.woff2') format('woff2'); unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0898-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC; }
@font-face { font-family: 'Cairo'; font-weight: 400; font-display: swap; src: url('../fonts/cairo-latin-400-normal.woff2') format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2212, U+2215; }
@font-face { font-family: 'Cairo'; font-weight: 600; font-display: swap; src: url('../fonts/cairo-latin-600-normal.woff2') format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2212, U+2215; }
@font-face { font-family: 'Cairo'; font-weight: 700; font-display: swap; src: url('../fonts/cairo-latin-700-normal.woff2') format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2212, U+2215; }
@font-face { font-family: 'Cairo'; font-weight: 800; font-display: swap; src: url('../fonts/cairo-latin-800-normal.woff2') format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2212, U+2215; }

:root {
    --brand: #d90000;
    --brand-dark: #a80000;
    --brand-soft: #fff0f0;
    --ink: #121214;
    --ink-2: #1c1c20;
    --muted: #6b6f76;
    --line: #e9e9ee;
    --bg: #f4f4f6;
    --card: #ffffff;
    --radius: 14px;
    --sidebar-w: 264px;
    --bs-primary: #d90000;
    --bs-primary-rgb: 217, 0, 0;
    --bs-link-color: #c10000;
    --bs-link-hover-color: #8f0000;
    --bs-body-font-family: 'Cairo', system-ui, -apple-system, 'Segoe UI', Tahoma, sans-serif;
    --bs-body-bg: var(--bg);
    --bs-body-color: #23252a;
    --bs-border-color: var(--line);
    --bs-border-radius: 10px;
}

html { -webkit-text-size-adjust: 100%; }
body { font-family: var(--bs-body-font-family); background: var(--bg); min-height: 100vh; font-size: .95rem; }
a { text-decoration: none; }
.num, .table td.num, input[type=number] { font-variant-numeric: tabular-nums; }
small.cur { font-size: .72em; color: var(--muted); font-weight: 600; }

/* ---------- الأزرار ---------- */
.btn { font-weight: 600; border-radius: 10px; }
.btn-primary { --bs-btn-bg: var(--brand); --bs-btn-border-color: var(--brand); --bs-btn-hover-bg: var(--brand-dark); --bs-btn-hover-border-color: var(--brand-dark); --bs-btn-active-bg: #8f0000; --bs-btn-active-border-color: #8f0000; --bs-btn-disabled-bg: #e46666; --bs-btn-disabled-border-color: #e46666; }
.btn-outline-primary { --bs-btn-color: var(--brand); --bs-btn-border-color: var(--brand); --bs-btn-hover-bg: var(--brand); --bs-btn-hover-border-color: var(--brand); --bs-btn-active-bg: var(--brand-dark); --bs-btn-active-border-color: var(--brand-dark); }
.btn-dark { --bs-btn-bg: var(--ink); --bs-btn-border-color: var(--ink); }
.btn-icon { width: 40px; height: 40px; display: inline-flex; align-items: center; justify-content: center; padding: 0; font-size: 1.4rem; border-radius: 10px; }
.btn-soft { background: #f1f1f4; border: 0; color: #333; }
.btn-soft:hover { background: #e6e6ea; }
.btn-soft-danger { background: var(--brand-soft); border: 0; color: var(--brand); }
.btn-soft-danger:hover { background: #ffdede; color: var(--brand-dark); }

/* ---------- النماذج ---------- */
.form-control, .form-select { border-radius: 10px; padding: .55rem .8rem; border-color: #dcdce2; }
.form-control:focus, .form-select:focus { border-color: var(--brand); box-shadow: 0 0 0 .2rem rgba(217, 0, 0, .12); }
.form-check-input:checked { background-color: var(--brand); border-color: var(--brand); }
.form-check-input:focus { box-shadow: 0 0 0 .2rem rgba(217, 0, 0, .15); border-color: var(--brand); }
.form-label { font-weight: 600; font-size: .86rem; color: #3b3e45; margin-bottom: .3rem; }
.required::after { content: ' *'; color: var(--brand); }
input.num-input { direction: ltr; text-align: right; }

/* ---------- القائمة الجانبية ---------- */
.sidebar { background: var(--ink) !important; color: #d6d6dc; width: var(--sidebar-w) !important; display: flex; flex-direction: column; border: 0 !important; }
.sidebar-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 18px 10px; }
.sidebar .brand img { height: 46px; width: auto; }
.sidebar-nav { flex: 1; overflow-y: auto; padding: 6px 12px 16px; scrollbar-width: thin; scrollbar-color: #333 transparent; }
.nav-group { font-size: .72rem; font-weight: 700; color: #7c7c86; padding: 14px 12px 6px; letter-spacing: .3px; }
.sidebar .nav-link { display: flex; align-items: center; gap: 12px; color: #c9c9d1; padding: 9px 12px; border-radius: 10px; font-weight: 600; font-size: .92rem; margin-bottom: 2px; transition: background .15s, color .15s; }
.sidebar .nav-link i { font-size: 1.1rem; width: 22px; text-align: center; color: #8d8d97; }
.sidebar .nav-link:hover { background: var(--ink-2); color: #fff; }
.sidebar .nav-link.active { background: var(--brand); color: #fff; box-shadow: 0 6px 16px rgba(217, 0, 0, .35); }
.sidebar .nav-link.active i { color: #fff; }
.sidebar-foot { display: flex; align-items: center; gap: 8px; padding: 12px; border-top: 1px solid #26262b; }
.user-chip { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; color: #eee; padding: 6px; border-radius: 10px; }
.user-chip:hover { background: var(--ink-2); color: #fff; }
.user-chip strong { display: block; font-size: .86rem; line-height: 1.3; }
.user-chip small { color: #8d8d97; font-size: .74rem; }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--brand); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-weight: 800; flex-shrink: 0; }
.btn-logout { width: 38px; height: 38px; border-radius: 10px; display: inline-flex; align-items: center; justify-content: center; color: #aaa; background: var(--ink-2); font-size: 1.1rem; }
.btn-logout:hover { color: #fff; background: var(--brand); }

@media (min-width: 992px) {
    .sidebar { position: fixed; top: 0; bottom: 0; right: 0; z-index: 1030; }
    .main { margin-right: var(--sidebar-w); }
}

/* ---------- الشريط العلوي ---------- */
.main { min-height: 100vh; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 1020; display: flex; align-items: center; gap: 10px; padding: 10px 14px; padding-top: max(10px, env(safe-area-inset-top)); background: rgba(255, 255, 255, .92); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.topbar-logo { height: 30px; background: var(--ink); border-radius: 8px; padding: 3px 6px; }
.page-title { font-size: 1.05rem; font-weight: 800; margin: 0; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.today { font-size: .85rem; color: var(--muted); font-weight: 600; background: #f3f3f6; padding: 6px 12px; border-radius: 20px; }
.content { flex: 1; padding: 14px 12px 96px; width: 100%; max-width: 1400px; margin: 0 auto; }
.app-footer { text-align: center; font-size: .78rem; color: #9a9aa3; padding: 0 12px 90px; }

@media (min-width: 992px) {
    .topbar { padding: 14px 28px; }
    .page-title { font-size: 1.3rem; }
    .content { padding: 24px 28px 30px; }
    .app-footer { padding-bottom: 20px; }
}

/* ---------- الشريط السفلي (موبايل) ---------- */
.bottom-nav { position: fixed; bottom: 0; left: 0; right: 0; z-index: 1025; display: flex; background: #fff; border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); box-shadow: 0 -6px 24px rgba(0, 0, 0, .06); }
.bottom-nav a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 2px 7px; color: #8a8a93; font-size: .7rem; font-weight: 700; }
.bottom-nav a i { font-size: 1.3rem; line-height: 1; }
.bottom-nav a.active { color: var(--brand); }

/* ---------- البطاقات ---------- */
.card { border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 1px 2px rgba(16, 16, 20, .03); }
.card-header { background: transparent; border-bottom: 1px solid var(--line); padding: .85rem 1rem; font-weight: 800; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.card-header .bi { color: var(--brand); }
.card-body { padding: 1rem; }

.page-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 14px; }
.page-actions .spacer { flex: 1; }

/* إحصائيات */
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; display: flex; align-items: center; gap: 12px; height: 100%; }
.stat .ic { width: 46px; height: 46px; border-radius: 12px; display: inline-flex; align-items: center; justify-content: center; font-size: 1.35rem; flex-shrink: 0; background: var(--brand-soft); color: var(--brand); }
.stat .ic.dark { background: #ececf0; color: var(--ink); }
.stat .ic.green { background: #e8f7ee; color: #198754; }
.stat .ic.amber { background: #fff6e0; color: #b7791f; }
.stat .lbl { font-size: .78rem; color: var(--muted); font-weight: 700; }
.stat .val { font-size: 1.15rem; font-weight: 800; color: var(--ink); line-height: 1.35; word-break: break-word; }
@media (min-width: 992px) { .stat .val { font-size: 1.35rem; } }

.hero { background: linear-gradient(135deg, #121214 0%, #26262c 100%); color: #fff; border-radius: var(--radius); padding: 18px; display: flex; align-items: center; gap: 14px; position: relative; overflow: hidden; }
.hero::after { content: ''; position: absolute; left: -40px; top: -40px; width: 180px; height: 180px; border-radius: 50%; background: radial-gradient(circle, rgba(217, 0, 0, .45), transparent 70%); }
.hero h2 { font-size: 1.15rem; font-weight: 800; margin: 0; }
.hero p { margin: 0; color: #b9b9c2; font-size: .86rem; }

/* اختصارات */
.quick { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
@media (min-width: 768px) { .quick { grid-template-columns: repeat(4, 1fr); } }
.quick a { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 10px; display: flex; flex-direction: column; align-items: center; gap: 6px; color: var(--ink); font-weight: 700; font-size: .88rem; transition: transform .12s, border-color .12s; }
.quick a i { font-size: 1.6rem; color: var(--brand); }
.quick a:hover { border-color: var(--brand); transform: translateY(-2px); }

/* ---------- الجداول ---------- */
.table { --bs-table-bg: transparent; margin-bottom: 0; }
.table > :not(caption) > * > * { padding: .65rem .75rem; vertical-align: middle; }
.table thead th { font-size: .78rem; color: var(--muted); font-weight: 800; background: #fafafc; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table tbody tr:hover { background: #fcfcfd; }
.table tfoot td, .table tfoot th { font-weight: 800; background: #fafafc; }
.table .actions { white-space: nowrap; text-align: left; }
.table .actions .btn { padding: .25rem .5rem; }

/* جدول يتحول إلى بطاقات في الموبايل */
@media (max-width: 767.98px) {
    .table-cards thead { display: none; }
    .table-cards, .table-cards tbody, .table-cards tr, .table-cards td { display: block; width: 100%; }
    .table-cards tr { background: #fff; border: 1px solid var(--line); border-radius: 12px; margin-bottom: 10px; padding: 6px 4px; }
    .table-cards td { display: flex; justify-content: space-between; align-items: center; gap: 12px; border: 0 !important; padding: .35rem .75rem !important; text-align: left; }
    .table-cards td::before { content: attr(data-label); font-weight: 700; color: var(--muted); font-size: .8rem; text-align: right; flex-shrink: 0; }
    .table-cards td[data-label=""]::before, .table-cards td:not([data-label])::before { display: none; }
    .table-cards td.card-title-cell { font-weight: 800; font-size: 1rem; color: var(--ink); border-bottom: 1px dashed var(--line) !important; padding-bottom: .5rem !important; margin-bottom: .2rem; justify-content: flex-start; text-align: right; }
    .table-cards td.actions { justify-content: flex-end; border-top: 1px dashed var(--line) !important; margin-top: .3rem; padding-top: .5rem !important; }
    .table-cards tfoot { display: block; }
    .table-cards tfoot tr { display: flex; flex-wrap: wrap; background: #fafafc; }
    .table-cards tfoot td { width: auto; flex: 1; }
    .card .table-cards { padding: 8px; }
}

/* شارات */
.badge { font-weight: 700; padding: .4em .7em; border-radius: 20px; }
.badge-soft-success { background: #e6f6ec; color: #157347; }
.badge-soft-danger { background: var(--brand-soft); color: var(--brand); }
.badge-soft-warning { background: #fff4db; color: #9a6700; }
.badge-soft-dark { background: #ececf0; color: #333; }

/* بحث وفلاتر */
.filters { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; margin-bottom: 14px; }
.filters .form-control, .filters .form-select { padding: .45rem .7rem; }

.empty { text-align: center; padding: 40px 16px; color: var(--muted); }
.empty i { font-size: 2.6rem; color: #cfcfd6; display: block; margin-bottom: 8px; }

/* ---------- سطور الفاتورة ---------- */
.line-row { background: #fafafc; border: 1px solid var(--line); border-radius: 12px; padding: 10px; margin-bottom: 8px; position: relative; }
.line-row .form-control, .line-row .form-select { padding: .45rem .6rem; }
.line-row .line-total { font-weight: 800; color: var(--ink); }
.line-row .btn-del { position: absolute; top: 6px; left: 6px; }
.line-row .stock-hint { font-size: .74rem; color: var(--muted); }
.totals-bar { position: sticky; bottom: 64px; z-index: 5; background: var(--ink); color: #fff; border-radius: var(--radius); padding: 12px 16px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; box-shadow: 0 10px 30px rgba(0, 0, 0, .25); }
.totals-bar .big { font-size: 1.35rem; font-weight: 800; }
.totals-bar small.cur { color: #aaa; }
@media (min-width: 992px) { .totals-bar { bottom: 12px; } }

/* بحث داخل القوائم المنسدلة */
.item-picker { position: relative; }
.item-picker .dropdown-list { position: absolute; top: 100%; right: 0; left: 0; z-index: 30; background: #fff; border: 1px solid var(--line); border-radius: 10px; max-height: 260px; overflow-y: auto; box-shadow: 0 12px 30px rgba(0, 0, 0, .12); display: none; }
.item-picker .dropdown-list.show { display: block; }
.item-picker .dropdown-list .opt { padding: 8px 12px; cursor: pointer; display: flex; justify-content: space-between; gap: 8px; font-size: .9rem; }
.item-picker .dropdown-list .opt:hover, .item-picker .dropdown-list .opt.hl { background: var(--brand-soft); }
.item-picker .dropdown-list .opt small { color: var(--muted); }
.item-picker .dropdown-list .grp { padding: 6px 12px; font-size: .74rem; font-weight: 800; color: var(--muted); background: #fafafc; position: sticky; top: 0; }

/* ---------- صفحة الدخول ---------- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; background: radial-gradient(circle at 20% 10%, rgba(217, 0, 0, .35), transparent 45%), radial-gradient(circle at 90% 90%, rgba(217, 0, 0, .18), transparent 40%), #0b0b0d; }
.login-card { width: 100%; max-width: 400px; background: #fff; border-radius: 20px; padding: 28px 24px; box-shadow: 0 30px 80px rgba(0, 0, 0, .45); }
.login-logo { background: #0b0b0d; border-radius: 14px; padding: 16px; text-align: center; margin: -8px -4px 20px; }
.login-logo img { max-width: 220px; width: 70%; }
.login-card h1 { font-size: 1.15rem; font-weight: 800; text-align: center; margin-bottom: 4px; }
.login-card p.sub { text-align: center; color: var(--muted); font-size: .86rem; margin-bottom: 20px; }
.input-icon { position: relative; }
.input-icon i { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: #9a9aa3; }
.input-icon .form-control { padding-right: 38px; }

/* ---------- الطباعة ---------- */
.print-only, .print-head.print-only { display: none; }
.print-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; border-bottom: 3px solid var(--brand); padding-bottom: 10px; margin-bottom: 14px; }
.print-head img { height: 64px; }
.print-head .info { text-align: right; }
.print-head .info h2 { font-size: 1.2rem; font-weight: 800; margin: 0; }
.print-head .info small { color: #555; }
.print-head .doc-title { text-align: left; }
.print-head .doc-title h3 { font-size: 1.1rem; font-weight: 800; margin: 0; color: var(--brand); }
.print-sign { display: flex; justify-content: space-between; margin-top: 40px; font-weight: 700; }
.print-sign div { text-align: center; min-width: 160px; }
.print-sign div span { display: block; margin-top: 30px; border-top: 1px dotted #888; padding-top: 4px; font-weight: 400; color: #666; font-size: .85rem; }
.print-foot { margin-top: 24px; font-size: .75rem; color: #888; text-align: center; border-top: 1px solid #eee; padding-top: 8px; }

@media print {
    @page { size: A4; margin: 12mm 10mm; }
    body { background: #fff !important; font-size: 12px; }
    .sidebar, .topbar, .bottom-nav, .app-footer, .no-print, .page-actions, .filters, .alert, .btn { display: none !important; }
    .main { margin: 0 !important; }
    .content { padding: 0 !important; max-width: none; }
    .print-only { display: block !important; }
    .print-head.print-only { display: flex !important; }
    .card { border: 0 !important; box-shadow: none !important; }
    .card-header { padding: 6px 0; border-bottom: 2px solid #222; }
    .card-body { padding: 8px 0; }
    .table-cards thead { display: table-header-group !important; }
    .table-cards, .table-cards tbody { display: table-row-group; }
    .table-cards { display: table !important; }
    .table-cards tr { display: table-row !important; border: 0; }
    .table-cards td { display: table-cell !important; }
    .table-cards td::before { display: none !important; }
    .table { border: 1px solid #999; }
    .table > :not(caption) > * > * { padding: 4px 6px; border: 1px solid #bbb; }
    .table thead th { background: #222 !important; color: #fff !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    .stat { border: 1px solid #bbb; }
    a { color: inherit; }
}
.list-group-item.active-day { background: var(--brand-soft); border-right: 3px solid var(--brand); }

/* ---------- التقارير الرسمية ---------- */
.report-table th { background: var(--ink) !important; color: #fff !important; font-size: .82rem; vertical-align: middle; }
.report-table td { font-size: .92rem; }
.report-table .row-sub td { background: #fafafc; }
.report-table .row-head td { background: #f1f1f4; letter-spacing: 2px; }
.report-table .row-total td { font-size: 1.05rem; font-weight: 800; background: var(--brand-soft); }
.report-table .row-total.pos td { background: #e8f7ee; color: #146c43; }
.report-table .row-total.neg td { color: var(--brand); }
.report-hub a.card { color: inherit; transition: transform .12s, border-color .12s; }
.report-hub a.card:hover { border-color: var(--brand); transform: translateY(-2px); }
.report-hub .ic-big { width: 54px; height: 54px; border-radius: 14px; display: inline-flex; align-items: center; justify-content: center; font-size: 1.6rem; background: var(--brand-soft); color: var(--brand); }
.bar-chart { display: flex; align-items: flex-end; gap: 6px; height: 170px; padding: 10px 4px 0; border-bottom: 1px solid var(--line); overflow-x: auto; }
.bar-chart .col-b { flex: 1; min-width: 34px; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 2px; }
.bar-chart .bars { display: flex; align-items: flex-end; gap: 2px; height: 100%; width: 100%; justify-content: center; }
.bar-chart .b { width: 42%; max-width: 16px; border-radius: 4px 4px 0 0; min-height: 2px; }
.bar-chart .b.s { background: var(--brand); }
.bar-chart .b.c { background: #3a3a40; }
.bar-chart .lbl { font-size: .68rem; color: var(--muted); white-space: nowrap; }
.legend-dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-left: 4px; vertical-align: middle; }
@media print {
    .report-table th { background: #222 !important; color: #fff !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    .report-table .row-total td, .report-table .row-sub td, .report-table .row-head td { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    .report-table td { font-size: 12px; padding: 5px 8px !important; }
    .bar-chart { display: none; }
}
@media screen and (max-width: 767.98px) {
    .report-table .col-note { display: none; }
    .report-table td, .report-table th { font-size: .82rem; padding: .45rem .4rem !important; }
}
