/* ============================================================
   Rincon Restaurant POS - Core Stylesheet
   Design: Dark professional theme, touch-optimized
   ============================================================ */

:root {
  --bg-dark:    #0f1117;
  --bg-card:    #1a1d27;
  --bg-card2:   #22263a;
  --bg-hover:   #2a2f47;
  --border:     #2e3352;
  --accent:     #4f7df3;
  --accent-dim: #3a5ec0;
  --green:      #22c55e;
  --red:        #ef4444;
  --orange:     #f97316;
  --yellow:     #eab308;
  --purple:     #a855f7;
  --text:       #e2e8f0;
  --text-muted: #8892a4;
  --text-dim:   #5a6478;
  --radius:     10px;
  --radius-lg:  16px;
  --shadow:     0 4px 24px rgba(0,0,0,0.4);
  --font:       'Inter', 'Segoe UI', system-ui, sans-serif;
  --touch-min:  44px;
}

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

html { font-size: 16px; -webkit-tap-highlight-color: transparent; }

body {
  font-family: var(--font);
  background: var(--bg-dark);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  user-select: none;
  -webkit-user-select: none;
}

/* ── Typography ─────────────────────────────────────────── */
h1, h2, h3, h4 { font-weight: 600; line-height: 1.2; }
p { line-height: 1.6; }
a { color: var(--accent); text-decoration: none; }

/* ── Scrollbar ──────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 99px; }

/* ── Layout ─────────────────────────────────────────────── */
.app-shell {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 20px;
  height: 56px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  z-index: 100;
}

.topbar-logo {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: -0.03em;
}

.topbar-sep { flex: 1; }

.topbar-clock {
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.875rem;
  font-weight: 500;
}

.topbar-user-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.app-body {
  display: flex;
  flex: 1;
  overflow: hidden;
}

.sidebar {
  width: 60px;
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 0;
  gap: 4px;
  flex-shrink: 0;
  z-index: 50;
}

