/* ══════════════════════════════════════════════
   مراسيم — نظام الضيافة الملكية
   CSS الرئيسي | أحمر وأبيض | خط تجوال
══════════════════════════════════════════════ */
@import url('https://fonts.googleapis.com/css2?family=Tajawal:wght@300;400;500;700;800;900&display=swap');

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

:root {
    --red:          #b81c27;
    --red2:         #991520;
    --red3:         #7a1018;
    --red-bg:       #fff5f5;
    --red-border:   #fcc;
    --white:        #ffffff;
    --bg:           #f2f3f5;
    --border:       #e2e2e8;
    --text:         #1a1a1a;
    --muted:        #888;
    --green:        #1a7a3a;
    --green-bg:     #f0fff4;
    --green-border: #b0ddc0;
    --orange:       #c07020;
    --orange-bg:    #fff8f0;
    --orange-border:#f0d090;
    --blue-bg:      #f0f5ff;
    --blue:         #2255cc;
    --shadow:       0 2px 12px rgba(0,0,0,0.08);
    --shadow-lg:    0 8px 32px rgba(0,0,0,0.12);
}

html { font-size: 16px; }
body {
    font-family: 'Tajawal', sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    direction: rtl;
}

/* ══ LAYOUT ══ */
.layout { display: flex; flex-direction: column; min-height: 100vh; }
.main   { flex: 1; padding: 28px 36px; }

/* ══ TOPBAR ══ */
.topbar {
    background: var(--red);
    height: 60px;
    padding: 0 36px;
    display: flex; align-items: center; justify-content: space-between;
    box-shadow: 0 2px 12px rgba(184,28,39,0.3);
    position: sticky; top: 0; z-index: 100;
    flex-shrink: 0;
}

