/* ===== IRATTAI PANAI – Shared Portal CSS Design System ===== */
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800;900&display=swap');

/* ─── CSS Variables ─── */
:root {
  --dark1: #0A0B0F;
  --dark2: #0F1117;
  --dark3: #161B26;
  --dark4: #1C2233;
  --surface: #1E2540;
  --border: rgba(255,255,255,0.06);
  --border2: rgba(255,255,255,0.1);

  --text: #C8CEDC;
  --text-muted: #7A8299;
  --text-dim: #4A5168;

  --success: #22C55E;
  --warning: #F59E0B;
  --danger:  #EF4444;
  --info:    #3B82F6;

  --sidebar-w: 240px;
  --topbar-h:  62px;

  /* KPI card accent */
  --kpi-color: #6C63FF;
}

/* ─── Reset ─── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: 'Outfit', system-ui, sans-serif;
  background: var(--dark1);
  color: var(--text);
  line-height: 1.5;
  overflow: hidden;
}
a { text-decoration: none; color: inherit; }

/* ─── Layout ─── */
.sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--sidebar-w);
  background: var(--dark2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: width 0.25s ease;
  z-index: 100;
}

.sidebar.collapsed { width: 62px; }

.main-wrapper {
  margin-left: var(--sidebar-w);
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: margin-left 0.25s ease;
}
.main-wrapper.expanded { margin-left: 62px; }

.content-area {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  scroll-behavior: smooth;
}

/* ─── Sidebar header ─── */
.sidebar-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 14px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.sidebar-logo {
  width: 36px; height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.sidebar-brand { overflow: hidden; flex: 1; min-width: 0; }
.sidebar-brand-name { font-size: 0.9rem; font-weight: 800; color: white; white-space: nowrap; }
.sidebar-brand-sub  { font-size: 0.65rem; color: var(--text-muted); white-space: nowrap; }

.sidebar-toggle {
  width: 24px; height: 24px;
  background: none;
  border: 1px solid var(--border2);
  border-radius: 6px;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.15s;
}
.sidebar-toggle:hover { background: var(--surface); color: white; }

/* ─── Nav ─── */
.nav-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
}

.nav-section { padding: 12px 0 4px; }
.nav-section-label {
  padding: 0 14px 6px;
  font-size: 0.6rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
}

.sidebar.collapsed .nav-section-label,
.sidebar.collapsed .nav-item-label,
.sidebar.collapsed .can-hide { display: none; }

.sidebar.collapsed .nav-badge { right: 4px; top: 4px; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  border-radius: 10px;
  margin: 1px 8px;
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-muted);
  transition: all 0.15s;
  position: relative;
  white-space: nowrap;
}

