/* ============================================================
   Stage Café — Operations System
   Visual identity: warm ivory + espresso brown + limited copper accents.
   ============================================================ */

@font-face {
  font-family: 'Plex Arabic';
  font-style: normal;
  font-weight: 300;
  font-display: swap;
  src: url('../fonts/plex-arabic-300-arabic.woff2') format('woff2');
  unicode-range: U+0600-06FF, U+0750-077F, U+FB50-FDFF, U+FE70-FEFC;
}
@font-face {
  font-family: 'Plex Arabic';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('../fonts/plex-arabic-400-arabic.woff2') format('woff2');
  unicode-range: U+0600-06FF, U+0750-077F, U+FB50-FDFF, U+FE70-FEFC;
}
@font-face {
  font-family: 'Plex Arabic';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('../fonts/plex-arabic-500-arabic.woff2') format('woff2');
  unicode-range: U+0600-06FF, U+0750-077F, U+FB50-FDFF, U+FE70-FEFC;
}
@font-face {
  font-family: 'Plex Arabic';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('../fonts/plex-arabic-600-arabic.woff2') format('woff2');
  unicode-range: U+0600-06FF, U+0750-077F, U+FB50-FDFF, U+FE70-FEFC;
}
@font-face {
  font-family: 'Plex Arabic';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('../fonts/plex-arabic-700-arabic.woff2') format('woff2');
  unicode-range: U+0600-06FF, U+0750-077F, U+FB50-FDFF, U+FE70-FEFC;
}
@font-face {
  font-family: 'Plex Arabic';
  font-style: normal;
  font-weight: 300;
  font-display: swap;
  src: url('../fonts/plex-arabic-300-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF;
}
@font-face {
  font-family: 'Plex Arabic';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('../fonts/plex-arabic-400-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF;
}
@font-face {
  font-family: 'Plex Arabic';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('../fonts/plex-arabic-500-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF;
}
@font-face {
  font-family: 'Plex Arabic';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('../fonts/plex-arabic-600-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF;
}
@font-face {
  font-family: 'Plex Arabic';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('../fonts/plex-arabic-700-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF;
}

:root {
  /* --- Brand palette --- */
  --ivory: #FAF6EE;
  --ivory-deep: #F1E9D8;
  --surface: #FFFFFF;
  --espresso-900: #2B1F17;
  --espresso-800: #3B2A1F;
  --espresso-700: #4E3A29;
  --espresso-500: #7A6350;
  --espresso-300: #B7A491;
  --espresso-100: #E6DCCC;
  --copper-600: #A9662F;
  --copper-500: #BE7A3E;
  --copper-100: #F1DCC3;
  --line: #E3D8C4;
  --line-strong: #D2C3A8;

  /* --- Semantic status colors (muted, harmonized with the warm base) --- */
  --status-available: #4B7A5B;
  --status-available-bg: #E7F0E5;
  --status-occupied: #A63C36;
  --status-occupied-bg: #F5E3DF;
  --status-ending: #B8722A;
  --status-ending-bg: #F5E7D5;
  --status-overtime: #6A4A82;
  --status-overtime-bg: #EBE2F0;
  --status-cleaning: #A98A2A;
  --status-cleaning-bg: #F4EDD6;
  --status-reserved: #3D6A88;
  --status-reserved-bg: #E1EBF0;
  --status-off: #7A7570;
  --status-off-bg: #EAE7E2;

  --danger: #A6342C;
  --danger-bg: #F5E1DE;
  --success: #4B7A5B;

  /* --- Type scale --- */
  --font-family: 'Plex Arabic', 'Segoe UI', Tahoma, sans-serif;
  --text-xs: 0.75rem;
  --text-sm: 0.8125rem;
  --text-base: 0.9375rem;
  --text-md: 1.0625rem;
  --text-lg: 1.25rem;
  --text-xl: 1.625rem;
  --text-2xl: 2.1rem;

  /* --- Spacing --- */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 24px;
  --sp-6: 32px;
  --sp-7: 48px;
  --sp-8: 64px;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --shadow-card: 0 1px 2px rgba(43, 31, 23, 0.06), 0 4px 16px rgba(43, 31, 23, 0.05);
  --shadow-pop: 0 8px 32px rgba(43, 31, 23, 0.16);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font-family);
  font-size: var(--text-base);
  color: var(--espresso-900);
  background: var(--ivory);
  line-height: 1.65;
  direction: rtl;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { font-weight: 600; color: var(--espresso-900); margin: 0 0 var(--sp-2); letter-spacing: -0.01em; }
h1 { font-size: var(--text-2xl); font-weight: 700; }
h2 { font-size: var(--text-xl); }
h3 { font-size: var(--text-lg); }
h4 { font-size: var(--text-md); }
p { margin: 0 0 var(--sp-3); color: var(--espresso-700); }
a { color: var(--copper-600); text-decoration: none; }
a:hover { text-decoration: underline; }
small, .muted { color: var(--espresso-500); font-size: var(--text-sm); }

/* ---------------- Layout shell ---------------- */

.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 232px;
  flex-shrink: 0;
  background: var(--espresso-900);
  color: var(--ivory);
  display: flex;
  flex-direction: column;
  padding: var(--sp-5) var(--sp-4);
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand-mark {
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--ivory);
  letter-spacing: 0.02em;
  margin-bottom: var(--sp-1);
}
.brand-sub {
  font-size: var(--text-xs);
  color: var(--espresso-300);
  margin-bottom: var(--sp-6);
  display: block;
}

.nav-group { margin-bottom: var(--sp-5); }
.nav-group-label {
  font-size: var(--text-xs);
  color: var(--espresso-300);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: var(--sp-2);
  padding: 0 var(--sp-3);
}
.nav-link {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--radius-sm);
  color: var(--ivory-deep);
  font-size: var(--text-sm);
  font-weight: 500;
  margin-bottom: 2px;
  transition: background 0.15s ease;
}
.nav-link:hover { background: rgba(255,255,255,0.06); text-decoration: none; }
.nav-link.active { background: var(--copper-600); color: #fff; }

.sidebar-footer {
  margin-top: auto;
  padding-top: var(--sp-4);
  border-top: 1px solid rgba(255,255,255,0.1);
  font-size: var(--text-xs);
  color: var(--espresso-300);
}

.main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-4) var(--sp-6);
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
}

.topbar-title { font-size: var(--text-lg); font-weight: 600; }
.topbar-actions { display: flex; align-items: center; gap: var(--sp-3); }

.content { padding: var(--sp-6); flex: 1; }

.mobile-topbar { display: none; }

/* ---------------- Buttons ---------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 0.6rem 1.1rem;
  font-family: inherit;
  font-size: var(--text-sm);
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.08s ease, background 0.15s ease, border-color 0.15s ease;
  line-height: 1.2;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--espresso-800); color: #fff; }
.btn-primary:hover { background: var(--espresso-900); text-decoration: none; }
.btn-accent { background: var(--copper-600); color: #fff; }
.btn-accent:hover { background: var(--copper-500); text-decoration: none; }
.btn-secondary { background: var(--surface); color: var(--espresso-800); border-color: var(--line-strong); }
.btn-secondary:hover { background: var(--ivory-deep); text-decoration: none; }
.btn-ghost { background: transparent; color: var(--espresso-700); }
.btn-ghost:hover { background: var(--ivory-deep); text-decoration: none; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #8c2c25; text-decoration: none; }
.btn-sm { padding: 0.4rem 0.75rem; font-size: var(--text-xs); }
.btn-lg { padding: 0.85rem 1.5rem; font-size: var(--text-md); }
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-icon { width: 36px; height: 36px; padding: 0; border-radius: 50%; }

/* ---------------- Forms ---------------- */

.field { margin-bottom: var(--sp-4); }
.field label {
  display: block;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--espresso-800);
  margin-bottom: var(--sp-1);
}
.field .hint { font-size: var(--text-xs); color: var(--espresso-500); margin-top: 4px; }
.field .error { font-size: var(--text-xs); color: var(--danger); margin-top: 4px; }

input[type=text], input[type=password], input[type=email], input[type=tel],
input[type=number], input[type=date], input[type=time], input[type=datetime-local],
select, textarea {
  width: 100%;
  font-family: inherit;
  font-size: var(--text-base);
  color: var(--espresso-900);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 0.65rem 0.85rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
textarea { resize: vertical; min-height: 90px; }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--copper-500);
  box-shadow: 0 0 0 3px var(--copper-100);
}
.checkbox-row { display: flex; align-items: center; gap: var(--sp-2); }
.checkbox-row input { width: auto; }