.topbar-brand { display: flex; align-items: center; gap: 12px; }
.topbar-logo  { font-size: 26px; }
.topbar-name  { font-size: 22px; font-weight: 900; color: #fff; line-height: 1; }
.topbar-sub   { font-size: 11px; color: rgba(255,255,255,0.6); letter-spacing: 1px; }

.topbar-nav { display: flex; gap: 4px; }
.nav-link {
    padding: 8px 16px; border-radius: 8px;
    font-size: 14px; font-weight: 700; color: rgba(255,255,255,0.75);
    text-decoration: none; transition: all 0.2s;
    display: flex; align-items: center; gap: 6px;
}
.nav-link:hover  { background: rgba(255,255,255,0.15); color: #fff; }
.nav-link.active { background: rgba(255,255,255,0.2); color: #fff; }

.topbar-user { display: flex; align-items: center; gap: 12px; }
.user-badge {
    padding: 4px 12px; border-radius: 20px; font-size: 12px; font-weight: 700;
    background: rgba(255,255,255,0.15); color: #fff;
}

/* ══ PAGE HEADER ══ */
.page-title { font-size: 24px; font-weight: 900; margin-bottom: 20px; }
.page-header {
    display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px;
}
.page-header .page-title { margin-bottom: 0; }

/* ══ BUTTONS ══ */
.btn {
    display: inline-flex; align-items: center; gap: 6px;
    font-family: 'Tajawal', sans-serif; font-weight: 700; font-size: 14px;
    padding: 10px 20px; border-radius: 10px; border: none; cursor: pointer;
    transition: all 0.2s; text-decoration: none; white-space: nowrap;
}
.btn-primary {
    background: var(--red); color: #fff;
    box-shadow: 0 4px 14px rgba(184,28,39,0.3);
}
.btn-primary:hover { background: var(--red2); transform: translateY(-1px); }
.btn-secondary {
    background: #f0f0f2; color: #444; border: 1.5px solid var(--border);
}
.btn-secondary:hover { background: #e5e5ea; }
.btn-danger { background: #fee; color: var(--red); border: 1.5px solid var(--red-border); }
.btn-danger:hover { background: var(--red); color: #fff; }
.btn-outline { background: #fff; color: var(--red); border: 1.5px solid var(--red); }
.btn-outline:hover { background: var(--red-bg); }
.btn-sm  { padding: 6px 14px; font-size: 13px; border-radius: 8px; }
.btn-lg  { padding: 14px 28px; font-size: 17px; border-radius: 12px; }
.btn-full { width: 100%; justify-content: center; }

/* ══ FORMS ══ */
.form-group { margin-bottom: 14px; }
.form-label { display: block; font-size: 13px; font-weight: 700; color: #444; margin-bottom: 6px; }
.form-control {
    width: 100%; padding: 11px 14px;
    font-family: 'Tajawal', sans-serif; font-size: 14px; font-weight: 500;
    color: var(--text); background: #fff;
    border: 1.5px solid var(--border); border-radius: 10px; outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    -webkit-appearance: none; appearance: none;
}
.form-control::placeholder { color: #bbb; font-weight: 400; }
.form-control:focus {
    border-color: var(--red);
    box-shadow: 0 0 0 3px rgba(184,28,39,0.1);
}
select.form-control {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='9' viewBox='0 0 14 9'%3E%3Cpath d='M1 1l6 6 6-6' stroke='%23b81c27' stroke-width='2' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: left 12px center;
    padding-left: 36px; cursor: pointer;
}
select.form-control option { color: var(--text); background: #fff; }
textarea.form-control { resize: none; line-height: 1.6; }

/* ══ CARDS ══ */
.card {
    background: #fff; border: 1.5px solid var(--border);
    border-radius: 14px; overflow: hidden;
    box-shadow: var(--shadow);
}
.card-header {
    padding: 14px 20px; background: #fafafa;
    border-bottom: 1.5px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
    font-size: 15px; font-weight: 800;
}
.card-body { padding: 20px; }

/* ══ BADGES ══ */
.badge {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 3px 10px; border-radius: 20px;
    font-size: 12px; font-weight: 700;
}
.badge-red    { background: var(--red-bg); color: var(--red); }
.badge-green  { background: var(--green-bg); color: var(--green); }
.badge-orange { background: var(--orange-bg); color: var(--orange); }
.badge-gray   { background: #f0f0f2; color: #666; }
.badge-blue   { background: var(--blue-bg); color: var(--blue); }

/* ══ TABLES ══ */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead th {
    padding: 11px 16px; text-align: right;
    font-size: 12px; font-weight: 700; color: var(--muted);
    background: #fafafa; border-bottom: 1.5px solid var(--border);
}
tbody td { padding: 12px 16px; font-size: 14px; border-bottom: 1px solid #f0f0f2; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: #fafafa; }
.text-muted { color: var(--muted); }
.text-green { color: var(--green); }

/* ══ STATS GRID ══ */
.stats-grid {
    display: grid; grid-template-columns: repeat(4,1fr); gap: 16px; margin-bottom: 24px;
}
.stat-card {
    background: #fff; border: 1.5px solid var(--border);
    border-radius: 14px; padding: 22px; box-shadow: var(--shadow);
}
.stat-icon  { font-size: 28px; margin-bottom: 10px; }
.stat-value { font-size: 34px; font-weight: 900; color: var(--text); line-height: 1; }
.stat-value.red    { color: var(--red); }
.stat-value.green  { color: var(--green); }
.stat-label { font-size: 13px; color: var(--muted); margin-top: 6px; }

/* ══ ALERTS ══ */
.alert {
    padding: 12px 16px; border-radius: 10px; margin-bottom: 16px;
    font-size: 14px; font-weight: 500;
}
.alert-error   { background: var(--red-bg); color: var(--red); border: 1px solid var(--red-border); }
.alert-success { background: var(--green-bg); color: var(--green); border: 1px solid var(--green-border); }

/* ══ MODALS ══ */
.modal-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 999;
    display: none; align-items: center; justify-content: center;
    backdrop-filter: blur(4px);
}
.modal {
    background: #fff; border-radius: 18px; padding: 32px;
    width: 90%; max-width: 500px;
    box-shadow: 0 32px 80px rgba(0,0,0,0.18);
    animation: popIn 0.3s cubic-bezier(.34,1.56,.64,1);
}

/* ══ PROGRESS ══ */
.progress-bar-wrap {
    flex: 1; height: 6px; background: #eee; border-radius: 4px; overflow: hidden;
}
.progress-bar      { height: 100%; border-radius: 4px; transition: width 0.4s; }
.progress-bar.ok   { background: var(--green); }
.progress-bar.low  { background: var(--red); }
.stock-ok  { color: var(--green); font-weight: 900; }
.stock-low { color: var(--red); font-weight: 900; }

/* ══════════════════ AUTH ══════════════════ */
.auth-wrap {
    min-height: 100vh; display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, var(--red) 0%, var(--red3) 100%);
    padding: 20px;
    position: relative;
}
.auth-wrap::before {
    content: '';
    position: absolute; inset: 0;
    background: repeating-linear-gradient(
        -45deg, transparent, transparent 40px,
        rgba(255,255,255,0.03) 40px, rgba(255,255,255,0.03) 41px
    );
}
.auth-card {
    background: #fff; border-radius: 20px; padding: 40px;
    width: 100%; max-width: 420px;
    box-shadow: 0 32px 80px rgba(0,0,0,0.2);
    position: relative; z-index: 1;
    animation: popIn 0.4s ease;
}
.auth-logo { text-align: center; margin-bottom: 32px; }
.auth-logo-icon { font-size: 48px; margin-bottom: 12px; }
.auth-title { font-size: 26px; font-weight: 900; color: var(--red); }
.auth-sub   { font-size: 13px; color: var(--muted); margin-top: 4px; }

/* ══════════════════ CASHIER ══════════════════ */
.cashier-layout {
    display: grid; grid-template-columns: 1fr 380px; gap: 0;
    height: calc(100vh - 60px);
    margin: -28px -36px;
}
.cashier-menu {
    display: flex; flex-direction: column; overflow: hidden;
    border-left: 2px solid var(--border); background: var(--bg);
}
.cat-tabs {
    display: flex; overflow-x: auto; background: #fff;
    border-bottom: 2px solid var(--border); flex-shrink: 0;
}
.cat-tab {
    padding: 14px 20px; white-space: nowrap;
    font-family: 'Tajawal', sans-serif; font-size: 14px; font-weight: 700;
    color: var(--muted); border-bottom: 3px solid transparent;
    margin-bottom: -2px; cursor: pointer; border: none;
    background: none; transition: all 0.15s;
}
.cat-tab.active { color: var(--red); border-bottom-color: var(--red); }
.cat-tab:hover  { color: var(--red); }

.items-grid {
    flex: 1; overflow-y: auto; padding: 18px;
    display: grid; grid-template-columns: repeat(auto-fill, minmax(145px, 1fr));
    gap: 12px; align-content: start;
}
.item-card {
    background: #fff; border: 1.5px solid var(--border); border-radius: 14px;
    padding: 16px 12px; text-align: center; cursor: pointer;
    transition: all 0.18s cubic-bezier(.34,1.56,.64,1);
    display: flex; flex-direction: column; align-items: center; gap: 6px;
    font-family: 'Tajawal', sans-serif;
}
.item-card:hover { border-color: var(--red); transform: translateY(-3px); box-shadow: 0 8px 20px rgba(184,28,39,0.12); }
.item-card.in-cart { background: var(--red-bg); border-color: var(--red); }
.item-emoji { font-size: 36px; }
.item-name  { font-size: 13px; font-weight: 700; color: var(--text); line-height: 1.4; }
.item-price { font-size: 15px; font-weight: 900; color: var(--red); }

.cashier-order {
    background: #fff; display: flex; flex-direction: column;
    border-right: 2px solid var(--border);
}
.order-header {
    padding: 14px 20px; border-bottom: 1.5px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
    flex-shrink: 0;
}
.order-items { flex: 1; overflow-y: auto; padding: 12px 18px; }

.order-item {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 0; border-bottom: 1px solid #f0f0f2;
}
.order-item-name  { font-size: 13px; font-weight: 700; }
.order-item-sub   { font-size: 11px; color: var(--muted); }
.order-item-total { font-size: 14px; font-weight: 800; min-width: 55px; text-align: left; }

.qty-ctrl { display: flex; align-items: center; gap: 6px; }
.qty-btn {
    width: 28px; height: 28px; border-radius: 7px;
    border: 1.5px solid var(--border); background: #f5f5f5;
    font-size: 16px; font-weight: 800; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    color: var(--red); transition: all 0.15s;
}
.qty-btn:hover { background: var(--red); color: #fff; border-color: var(--red); }
.qty-num { font-size: 14px; font-weight: 900; min-width: 22px; text-align: center; }

.order-note { padding: 10px 18px; border-top: 1px solid #f0f0f2; flex-shrink: 0; }

.order-totals {
    padding: 14px 18px; border-top: 1.5px solid var(--border);
    background: #fafafa; flex-shrink: 0;
}
.total-row {
    display: flex; justify-content: space-between;
    font-size: 13px; color: var(--muted); margin-bottom: 5px;
}
.total-row.grand {
    font-size: 22px; font-weight: 900; color: var(--text);
    border-top: 2px solid var(--border); padding-top: 10px; margin-top: 8px; margin-bottom: 0;
}
.total-row.grand span:last-child { color: var(--red); }

.pay-methods { display: flex; gap: 8px; margin-top: 12px; margin-bottom: 10px; }
.pay-btn {
    flex: 1; padding: 9px 4px;
    background: #fff; border: 1.5px solid var(--border);
    border-radius: 9px; font-family: 'Tajawal', sans-serif;
    font-size: 12px; font-weight: 700; color: var(--muted);
    cursor: pointer; transition: all 0.15s;
}
.pay-btn.active { border-color: var(--red); background: var(--red-bg); color: var(--red); }
.pay-btn:hover  { border-color: var(--red); }

.order-actions { display: flex; gap: 8px; margin-top: 8px; }

.empty-state {
    display: flex; flex-direction: column; align-items: center;
    justify-content: center; height: 100%; color: #ccc; gap: 8px;
    padding: 40px 0;
}
.empty-state-icon { font-size: 52px; }

/* ══════════════════ RECEIPT MODAL ══════════════════ */
.divider { border: none; border-top: 1.5px dashed var(--border); margin: 12px 0; }
.receipt-line {
    display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 7px;
}
.receipt-line.total { font-size: 18px; font-weight: 900; color: var(--red); }

/* ══════════════════ KITCHEN ══════════════════ */
.kds-layout { max-width: 100%; }
.kds-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 16px;
}
.kds-card {
    background: #fff; border: 1.5px solid var(--border);
    border-radius: 16px; overflow: hidden; box-shadow: var(--shadow);
}
.kds-card.status-new      { border-color: #c0d0ff; }
.kds-card.status-preparing{ border-color: var(--orange-border); }
.kds-card.status-ready    { border-color: var(--green-border); }

.kds-header {
    padding: 14px 18px; display: flex; justify-content: space-between; align-items: center;
}
.kds-header.status-new      { background: var(--blue-bg); border-bottom: 1.5px solid #c0d0ff; }
.kds-header.status-preparing{ background: var(--orange-bg); border-bottom: 1.5px solid var(--orange-border); }
.kds-header.status-ready    { background: var(--green-bg); border-bottom: 1.5px solid var(--green-border); }

.kds-table { font-size: 17px; font-weight: 800; }
.kds-time  { font-size: 11px; color: var(--muted); margin-top: 2px; }

.kds-body { padding: 12px 18px; }
.kds-item {
    display: flex; align-items: center; gap: 8px;
    padding: 6px 0; border-bottom: 1px solid #f5f5f5; font-size: 13px;
}
.kds-item:last-child { border-bottom: none; }
.kds-qty {
    background: var(--red); color: #fff;
    border-radius: 6px; padding: 2px 9px; font-size: 12px; font-weight: 800;
}

.kds-actions { display: flex; gap: 8px; padding: 12px 18px; border-top: 1.5px solid #f0f0f2; }
.kds-btn {
    flex: 1; padding: 10px; border-radius: 9px;
    border: 1.5px solid var(--border); background: #fff;
    font-family: 'Tajawal', sans-serif; font-size: 13px; font-weight: 700;
    color: #888; cursor: pointer; transition: all 0.15s;
}
.kds-btn.prepare.active { background: var(--orange-bg); border-color: var(--orange); color: var(--orange); }
.kds-btn.ready.active   { background: var(--green-bg);  border-color: var(--green);  color: var(--green);  }
.kds-btn:hover          { border-color: var(--red); color: var(--red); }

/* ══════════════════ INVENTORY ══════════════════ */
.inv-layout { max-width: 100%; }
.inv-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }

/* ══════════════════ REPORTS ══════════════════ */
.reports-layout { max-width: 100%; }
.chart-bar-wrap {
    display: flex; align-items: flex-end; gap: 6px; height: 150px; padding: 10px 0;
    overflow-x: auto;
}
.chart-bar-col  { display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 40px; }
.chart-val      { font-size: 10px; color: var(--muted); font-weight: 700; }
.chart-bar      { width: 32px; background: var(--red); border-radius: 4px 4px 0 0; min-height: 4px; transition: height 0.4s; }
.chart-label    { font-size: 10px; color: var(--muted); white-space: nowrap; }

/* ══════════════════ ADMIN ══════════════════ */
.admin-layout { max-width: 100%; }
.admin-grid   { display: grid; gap: 20px; }

/* ══ ANIMATIONS ══ */
@keyframes popIn {
    from { opacity: 0; transform: scale(0.88); }
    to   { opacity: 1; transform: scale(1); }
}
@keyframes fadeUp {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ══ SCROLLBAR ══ */
::-webkit-scrollbar       { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: #f0f0f2; }
::-webkit-scrollbar-thumb { background: var(--red); border-radius: 4px; }