.nav-item:hover { background: var(--dark4); color: var(--text); }
.nav-item.active { background: rgba(108,99,255,0.12); color: white; font-weight: 600; }
.nav-item.active .nav-icon { color: #6C63FF; }

.nav-icon { display: flex; align-items: center; flex-shrink: 0; }

.nav-item-label { flex: 1; }

.nav-badge {
  background: #EF4444;
  color: white;
  font-size: 0.6rem;
  font-weight: 800;
  padding: 1px 5px;
  border-radius: 99px;
  min-width: 18px;
  text-align: center;
}

/* ─── Sidebar footer ─── */
.sidebar-footer {
  padding: 12px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.user-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 10px;
  background: var(--dark3);
}

.user-avatar {
  width: 32px; height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 800;
  flex-shrink: 0;
}

.user-info { flex: 1; min-width: 0; overflow: hidden; }
.user-name { font-size: 0.78rem; font-weight: 700; color: white; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 0.65rem; color: var(--text-muted); white-space: nowrap; }

/* ─── Topbar ─── */
.topbar {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 24px;
  background: var(--dark2);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-title  { font-size: 1rem; font-weight: 800; color: white; }
.topbar-subtitle { font-size: 0.7rem; color: var(--text-muted); }
.topbar-date { font-size: 0.75rem; color: var(--text-muted); font-weight: 500; }

.spacer { flex: 1; }

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.icon-btn {
  width: 34px; height: 34px;
  border-radius: 9px;
  border: 1px solid var(--border2);
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  position: relative;
}
.icon-btn:hover { background: var(--dark3); color: white; }

.notif-dot {
  position: absolute;
  top: 5px; right: 5px;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: #EF4444;
}

/* ─── Page views ─── */
.page-view { display: none; }
.page-view.active { display: block; }

/* ─── Cards ─── */
.card {
  background: var(--dark3);
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
}

.card-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}

.card-title {
  font-size: 0.82rem;
  font-weight: 700;
  color: white;
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
}

.card-body { padding: 16px 18px; }

/* ─── KPI Cards ─── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}

.kpi-card {
  background: var(--dark3);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px 16px;
  position: relative;
  overflow: hidden;
  transition: transform 0.2s, border-color 0.2s;
}

.kpi-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0;
  width: 4px; height: 100%;
  background: var(--kpi-color);
  border-radius: 0 2px 2px 0;
}

.kpi-card:hover { transform: translateY(-2px); border-color: var(--border2); }

.kpi-label { font-size: 0.7rem; font-weight: 600; color: var(--text-muted); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.06em; }
.kpi-value { font-size: 1.6rem; font-weight: 900; color: white; line-height: 1.1; }
.kpi-change { display: inline-flex; align-items: center; gap: 3px; font-size: 0.68rem; font-weight: 700; margin-top: 6px; }
.kpi-change.up   { color: var(--success); }
.kpi-change.down { color: var(--danger); }

/* ─── Grids ─── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.mb-24  { margin-bottom: 24px; }
.mb-16  { margin-bottom: 16px; }

/* ─── Tables ─── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead tr { background: var(--dark4); }
th {
  padding: 10px 16px;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  text-align: left;
  white-space: nowrap;
}
td {
  padding: 11px 16px;
  font-size: 0.8rem;
  color: var(--text);
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(255,255,255,0.015); }

/* ─── Badges ─── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 99px;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.badge-success { background: rgba(34,197,94,0.12); color: #22C55E; }
.badge-warning { background: rgba(245,158,11,0.12); color: #F59E0B; }
.badge-danger  { background: rgba(239,68,68,0.12);  color: #EF4444; }
.badge-info    { background: rgba(59,130,246,0.12);  color: #3B82F6; }
.badge-muted   { background: rgba(255,255,255,0.06); color: var(--text-muted); }
.badge-accent  { background: rgba(108,99,255,0.12);  color: #6C63FF; }
.badge-teal    { background: rgba(62,207,207,0.12);  color: #3ECFCF; }

/* ─── Buttons ─── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 9px;
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  border: none;
  transition: all 0.15s;
  white-space: nowrap;
}
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.btn-primary { background: #6C63FF; color: white; }
.btn-primary:hover:not(:disabled) { background: #5A52D5; transform: translateY(-1px); }

.btn-success { background: #22C55E; color: white; }
.btn-success:hover:not(:disabled) { background: #16A34A; }

.btn-danger  { background: #EF4444; color: white; }
.btn-danger:hover:not(:disabled)  { background: #DC2626; }

.btn-warning { background: #F59E0B; color: #111; }
.btn-warning:hover:not(:disabled) { background: #D97706; }

.btn-outline {
  background: transparent;
  border: 1px solid var(--border2);
  color: var(--text);
}
.btn-outline:hover:not(:disabled) { background: var(--surface); color: white; }

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
}
.btn-ghost:hover:not(:disabled) { background: var(--dark4); color: var(--text); }

.btn-sm { padding: 5px 10px; font-size: 0.72rem; border-radius: 7px; }
.btn-lg { padding: 11px 22px; font-size: 0.88rem; }

/* ─── Forms ─── */
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-label { font-size: 0.72rem; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.06em; }

.form-input {
  background: var(--dark4);
  border: 1px solid var(--border2);
  border-radius: 9px;
  padding: 9px 13px;
  font-family: inherit;
  font-size: 0.82rem;
  color: white;
  outline: none;
  transition: border-color 0.15s;
  width: 100%;
}
.form-input:focus { border-color: rgba(108,99,255,0.4); }
.form-input::placeholder { color: var(--text-dim); }
.form-input option { background: var(--dark4); }

/* ─── Tabs ─── */
.tabs {
  display: flex;
  gap: 2px;
  background: var(--dark4);
  padding: 3px;
  border-radius: 10px;
}

.tab {
  padding: 5px 12px;
  border-radius: 8px;
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.tab:hover { color: white; }
.tab.active { background: var(--surface); color: white; }

/* ─── Progress bar ─── */
.progress-bar {
  width: 100%;
  height: 5px;
  background: var(--dark4);
  border-radius: 99px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  border-radius: 99px;
  background: linear-gradient(90deg, #6C63FF, #3ECFCF);
  transition: width 0.6s ease;
}

/* ─── Modal ─── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
  z-index: 500;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-overlay.open { display: flex; }

.modal {
  background: var(--dark3);
  border: 1px solid var(--border2);
  border-radius: 18px;
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  animation: modalIn 0.2s ease;
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.96) translateY(8px); }
  to   { opacity: 1; transform: none; }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
}

.modal-title { font-size: 0.95rem; font-weight: 800; color: white; }

.modal-close {
  width: 28px; height: 28px;
  border: none;
  background: var(--dark4);
  border-radius: 7px;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.8rem;
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal-close:hover { background: var(--danger); color: white; }

.modal-body   { padding: 20px 22px; }
.modal-footer { padding: 14px 22px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }

/* ─── Toast ─── */
#toastContainer {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 0.82rem;
  font-weight: 600;
  color: white;
  min-width: 260px;
  max-width: 360px;
  border: 1px solid transparent;
  animation: toastIn 0.25s ease;
  pointer-events: all;
}

@keyframes toastIn  { from { opacity: 0; transform: translateY(12px) scale(0.97); } to { opacity: 1; transform: none; } }
@keyframes toastOut { from { opacity: 1; } to { opacity: 0; transform: translateY(-6px); } }

.toast.out { animation: toastOut 0.2s ease forwards; }

.toast-success { background: rgba(22,163,74,0.92); border-color: rgba(34,197,94,0.3); }
.toast-warning { background: rgba(180,83,9,0.95); border-color: rgba(245,158,11,0.3); }
.toast-danger  { background: rgba(185,28,28,0.95); border-color: rgba(239,68,68,0.3); }
.toast-info    { background: rgba(37,99,235,0.95); border-color: rgba(59,130,246,0.3); }

/* ─── Search ─── */
.search-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.search-wrap svg { position: absolute; left: 10px; color: var(--text-dim); pointer-events: none; }
.search-wrap .form-input { padding-left: 32px; }

/* ─── Live dot ─── */
.live-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--success);
  display: inline-block;
  animation: pulse 2s ease-in-out infinite;
}
@keyframes pulse {
  0%,100% { box-shadow: 0 0 0 0 rgba(34,197,94,0.4); }
  50%      { box-shadow: 0 0 0 6px rgba(34,197,94,0); }
}