.sidebar-btn {
  width: 48px; height: 48px;
  border-radius: var(--radius);
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 2px;
  font-size: 0.6rem;
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
  text-decoration: none;
}
.sidebar-btn svg { width: 20px; height: 20px; }
.sidebar-btn:hover  { background: var(--bg-hover); color: var(--text); }
.sidebar-btn.active { background: var(--accent); color: #fff; }
.sidebar-btn.active svg { stroke: #fff; }

.sidebar-sep {
  width: 32px;
  height: 1px;
  background: var(--border);
  margin: 4px 0;
}

.main-content {
  flex: 1;
  overflow: auto;
  padding: 20px;
  background: var(--bg-dark);
}

/* ── Cards ──────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
}

.card-header {
  display: flex; align-items: center;
  gap: 12px; margin-bottom: 16px;
}
.card-title {
  font-size: 1rem;
  font-weight: 600;
}

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center; justify-content: center;
  gap: 6px;
  min-height: var(--touch-min);
  padding: 0 16px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
  font-family: var(--font);
}
.btn svg { width: 16px; height: 16px; flex-shrink: 0; }

.btn-primary  { background: var(--accent); color: #fff; }
.btn-primary:hover  { background: var(--accent-dim); }

.btn-success  { background: var(--green); color: #000; }
.btn-success:hover  { filter: brightness(0.9); }

.btn-danger   { background: var(--red); color: #fff; }
.btn-danger:hover   { filter: brightness(0.85); }

.btn-warning  { background: var(--orange); color: #fff; }
.btn-warning:hover  { filter: brightness(0.9); }

.btn-ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--text);
}
.btn-ghost:hover { background: var(--bg-hover); }

.btn-sm { min-height: 36px; padding: 0 12px; font-size: 0.8125rem; }
.btn-lg { min-height: 52px; padding: 0 24px; font-size: 1rem; }
.btn-xl { min-height: 64px; padding: 0 32px; font-size: 1.125rem; }
.btn-icon { width: 44px; padding: 0; border-radius: 8px; }
.btn-block { width: 100%; }

.btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ── Badges / Pills ─────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center;
  padding: 2px 8px;
  border-radius: 99px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.badge-green  { background: rgba(34,197,94,0.15);  color: var(--green); }
.badge-red    { background: rgba(239,68,68,0.15);   color: var(--red); }
.badge-orange { background: rgba(249,115,22,0.15);  color: var(--orange); }
.badge-yellow { background: rgba(234,179,8,0.15);   color: var(--yellow); }
.badge-blue   { background: rgba(79,125,243,0.15);  color: var(--accent); }
.badge-purple { background: rgba(168,85,247,0.15);  color: var(--purple); }
.badge-muted  { background: var(--bg-hover); color: var(--text-muted); }

/* ── Form Inputs ─────────────────────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-label { font-size: 0.8rem; font-weight: 600; color: var(--text-muted); }
.form-input, .form-select, .form-textarea {
  background: var(--bg-dark);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font);
  font-size: 0.9rem;
  padding: 10px 14px;
  min-height: var(--touch-min);
  transition: border-color 0.15s;
  width: 100%;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none;
  border-color: var(--accent);
}
.form-select { cursor: pointer; }
.form-textarea { resize: vertical; min-height: 80px; }

/* ── Modal ───────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}
.modal-overlay.open { opacity: 1; pointer-events: all; }

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 24px;
  transform: scale(0.95);
  transition: transform 0.2s;
  box-shadow: var(--shadow);
}
.modal-overlay.open .modal { transform: scale(1); }

.modal-header {
  display: flex; align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}
.modal-title { font-size: 1.1rem; font-weight: 700; }
.modal-close {
  width: 32px; height: 32px;
  border-radius: 8px;
  border: none;
  background: var(--bg-hover);
  color: var(--text-muted);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem;
  transition: background 0.15s;
}
.modal-close:hover { background: var(--red); color: #fff; }

/* ── Toast Notifications ────────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: 20px; right: 20px;
  z-index: 9999;
  display: flex; flex-direction: column-reverse; gap: 8px;
  pointer-events: none;
}
.toast {
  background: var(--bg-card2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  font-size: 0.875rem;
  font-weight: 500;
  min-width: 240px;
  max-width: 340px;
  display: flex; align-items: center; gap: 10px;
  box-shadow: var(--shadow);
  pointer-events: all;
  animation: slideInRight 0.25s ease, fadeOut 0.3s ease 2.7s forwards;
}
.toast-success { border-left: 3px solid var(--green); }
.toast-error   { border-left: 3px solid var(--red); }
.toast-warning { border-left: 3px solid var(--orange); }
.toast-info    { border-left: 3px solid var(--accent); }
.toast-icon { width: 16px; height: 16px; flex-shrink: 0; }

@keyframes slideInRight {
  from { transform: translateX(60px); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}
@keyframes fadeOut {
  to { opacity: 0; transform: translateY(8px); }
}

/* ── Status Colors ──────────────────────────────────────── */
.status-available { color: var(--green); }
.status-occupied  { color: var(--orange); }
.status-reserved  { color: var(--accent); }
.status-cleaning  { color: var(--yellow); }

/* ── PIN Pad ─────────────────────────────────────────────── */
.pin-pad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.pin-pad-key {
  height: 72px;
  background: var(--bg-card2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 1.4rem;
  font-weight: 600;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.1s, transform 0.1s;
  user-select: none;
  font-family: var(--font);
}
.pin-pad-key:active { background: var(--accent); transform: scale(0.96); }
.pin-pad-key.clear  { color: var(--red); }
.pin-pad-key.submit { background: var(--accent); color: #fff; }

.pin-display {
  display: flex; gap: 12px;
  justify-content: center;
  margin-bottom: 20px;
}
.pin-dot {
  width: 14px; height: 14px;
  border-radius: 50%;
  border: 2px solid var(--border);
  transition: background 0.15s, border-color 0.15s;
}
.pin-dot.filled { background: var(--accent); border-color: var(--accent); }

/* ── Table Button (floor plan) ──────────────────────────── */
.table-btn {
  position: absolute;
  background: var(--bg-card2);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 2px;
  font-weight: 600;
  transition: all 0.15s;
  overflow: hidden;
  padding: 4px;
}
.table-btn:hover { border-color: var(--accent); z-index: 10; }
.table-btn.available  { border-color: var(--green);  background: rgba(34,197,94,0.08); }
.table-btn.occupied   { border-color: var(--orange); background: rgba(249,115,22,0.1); }
.table-btn.reserved   { border-color: var(--accent); background: rgba(79,125,243,0.1); }
.table-btn.cleaning   { border-color: var(--yellow); background: rgba(234,179,8,0.1); }
.table-btn.circle     { border-radius: 50%; }

.table-name  { font-size: 0.85rem; font-weight: 700; }
.table-info  { font-size: 0.65rem; color: var(--text-muted); text-align: center; line-height: 1.3; }
.table-timer { font-size: 0.65rem; font-weight: 700; }
.table-timer.warn  { color: var(--orange); }
.table-timer.alert { color: var(--red); animation: pulse 1s infinite; }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.5; }
}

/* ── POS Terminal ────────────────────────────────────────── */
.pos-layout {
  display: grid;
  grid-template-columns: 1fr 360px;
  height: calc(100vh - 56px);
  overflow: hidden;
}

.pos-menu-panel {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-right: 1px solid var(--border);
}

.pos-category-bar {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  overflow-x: auto;
  flex-shrink: 0;
  border-bottom: 1px solid var(--border);
  background: var(--bg-card);
}
.pos-category-bar::-webkit-scrollbar { height: 3px; }

.cat-btn {
  display: flex; flex-direction: column;
  align-items: center; gap: 4px;
  padding: 8px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-card2);
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
  font-size: 0.8rem;
  font-weight: 600;
  min-height: var(--touch-min);
  transition: all 0.15s;
  font-family: var(--font);
}
.cat-btn:hover  { background: var(--bg-hover); color: var(--text); }
.cat-btn.active { color: #fff; border-color: transparent; }

.pos-search-bar {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-card);
  flex-shrink: 0;
}

.pos-items-grid {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 10px;
  align-content: start;
}

.menu-item-btn {
  background: var(--bg-card2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 8px;
  cursor: pointer;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 6px;
  min-height: 90px;
  text-align: center;
  transition: all 0.15s;
  position: relative;
  font-family: var(--font);
}
.menu-item-btn:hover  { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,0.3); }
.menu-item-btn:active { transform: scale(0.97); }
.menu-item-btn .item-name {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
}
.menu-item-btn .item-price {
  font-size: 0.85rem;
  font-weight: 700;
}
.menu-item-btn .item-tag {
  position: absolute; top: 4px; right: 4px;
  font-size: 0.6rem;
  background: var(--orange);
  color: #fff;
  border-radius: 4px;
  padding: 1px 4px;
  font-weight: 700;
}

/* ── Order Panel (right side of POS) ────────────────────── */
.pos-order-panel {
  display: flex;
  flex-direction: column;
  background: var(--bg-card);
  overflow: hidden;
}

.order-panel-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.order-panel-title {
  font-size: 1rem;
  font-weight: 700;
}

.order-panel-meta {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.order-items-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.order-item-row {
  display: flex; align-items: flex-start;
  gap: 8px;
  padding: 8px 8px;
  border-radius: 8px;
  transition: background 0.1s;
  border-bottom: 1px solid var(--border);
}
.order-item-row:last-child { border-bottom: none; }
.order-item-row:hover { background: var(--bg-hover); }
.order-item-row.voided { opacity: 0.4; text-decoration: line-through; }

.order-item-qty {
  min-width: 24px;
  font-weight: 700;
  font-size: 0.875rem;
  color: var(--accent);
  text-align: center;
  padding-top: 2px;
}
.order-item-info { flex: 1; }
.order-item-name {
  font-size: 0.85rem;
  font-weight: 600;
}
.order-item-mods {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 2px;
}
.order-item-notes {
  font-size: 0.72rem;
  color: var(--yellow);
  font-style: italic;
  margin-top: 2px;
}
.order-item-price {
  font-size: 0.875rem;
  font-weight: 700;
  white-space: nowrap;
}
.order-item-remove {
  width: 24px; height: 24px;
  border-radius: 6px;
  background: transparent;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.1s;
  flex-shrink: 0;
}
.order-item-remove:hover { background: var(--red); color: #fff; }

.order-totals {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.order-total-row {
  display: flex; justify-content: space-between;
  font-size: 0.85rem;
  padding: 3px 0;
  color: var(--text-muted);
}
.order-total-row.grand {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
  border-top: 1px solid var(--border);
  padding-top: 8px;
  margin-top: 4px;
}

.order-actions {
  padding: 12px 16px;
  display: flex; gap: 8px;
  flex-shrink: 0;
}

/* ── KDS Display ─────────────────────────────────────────── */
.kds-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
  padding: 16px;
  align-content: start;
  overflow-y: auto;
  height: calc(100vh - 56px);
}

.kds-ticket {
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  display: flex; flex-direction: column;
}
.kds-ticket.warn  { border-color: var(--orange); }
.kds-ticket.alert { border-color: var(--red); animation: pulse 1.5s infinite; }
.kds-ticket.ready { border-color: var(--green); opacity: 0.7; }

.kds-ticket-header {
  padding: 10px 14px;
  background: var(--bg-card2);
  display: flex; align-items: center; justify-content: space-between;
  flex-shrink: 0;
}
.kds-table-name { font-size: 1rem; font-weight: 700; }
.kds-order-num  { font-size: 0.75rem; color: var(--text-muted); }
.kds-timer      { font-size: 0.85rem; font-weight: 700; font-variant-numeric: tabular-nums; }

.kds-items { flex: 1; padding: 8px 14px; }
.kds-item-row {
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
  display: flex; gap: 8px;
}
.kds-item-row:last-child { border-bottom: none; }
.kds-item-qty  { font-size: 1rem; font-weight: 700; color: var(--accent); width: 24px; }
.kds-item-info { flex: 1; }
.kds-item-name { font-size: 0.9rem; font-weight: 600; }
.kds-item-mods { font-size: 0.75rem; color: var(--text-muted); margin-top: 2px; }
.kds-item-note { font-size: 0.75rem; color: var(--yellow); font-style: italic; }

.kds-ticket-footer {
  padding: 10px 14px;
  background: var(--bg-card2);
  display: flex; gap: 8px;
}

/* ── Auth / Login ────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-dark);
  padding: 16px;
}

.login-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 40px 36px;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow);
}

.login-logo {
  text-align: center;
  margin-bottom: 32px;
}
.login-logo h1 { font-size: 1.8rem; color: var(--accent); font-weight: 800; }
.login-logo p  { font-size: 0.875rem; color: var(--text-muted); margin-top: 4px; }

/* ── Admin / Report Tables ──────────────────────────────── */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}
.data-table th, .data-table td {
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
.data-table th {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}
.data-table tbody tr:hover { background: var(--bg-hover); }
.data-table .num { text-align: right; font-variant-numeric: tabular-nums; }

/* ── Stat Cards ─────────────────────────────────────────── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
}
.stat-label {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.stat-value {
  font-size: 1.75rem;
  font-weight: 800;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.stat-delta {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 6px;
}

/* ── Responsive ─────────────────────────────────────────── */
@media (max-width: 768px) {
  .pos-layout {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr 300px;
  }
  .pos-items-grid {
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  }
}

@media (max-width: 480px) {
  .topbar { padding: 0 12px; }
  .main-content { padding: 12px; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
}
