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

:root {
  --blue-900: #0D47A1; --blue-800: #1565C0; --blue-700: #1976D2;
  --blue-100: #BBDEFB; --blue-50: #E3F2FD;
  --orange-900: #E65100; --orange-700: #F57C00; --orange-500: #FF6F00;
  --orange-300: #FFB74D; --orange-50: #FFF3E0;
  --success: #2E7D32; --danger: #C62828; --warn: #F57F17;
  --gray-900: #212121; --gray-700: #424242; --gray-500: #9E9E9E;
  --gray-200: #EEEEEE; --gray-100: #F5F5F5; --white: #FFFFFF;
  --sidebar-w: 260px; --topbar-h: 64px;
  --radius: 12px; --radius-sm: 8px;
  --shadow: 0 2px 12px rgba(21,101,192,.10);
  --shadow-md: 0 4px 24px rgba(21,101,192,.15);
  --shadow-lg: 0 8px 40px rgba(21,101,192,.18);
  --t: .2s cubic-bezier(.4,0,.2,1);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; direction: rtl; scroll-behavior: smooth; }
body { font-family: 'Cairo','Tajawal',sans-serif; background: #F0F4FA; color: var(--gray-900); min-height: 100vh; display: flex; overflow-x: hidden; }
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--gray-100); }
::-webkit-scrollbar-thumb { background: var(--blue-700); border-radius: 3px; }