.form-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: var(--sp-6);
  max-width: 460px;
  box-shadow: var(--shadow-card);
}

/* ---------------- Auth screens ---------------- */

.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(180deg, var(--ivory) 0%, var(--ivory-deep) 100%);
  padding: var(--sp-5);
  position: relative;
  overflow: hidden;
}
.auth-bg-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: 0;
}
.auth-bg-overlay {
  position: absolute;
  inset: 0;
  background: rgba(20, 14, 10, 0.5);
  z-index: 1;
}
.auth-box { position: relative; z-index: 2; width: 100%; max-width: 400px; }
.auth-bg-play {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 1;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.8);
  background: rgba(0,0,0,0.35);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.auth-bg-play:hover { background: rgba(0,0,0,0.55); }
.auth-brand { text-align: center; margin-bottom: var(--sp-6); }
.auth-brand .name { font-size: var(--text-2xl); font-weight: 700; color: var(--espresso-900); }
.auth-brand .company { font-size: var(--text-sm); color: var(--espresso-500); margin-top: 2px; }
.auth-brand .rule { width: 40px; height: 3px; background: var(--copper-600); margin: var(--sp-3) auto 0; border-radius: 2px; }
.has-video-bg .auth-brand .name { color: #fff; }
.has-video-bg .auth-brand .company { color: rgba(255,255,255,0.85); }

/* ---------------- Cards / KPI (used sparingly, not for everything) ---------------- */

.kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--sp-4);
  margin-bottom: var(--sp-6);
}
.kpi-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: var(--sp-4) var(--sp-5);
  border-inline-start: 3px solid var(--copper-500);
}
.kpi-card .kpi-value { font-size: var(--text-2xl); font-weight: 700; color: var(--espresso-900); line-height: 1; }
.kpi-card .kpi-label { font-size: var(--text-sm); color: var(--espresso-500); margin-top: var(--sp-2); }
.kpi-card.alert { border-inline-start-color: var(--danger); }
.kpi-card.alert .kpi-value { color: var(--danger); }