/* ─── Sparkline ─── */
.sparkline {
  display: flex;
  align-items: flex-end;
  gap: 3px;
}
.spark-bar {
  flex: 1;
  border-radius: 3px 3px 0 0;
  background: linear-gradient(0deg, #6C63FF, #3ECFCF);
  opacity: 0.7;
  transition: opacity 0.2s;
}
.spark-bar:hover { opacity: 1; }

/* ─── QR Section ─── */
.qr-card {
  background: var(--dark3);
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
  transition: transform 0.2s, border-color 0.2s;
}
.qr-card:hover { transform: translateY(-3px); border-color: var(--border2); }

.qr-canvas-wrap {
  background: white;
  border-radius: 12px;
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 160px;
  margin: 0 auto;
  width: fit-content;
}

/* ─── Table map ─── */
.table-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 10px;
}

.table-cell {
  border: 2px solid var(--border2);
  border-radius: 12px;
  padding: 10px 8px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
}
.table-cell.available  { border-color: rgba(34,197,94,0.3); background: rgba(34,197,94,0.05); }
.table-cell.occupied   { border-color: rgba(239,68,68,0.4); background: rgba(239,68,68,0.07); }
.table-cell.reserved   { border-color: rgba(245,158,11,0.4); background: rgba(245,158,11,0.05); }

.table-cell:hover { transform: scale(1.03); }

.table-cell-num  { font-size: 1rem; font-weight: 900; color: white; }
.table-cell-cap  { font-size: 0.65rem; color: var(--text-muted); margin-top: 2px; }
.table-cell-name { font-size: 0.6rem; color: var(--text-dim); }