/* ── Sidebar ── */
.sidebar { width: var(--sidebar-w); min-height: 100vh; background: linear-gradient(180deg,var(--blue-900) 0%,var(--blue-800) 60%,#0a3880 100%); position: fixed; right: 0; top: 0; z-index: 100; display: flex; flex-direction: column; box-shadow: -4px 0 20px rgba(0,0,0,.2); transition: transform var(--t); }
.sidebar-brand { padding: 20px 18px; border-bottom: 1px solid rgba(255,255,255,.1); display: flex; align-items: center; gap: 12px; }
.brand-logo { width: 44px; height: 44px; background: var(--orange-500); border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 22px; box-shadow: 0 4px 12px rgba(255,111,0,.4); flex-shrink: 0; }
.sidebar-logo-img { width: 44px; height: 44px; border-radius: 50%; object-fit: cover; flex-shrink: 0; box-shadow: 0 4px 12px rgba(0,0,0,.3); }
.brand-text { color: #fff; }
.brand-text .name { font-size: 15px; font-weight: 700; line-height: 1.2; }
.brand-text .tagline { font-size: 11px; opacity: .65; }
.sidebar-nav { flex: 1; padding: 12px 0; overflow-y: auto; }
.nav-section-label { font-size: 10px; font-weight: 700; letter-spacing: .1em; color: rgba(255,255,255,.4); text-transform: uppercase; padding: 16px 18px 6px; }
.nav-link { display: flex; align-items: center; gap: 12px; padding: 11px 18px; color: rgba(255,255,255,.75); text-decoration: none; transition: all var(--t); font-size: 14px; font-weight: 500; }
.nav-link:hover { background: rgba(255,255,255,.1); color: #fff; padding-right: 24px; }
.nav-link.active { background: rgba(255,111,0,.2); color: #fff; border-left: 3px solid var(--orange-500); }
.nav-link .icon { width: 32px; height: 32px; background: rgba(255,255,255,.08); border-radius: 8px; display: flex; align-items: center; justify-content: center; font-size: 16px; flex-shrink: 0; transition: background var(--t); }
.nav-link.active .icon, .nav-link:hover .icon { background: rgba(255,111,0,.3); }
.nav-link .nbadge { margin-right: auto; background: var(--orange-500); color: #fff; font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 20px; }
.sidebar-footer { padding: 16px 18px; border-top: 1px solid rgba(255,255,255,.1); }
.user-card { display: flex; align-items: center; gap: 10px; background: rgba(255,255,255,.08); border-radius: 10px; padding: 10px 12px; }
.user-avatar { width: 36px; height: 36px; background: var(--orange-500); border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 14px; font-weight: 700; color: #fff; flex-shrink: 0; }
.user-info { flex: 1; min-width: 0; }
.user-info .uname { font-size: 13px; font-weight: 600; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-info .urole { font-size: 11px; color: rgba(255,255,255,.5); }
.btn-logout { background: transparent; border: none; cursor: pointer; color: rgba(255,255,255,.5); font-size: 18px; padding: 4px; border-radius: 6px; transition: color var(--t); }
.btn-logout:hover { color: var(--orange-300); }

/* ── Layout ── */
.main-content { margin-right: var(--sidebar-w); flex: 1; min-height: 100vh; display: flex; flex-direction: column; }
.topbar { height: var(--topbar-h); background: var(--white); border-bottom: 1px solid var(--gray-200); display: flex; align-items: center; padding: 0 28px; gap: 16px; position: sticky; top: 0; z-index: 50; box-shadow: var(--shadow); }
.topbar-title { font-size: 18px; font-weight: 700; color: var(--blue-800); flex: 1; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.icon-btn { width: 38px; height: 38px; background: var(--gray-100); border: none; border-radius: 10px; cursor: pointer; font-size: 18px; display: flex; align-items: center; justify-content: center; position: relative; transition: all var(--t); color: var(--gray-700); }
.icon-btn:hover { background: var(--blue-50); color: var(--blue-800); }
.icon-btn .dot { position: absolute; top: 6px; right: 6px; width: 8px; height: 8px; background: var(--orange-500); border-radius: 50%; border: 2px solid var(--white); }
.page-body { padding: 28px; flex: 1; }

/* ── Cards ── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit,minmax(200px,1fr)); gap: 18px; margin-bottom: 28px; }
.stat-card { background: var(--white); border-radius: var(--radius); padding: 22px 20px; box-shadow: var(--shadow); display: flex; align-items: center; gap: 16px; transition: transform var(--t),box-shadow var(--t); position: relative; overflow: hidden; }
.stat-card::after { content: ''; position: absolute; top: 0; right: 0; width: 4px; height: 100%; }
.stat-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }
.stat-card.blue::after { background: var(--blue-800); } .stat-card.orange::after { background: var(--orange-500); } .stat-card.green::after { background: var(--success); } .stat-card.red::after { background: var(--danger); }
.stat-icon { width: 52px; height: 52px; border-radius: 14px; display: flex; align-items: center; justify-content: center; font-size: 24px; flex-shrink: 0; }
.stat-card.blue .stat-icon { background: var(--blue-50); } .stat-card.orange .stat-icon { background: var(--orange-50); } .stat-card.green .stat-icon { background: #E8F5E9; } .stat-card.red .stat-icon { background: #FFEBEE; }
.stat-info .label { font-size: 12px; color: var(--gray-500); font-weight: 500; }
.stat-info .value { font-size: 26px; font-weight: 900; color: var(--gray-900); line-height: 1.2; }
.stat-info .sub { font-size: 11px; color: var(--gray-500); margin-top: 2px; }
.card { background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.card-header { padding: 18px 22px; border-bottom: 1px solid var(--gray-200); display: flex; align-items: center; gap: 12px; }
.card-header h3 { font-size: 15px; font-weight: 700; color: var(--gray-900); flex: 1; }
.card-body { padding: 22px; }

/* ── Table ── */
.tbl-wrap { overflow-x: auto; }
table.data-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.data-table th { background: var(--gray-100); padding: 12px 16px; text-align: right; font-weight: 700; font-size: 12px; color: var(--gray-700); white-space: nowrap; border-bottom: 2px solid var(--gray-200); }
.data-table td { padding: 13px 16px; border-bottom: 1px solid var(--gray-200); vertical-align: middle; }
.data-table tbody tr:hover { background: var(--blue-50); }
.data-table tbody tr:last-child td { border-bottom: none; }

/* ── Badges ── */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: 20px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge-pending { background: #FFF8E1; color: #F57F17; }
.badge-confirmed { background: var(--blue-50); color: var(--blue-800); }
.badge-preparing { background: #FFF3E0; color: var(--orange-700); }
.badge-ready { background: #E8F5E9; color: #1B5E20; }
.badge-on_way { background: #E3F2FD; color: #0D47A1; }
.badge-delivered { background: #E8F5E9; color: var(--success); }
.badge-cancelled { background: #FFEBEE; color: var(--danger); }
.badge-free { background: #E8F5E9; color: var(--success); }
.badge-occupied { background: #FFEBEE; color: var(--danger); }
.badge-reserved { background: #FFF3E0; color: var(--orange-700); }
.badge-available { background: #E8F5E9; color: var(--success); }
.badge-busy { background: #FFEBEE; color: var(--danger); }
.badge-offline { background: var(--gray-200); color: var(--gray-500); }
.badge-dine_in { background: var(--blue-50); color: var(--blue-800); }
.badge-takeaway { background: #FFF3E0; color: var(--orange-700); }
.badge-delivery { background: #E8F5E9; color: var(--success); }

/* ── Buttons ── */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 9px 18px; border-radius: var(--radius-sm); font-family: inherit; font-size: 13.5px; font-weight: 600; border: 2px solid transparent; cursor: pointer; transition: all var(--t); white-space: nowrap; text-decoration: none; }
.btn-primary { background: var(--blue-800); color: #fff; border-color: var(--blue-800); }
.btn-primary:hover { background: var(--blue-900); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(21,101,192,.35); }
.btn-accent { background: var(--orange-500); color: #fff; border-color: var(--orange-500); }
.btn-accent:hover { background: var(--orange-700); transform: translateY(-1px); }
.btn-success { background: var(--success); color: #fff; border-color: var(--success); }
.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-outline { background: transparent; color: var(--blue-800); border-color: var(--blue-800); }
.btn-outline:hover { background: var(--blue-50); }
.btn-ghost { background: transparent; color: var(--gray-700); border-color: transparent; }
.btn-ghost:hover { background: var(--gray-100); }
.btn-sm { padding: 5px 12px; font-size: 12px; }
.btn-warn { background: var(--warn); color: #fff; border-color: var(--warn); }

/* ── Forms ── */
.form-group { margin-bottom: 18px; }
.form-label { display: block; font-size: 13px; font-weight: 600; color: var(--gray-700); margin-bottom: 6px; }
.form-control { width: 100%; padding: 10px 14px; border: 2px solid var(--gray-200); border-radius: var(--radius-sm); font-family: inherit; font-size: 14px; color: var(--gray-900); background: var(--white); transition: border-color var(--t),box-shadow var(--t); outline: none; }
.form-control:focus { border-color: var(--blue-700); box-shadow: 0 0 0 3px rgba(21,101,192,.12); }
.form-control::placeholder { color: var(--gray-500); }
select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 90px; }

/* ── Alert ── */
.alert { padding: 12px 16px; border-radius: var(--radius-sm); font-size: 14px; margin-bottom: 16px; display: flex; align-items: center; gap: 10px; border-right: 4px solid; }
.alert-success { background: #E8F5E9; color: #1B5E20; border-color: var(--success); }
.alert-error { background: #FFEBEE; color: var(--danger); border-color: var(--danger); }
.alert-info { background: var(--blue-50); color: var(--blue-900); border-color: var(--blue-700); }

/* ── Modal ── */
.modal-overlay { position: fixed; inset: 0; z-index: 200; background: rgba(0,0,0,.5); display: flex; align-items: center; justify-content: center; padding: 20px; opacity: 0; pointer-events: none; transition: opacity var(--t); }
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal { background: var(--white); border-radius: var(--radius); width: 100%; max-width: 540px; max-height: 90vh; overflow-y: auto; box-shadow: var(--shadow-lg); transform: scale(.95); transition: transform var(--t); }
.modal-overlay.open .modal { transform: scale(1); }
.modal-header { padding: 18px 22px; border-bottom: 1px solid var(--gray-200); display: flex; align-items: center; gap: 12px; position: sticky; top: 0; background: var(--white); z-index: 1; }
.modal-header h3 { flex: 1; font-size: 16px; font-weight: 700; }
.modal-close { background: none; border: none; cursor: pointer; font-size: 20px; color: var(--gray-500); width: 32px; height: 32px; border-radius: 8px; display: flex; align-items: center; justify-content: center; transition: background var(--t); }
.modal-close:hover { background: var(--gray-100); color: var(--danger); }
.modal-body { padding: 22px; }
.modal-footer { padding: 16px 22px; border-top: 1px solid var(--gray-200); display: flex; gap: 10px; justify-content: flex-end; }

/* ── POS ── */
.pos-layout { display: grid; grid-template-columns: 1fr 380px; gap: 20px; height: calc(100vh - var(--topbar-h) - 56px); }
.pos-menu { display: flex; flex-direction: column; overflow: hidden; }
.category-tabs { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 12px; flex-shrink: 0; }
.category-tabs::-webkit-scrollbar { height: 3px; }
.cat-tab { display: flex; align-items: center; gap: 6px; padding: 8px 16px; border-radius: 30px; background: var(--white); border: 2px solid var(--gray-200); font-size: 13px; font-weight: 600; cursor: pointer; white-space: nowrap; transition: all var(--t); color: var(--gray-700); }
.cat-tab:hover, .cat-tab.active { background: var(--blue-800); color: #fff; border-color: var(--blue-800); }
.menu-search { position: relative; margin-bottom: 14px; flex-shrink: 0; }
.menu-search input { width: 100%; padding: 10px 14px 10px 40px; border: 2px solid var(--gray-200); border-radius: var(--radius-sm); font-family: inherit; font-size: 14px; outline: none; transition: border-color var(--t); direction: rtl; }
.menu-search input:focus { border-color: var(--blue-700); }
.menu-search .si { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--gray-500); font-size: 18px; }
.menu-items-grid { display: grid; grid-template-columns: repeat(auto-fill,minmax(140px,1fr)); gap: 10px; overflow-y: auto; flex: 1; padding-bottom: 8px; align-content: start; }
.menu-item-card { background: var(--white); border-radius: var(--radius); padding: 10px 8px; cursor: pointer; border: 2px solid transparent; transition: all var(--t); box-shadow: var(--shadow); text-align: center; aspect-ratio: 1/1; display: flex; flex-direction: column; justify-content: center; align-items: center; overflow: hidden; }
.menu-item-card:hover { border-color: var(--blue-700); transform: translateY(-2px); box-shadow: var(--shadow-md); }
.menu-item-card.unavail { opacity: .45; pointer-events: none; }
.item-emoji { font-size: 28px; margin-bottom: 5px; display: block; line-height: 1; }
.item-name { font-size: 12px; font-weight: 700; color: var(--gray-900); margin-bottom: 3px; line-height: 1.25; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-price { font-size: 13px; font-weight: 900; color: var(--orange-500); }
.order-panel { background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow); display: flex; flex-direction: column; overflow: hidden; }
.order-panel-header { background: linear-gradient(135deg,var(--blue-800),var(--blue-900)); color: #fff; padding: 12px 16px; display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.order-panel-header h3 { font-size: 14px; font-weight: 700; }
.invoice-tabs-bar { display: flex; align-items: center; gap: 4px; padding: 6px 8px; background: var(--gray-100); border-bottom: 1px solid var(--gray-200); overflow-x: auto; scrollbar-width: none; flex-shrink: 0; min-height: 42px; }
.invoice-tabs-bar::-webkit-scrollbar { display: none; }
.invoice-tab { display: flex; align-items: center; gap: 4px; padding: 4px 10px; background: var(--white); border: 1.5px solid var(--gray-300); border-radius: 6px; cursor: pointer; font-size: 12px; font-weight: 600; white-space: nowrap; transition: all .15s; color: var(--gray-700); user-select: none; }
.invoice-tab.active { background: var(--blue-800); border-color: var(--blue-800); color: #fff; }
.invoice-tab .inv-badge { background: var(--orange-500); color: #fff; border-radius: 10px; padding: 1px 6px; font-size: 10px; font-weight: 700; }
.invoice-tab.active .inv-badge { background: rgba(255,255,255,.3); }
.invoice-tab .tab-close { font-size: 10px; opacity: .55; padding: 0 2px; line-height: 1; }
.invoice-tab .tab-close:hover { opacity: 1; }
.btn-new-inv { flex-shrink: 0; width: 28px; height: 28px; border-radius: 50%; background: var(--blue-700); color: #fff; border: none; cursor: pointer; font-size: 18px; line-height: 1; display: flex; align-items: center; justify-content: center; margin-right: 2px; transition: background var(--t); }
.btn-new-inv:hover { background: var(--blue-800); }
.order-type-selector { display: grid; grid-template-columns: repeat(3,1fr); gap: 6px; padding: 12px; background: var(--gray-100); border-bottom: 1px solid var(--gray-200); }
.order-type-btn { padding: 8px 6px; border: 2px solid var(--gray-200); border-radius: var(--radius-sm); background: var(--white); font-family: inherit; font-size: 12px; font-weight: 600; cursor: pointer; text-align: center; transition: all var(--t); color: var(--gray-700); }
.order-type-btn.active { background: var(--blue-800); color: #fff; border-color: var(--blue-800); }
.cart-items { flex: 1; overflow-y: auto; padding: 8px; }
.cart-item { display: flex; align-items: center; gap: 8px; padding: 10px 6px; border-bottom: 1px solid var(--gray-200); }
.cart-item-name { flex: 1; font-size: 13px; font-weight: 600; }
.cart-item-price { font-size: 13px; font-weight: 700; color: var(--orange-500); white-space: nowrap; }
.cart-qty { display: flex; align-items: center; gap: 6px; }
.qty-btn { width: 26px; height: 26px; background: var(--gray-100); border: none; border-radius: 6px; cursor: pointer; font-size: 16px; font-weight: 700; color: var(--blue-800); transition: background var(--t); display: flex; align-items: center; justify-content: center; }
.qty-btn:hover { background: var(--blue-50); }
.qty-num { font-size: 14px; font-weight: 700; min-width: 20px; text-align: center; }
.cart-empty { text-align: center; padding: 40px 20px; color: var(--gray-500); }
.cart-empty-icon { font-size: 48px; margin-bottom: 12px; opacity: .4; }
.order-summary { padding: 14px 16px; border-top: 2px solid var(--gray-200); background: var(--gray-100); }
.summary-row { display: flex; justify-content: space-between; font-size: 13px; padding: 4px 0; color: var(--gray-700); }
.summary-row.total { font-size: 17px; font-weight: 900; color: var(--gray-900); padding-top: 10px; border-top: 1px solid var(--gray-300); margin-top: 6px; }
.total-amount { color: var(--orange-500); }
.checkout-btn { width: 100%; padding: 14px; background: linear-gradient(135deg,var(--orange-500),var(--orange-700)); color: #fff; border: none; border-radius: var(--radius-sm); font-family: inherit; font-size: 15px; font-weight: 700; cursor: pointer; transition: all var(--t); margin-top: 12px; }
.checkout-btn:hover { background: linear-gradient(135deg,var(--orange-700),var(--orange-900)); transform: translateY(-1px); box-shadow: 0 4px 16px rgba(255,111,0,.4); }
.checkout-btn:disabled { opacity: .5; pointer-events: none; }

/* ── Tables Grid ── */
.tables-grid { display: grid; grid-template-columns: repeat(auto-fill,minmax(130px,1fr)); gap: 14px; }
.table-card { background: var(--white); border-radius: var(--radius); padding: 20px 14px; text-align: center; box-shadow: var(--shadow); cursor: pointer; transition: all var(--t); border: 2px solid transparent; }
.table-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }
.table-card.free { border-color: #A5D6A7; }
.table-card.occupied { border-color: #EF9A9A; background: #FFF5F5; }
.table-card.reserved { border-color: #FFE082; background: #FFFDE7; }
.table-num { font-size: 28px; font-weight: 900; color: var(--blue-800); }
.table-cap { font-size: 12px; color: var(--gray-500); margin: 4px 0; }

/* ── Login ── */
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg,var(--blue-900) 0%,var(--blue-800) 50%,#0a3d8a 100%); padding: 20px; position: relative; overflow: hidden; }
.login-bg-shape { position: absolute; border-radius: 50%; background: rgba(255,255,255,.04); }
.login-card { background: var(--white); border-radius: 20px; padding: 40px 36px; width: 100%; max-width: 420px; box-shadow: 0 20px 60px rgba(0,0,0,.3); position: relative; z-index: 1; }
.login-logo { text-align: center; margin-bottom: 28px; }
.login-logo .logo-icon { width: 72px; height: 72px; background: linear-gradient(135deg,var(--orange-500),var(--orange-700)); border-radius: 20px; display: flex; align-items: center; justify-content: center; font-size: 36px; margin: 0 auto 12px; box-shadow: 0 8px 24px rgba(255,111,0,.35); }
.login-logo-img { width: 90px; height: 90px; border-radius: 50%; object-fit: cover; margin: 0 auto 14px; display: block; box-shadow: 0 8px 24px rgba(0,0,0,.18); }
.login-logo h1 { font-size: 22px; font-weight: 900; color: var(--blue-800); }
.login-logo p { font-size: 13px; color: var(--gray-500); margin-top: 4px; }

/* ── Toast ── */
.toast-container { position: fixed; top: 20px; left: 20px; z-index: 9999; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.toast { background: var(--white); border-radius: var(--radius-sm); padding: 12px 18px; box-shadow: var(--shadow-lg); border-right: 4px solid var(--blue-800); font-size: 14px; font-weight: 500; min-width: 240px; animation: slideIn .3s ease; pointer-events: all; }
.toast.success { border-color: var(--success); }
.toast.error { border-color: var(--danger); }
@keyframes slideIn { from { opacity:0; transform: translateX(-20px); } to { opacity:1; transform: translateX(0); } }

/* ── Utils ── */
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.flex { display: flex; align-items: center; }
.gap-8 { gap: 8px; } .gap-12 { gap: 12px; }
.mb-16 { margin-bottom: 16px; } .mb-24 { margin-bottom: 24px; } .mt-16 { margin-top: 16px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.text-muted { color: var(--gray-500); font-size: 13px; }
.text-orange { color: var(--orange-500); }
.fw-bold { font-weight: 700; } .fw-black { font-weight: 900; }
.spinner { width: 32px; height: 32px; border: 3px solid var(--gray-200); border-top-color: var(--blue-800); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media(max-width:900px) { .sidebar { transform: translateX(100%); } .sidebar.open { transform: translateX(0); } .main-content { margin-right: 0; } .pos-layout { grid-template-columns: 1fr; height: auto; } .grid-2 { grid-template-columns: 1fr; } }