/* ---------------- Data tables (used for lists — not everything is a card) ---------------- */

.data-table-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); overflow: hidden; box-shadow: var(--shadow-card); }
table.data-table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
table.data-table th {
  text-align: right;
  padding: var(--sp-3) var(--sp-4);
  background: var(--ivory-deep);
  color: var(--espresso-700);
  font-weight: 600;
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
table.data-table td {
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--line);
  color: var(--espresso-800);
  vertical-align: middle;
}
table.data-table tr:last-child td { border-bottom: none; }
table.data-table tbody tr:hover { background: var(--ivory); }
.table-toolbar { display: flex; flex-wrap: wrap; gap: var(--sp-3); align-items: center; padding: var(--sp-4); border-bottom: 1px solid var(--line); background: var(--surface); }
.table-toolbar select, .table-toolbar input { width: auto; min-width: 150px; }

/* ---------------- Task list (distinct from data table — a checklist feel) ---------------- */

.task-list { display: flex; flex-direction: column; gap: var(--sp-3); }
.task-item {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-4);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: var(--sp-4);
  transition: border-color 0.15s ease;
}
.task-item.is-overdue { border-color: var(--danger); background: var(--danger-bg); }
.task-item.is-completed { opacity: 0.65; }
.task-check {
  width: 26px; height: 26px; border-radius: 50%;
  border: 2px solid var(--line-strong);
  flex-shrink: 0; margin-top: 2px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; background: var(--surface);
  transition: all 0.15s ease;
}
.task-check.checked { background: var(--success); border-color: var(--success); }
.task-check.checked::after { content: '✓'; color: #fff; font-size: 14px; font-weight: 700; }
.task-body { flex: 1; min-width: 0; }
.task-title { font-weight: 600; font-size: var(--text-md); color: var(--espresso-900); }
.task-meta { display: flex; flex-wrap: wrap; gap: var(--sp-3); margin-top: var(--sp-1); font-size: var(--text-xs); color: var(--espresso-500); }
.task-desc { margin-top: var(--sp-2); font-size: var(--text-sm); color: var(--espresso-700); }
.task-actions { display: flex; gap: var(--sp-2); flex-shrink: 0; }

/* ---------------- Status pills ---------------- */

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: var(--text-xs);
  font-weight: 600;
}
.pill::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.pill-new { background: var(--copper-100); color: var(--copper-600); }
.pill-in_progress { background: var(--status-reserved-bg); color: var(--status-reserved); }
.pill-completed { background: var(--status-available-bg); color: var(--status-available); }
.pill-overdue { background: var(--status-occupied-bg); color: var(--status-occupied); }
.pill-available { background: var(--status-available-bg); color: var(--status-available); }
.pill-occupied { background: var(--status-occupied-bg); color: var(--status-occupied); }
.pill-ending_soon { background: var(--status-ending-bg); color: var(--status-ending); }
.pill-overtime { background: var(--status-overtime-bg); color: var(--status-overtime); }
.pill-needs_cleaning { background: var(--status-cleaning-bg); color: var(--status-cleaning); }
.pill-reserved { background: var(--status-reserved-bg); color: var(--status-reserved); }
.pill-out_of_service { background: var(--status-off-bg); color: var(--status-off); }

/* ---------------- Status legend ---------------- */

.legend { display: flex; flex-wrap: wrap; gap: var(--sp-4); padding: var(--sp-3) 0; }
.legend-item { display: flex; align-items: center; gap: 6px; font-size: var(--text-xs); color: var(--espresso-700); }
.legend-dot { width: 10px; height: 10px; border-radius: 50%; }

/* ---------------- Flash / toast ---------------- */