/* ─── Order flow card (KDS) ─── */
.kds-card {
  background: var(--dark3);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  transition: all 0.2s;
}
.kds-card.new-order   { border-color: rgba(59,130,246,0.4); }
.kds-card.accepted    { border-color: rgba(245,158,11,0.4); }
.kds-card.preparing   { border-color: rgba(239,68,68,0.4); animation: borderPulse 2s ease-in-out infinite; }
.kds-card.ready       { border-color: rgba(34,197,94,0.4); }

@keyframes borderPulse {
  0%,100% { box-shadow: 0 0 0 0 rgba(239,68,68,0); }
  50%      { box-shadow: 0 0 0 6px rgba(239,68,68,0.08); }
}

.kds-header {
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid var(--border);
}

.kds-timer {
  font-size: 0.72rem;
  font-weight: 800;
  padding: 3px 7px;
  border-radius: 6px;
  font-variant-numeric: tabular-nums;
}
.kds-timer.urgent { background: rgba(239,68,68,0.15); color: #EF4444; }
.kds-timer.ok     { background: rgba(245,158,11,0.15); color: #F59E0B; }
.kds-timer.fresh  { background: rgba(34,197,94,0.12);  color: #22C55E; }

/* ─── Bill/Invoice ─── */
.invoice-wrap {
  background: white;
  color: #111;
  padding: 24px;
  border-radius: 12px;
  font-family: monospace;
  font-size: 0.82rem;
  line-height: 1.6;
}
.invoice-wrap h2 { font-size: 1.1rem; font-weight: 900; margin-bottom: 4px; }
.invoice-divider { border: none; border-top: 1px dashed #aaa; margin: 10px 0; }
.invoice-row     { display: flex; justify-content: space-between; }
.invoice-total   { font-weight: 900; font-size: 1rem; }

/* ─── Misc utilities ─── */
.text-right   { text-align: right; }
.text-center  { text-align: center; }
.text-success { color: var(--success); }
.text-danger  { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-accent  { color: #6C63FF; }
.font-bold    { font-weight: 700; }
.font-heavy   { font-weight: 900; }
.mt-8         { margin-top: 8px; }
.mt-16        { margin-top: 16px; }
.gap-8        { gap: 8px; }

.empty-state {
  text-align: center;
  padding: 40px 24px;
  color: var(--text-muted);
}
.empty-state svg { opacity: 0.3; margin-bottom: 12px; }
.empty-state p   { font-size: 0.85rem; }

/* ─── Scrollbar ─── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.08); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.14); }

/* ─── Print ─── */
@media print {
  .sidebar, .topbar, .no-print { display: none !important; }
  .main-wrapper { margin-left: 0 !important; }
  body { background: white; color: black; }
}

/* ─── POS Layout ─── */
.pos-layout {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 16px;
  height: calc(100vh - 110px);
}
.pos-menu-col, .pos-cart-col {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ─── Mobile Responsiveness ─── */
@media (max-width: 768px) {
  .sidebar {
    position: fixed; bottom: 0; left: 0;
    width: 100% !important; height: 64px;
    flex-direction: row;
    border-right: none; border-top: 1px solid var(--border);
    z-index: 1000;
  }
  .sidebar-header, .sidebar-footer, .sidebar-brand, .nav-section-label { display: none !important; }
  .nav-scroll {
    display: flex; flex-direction: row; padding: 4px; gap: 2px;
    overflow-x: auto; overflow-y: hidden;
  }
  .nav-section { display: flex; flex-direction: row; padding: 0; margin: 0; }
  .nav-item { flex-direction: column; padding: 6px; gap: 4px; border-radius: 8px; flex: 1 0 auto; min-width: 60px; justify-content: center; align-items: center; }
  .nav-item-icon { width: 22px; height: 22px; }
  .nav-item-icon svg { width: 14px; height: 14px; }
  .nav-item-label { font-size: 0.65rem; display: block !important; opacity: 1 !important; transform: none !important; }
  .nav-item-badge { display: none; }
  .main-wrapper { margin-left: 0 !important; margin-bottom: 64px; height: calc(100vh - 64px); }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr !important; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr) !important; }
  .table-map { grid-template-columns: repeat(2, 1fr) !important; }
  .pos-layout { grid-template-columns: 1fr !important; height: auto !important; }
  .pos-menu-col, .pos-cart-col { min-height: 500px; }
  .topbar { padding: 0 12px; }
  .content-area { padding: 12px; }
}