.flash-stack { position: fixed; top: var(--sp-5); left: 50%; transform: translateX(-50%); z-index: 100; display: flex; flex-direction: column; gap: var(--sp-2); width: min(92vw, 420px); }
.flash {
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: 500;
  box-shadow: var(--shadow-pop);
  animation: flash-in 0.2s ease;
}
.flash-success { background: var(--status-available); color: #fff; }
.flash-error { background: var(--danger); color: #fff; }
.flash-info { background: var(--espresso-800); color: #fff; }
@keyframes flash-in { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }

/* ---------------- Empty state ---------------- */
.empty-state { text-align: center; padding: var(--sp-8) var(--sp-4); color: var(--espresso-500); }
.empty-state h3 { color: var(--espresso-700); }

/* ---------------- Modal ---------------- */
.modal-overlay { position: fixed; inset: 0; background: rgba(43,31,23,0.45); display: none; align-items: center; justify-content: center; z-index: 200; padding: var(--sp-4); }
.modal-overlay.open { display: flex; }
.modal-box { background: var(--surface); border-radius: var(--radius-lg); padding: var(--sp-5); width: 100%; max-width: 480px; box-shadow: var(--shadow-pop); max-height: 90vh; overflow-y: auto; }
.modal-box h3 { margin-bottom: var(--sp-4); }
.modal-actions { display: flex; justify-content: flex-end; gap: var(--sp-2); margin-top: var(--sp-5); }

/* ---------------- Floor plan (Phase 2) ---------------- */
.floor-plan { position: relative; background: var(--ivory-deep); border: 1px solid var(--line); border-radius: var(--radius-lg); overflow: auto; min-height: 520px; }
.floor-table {
  position: absolute;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  border-radius: var(--radius-sm);
  border: 2px solid transparent;
  cursor: pointer;
  color: #fff;
  font-weight: 700;
  box-shadow: 0 2px 6px rgba(43,31,23,0.15);
  transition: transform 0.1s ease;
  text-align: center;
  padding: 4px;
}
.floor-table:hover { transform: scale(1.03); }
.floor-table .t-label { font-size: var(--text-md); }
.floor-table .t-seats { font-size: var(--text-xs); opacity: 0.85; font-weight: 500; }
.floor-table .t-timer { font-size: var(--text-xs); font-weight: 600; margin-top: 2px; }
.floor-table.round { border-radius: 50%; }
.floor-table.status-available { background: var(--status-available); }
.floor-table.status-occupied { background: var(--status-occupied); }
.floor-table.status-ending_soon { background: var(--status-ending); }
.floor-table.status-overtime { background: var(--status-overtime); }
.floor-table.status-needs_cleaning { background: var(--status-cleaning); color: var(--espresso-900); }
.floor-table.status-reserved { background: var(--status-reserved); }
.floor-table.status-out_of_service { background: var(--status-off); }

/* ---------------- Utilities ---------------- */
.stack { display: flex; flex-direction: column; gap: var(--sp-3); }
.row { display: flex; align-items: center; gap: var(--sp-3); }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); }
.section { margin-bottom: var(--sp-7); }
.section-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--sp-4); }
.text-danger { color: var(--danger); }
.text-muted { color: var(--espresso-500); }
.badge-count { background: var(--danger); color: #fff; font-size: 10px; font-weight: 700; min-width: 16px; height: 16px; border-radius: 999px; display: inline-flex; align-items: center; justify-content: center; padding: 0 4px; }

/* ---------------- Responsive ---------------- */

@media (max-width: 900px) {
  .sidebar { display: none; }
  .app-shell { flex-direction: column; }
  .mobile-topbar {
    display: flex; align-items: center; justify-content: space-between;
    padding: var(--sp-3) var(--sp-4);
    background: var(--espresso-900); color: var(--ivory);
    position: sticky; top: 0; z-index: 30;
  }
  .mobile-topbar .brand-mark { font-size: var(--text-md); margin-bottom: 0; color: #fff; }
  .content { padding: var(--sp-4); }
  .topbar { padding: var(--sp-3) var(--sp-4); }
  .kpi-row { grid-template-columns: repeat(2, 1fr); }
  .form-card { padding: var(--sp-4); }
  .task-item { flex-direction: column; }
  .task-actions { width: 100%; }
  .task-actions .btn { flex: 1; }
  table.data-table { font-size: var(--text-xs); }
  .bottom-nav {
    display: flex; position: fixed; bottom: 0; inset-inline: 0; z-index: 30;
    background: var(--surface); border-top: 1px solid var(--line);
    padding: 6px var(--sp-2); justify-content: space-around;
  }
  .bottom-nav a { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 10px; color: var(--espresso-500); flex: 1; padding: 6px 0; }
  .bottom-nav a.active { color: var(--copper-600); }
  body { padding-bottom: 64px; }
}
@media (min-width: 901px) {
  .bottom-nav { display: none; }
}
