/* =====================================================================
   SANDTEKNO POS — Design System v2 (FULL FIX + PHASE 2A + PHASE 3)
   ===================================================================== */

:root {
  --navy: #0f172a; --bg: #f1f5f9; --line: #e2e8f0;
  --emerald: #059669; --amber: #d97706; --indigo: #4f46e5; --red: #dc2626;
  --text: #0f172a; --navy-2: #1e293b; --navy-3: #334155;
  --text-2: #475569; --text-3: #64748b; --text-4: #94a3b8;
  --surface: #ffffff; --surface-2: #f8fafc;
  --r-xs: 4px; --r-sm: 6px; --r: 8px; --r-md: 10px; --r-lg: 12px; --r-xl: 16px;
  --sh-sm: 0 1px 3px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
  --sh-md: 0 10px 15px -3px rgba(15, 23, 42, 0.08), 0 4px 6px -4px rgba(15, 23, 42, 0.04);
  --sh-lg: 0 20px 25px -5px rgba(15, 23, 42, 0.10), 0 8px 10px -6px rgba(15, 23, 42, 0.04);
  --ring: 0 0 0 3px rgba(79, 70, 229, 0.15);
  --font-main: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, monospace;
  --t-fast: 120ms ease; --t: 180ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* --- RESET & BASE --- */
* { box-sizing: border-box; }
html, body, table, th, td, input, select, button, textarea { font-family: var(--font-main) !important; }
html, body { height: 100vh; max-height: 100vh; margin: 0; overflow: hidden; font-size: 14px; line-height: 1.55; background: var(--bg); color: var(--text); -webkit-font-smoothing: antialiased; }

/* --- TOPBAR --- */
.topbar { display: flex; justify-content: space-between; align-items: center; height: 56px; padding: 0 24px; background: var(--navy); color: #fff; width: 100%; border-bottom: 1px solid rgba(148, 163, 184, 0.1); box-shadow: 0 1px 0 0 rgba(255, 255, 255, 0.04) inset, 0 2px 8px rgba(15, 23, 42, 0.14); flex-shrink: 0; position: relative; z-index: 20; }
.topbar-left, .topbar-right { display: flex; align-items: center; gap: 12px; }
.brand { font-weight: 800; font-size: 15px; letter-spacing: 0.14em; color: #fbbf24; padding-right: 16px; border-right: 1px solid #334155; text-transform: uppercase; }
.top-nav { display: flex; align-items: center; gap: 4px; }
.top-nav a { padding: 7px 14px; border-radius: var(--r); color: #cbd5e1; text-decoration: none; font-weight: 600; font-size: 13px; transition: all var(--t-fast); }
.top-nav a:hover { background: rgba(255, 255, 255, 0.08); color: #fff; }
.top-nav a.active { background: var(--indigo); color: #fff; box-shadow: 0 1px 3px rgba(79, 70, 229, 0.4); }
.topbar-user { display: flex; align-items: center; gap: 8px; background: rgba(255, 255, 255, 0.08); padding: 4px 12px 4px 4px; border-radius: 50px; border: 1px solid rgba(255, 255, 255, 0.1); }
.topbar-avatar { width: 28px; height: 28px; background: var(--indigo); color: #fff; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 12px; }
.topbar-user-info { display: flex; flex-direction: column; line-height: 1.1; }
.topbar-user-name { font-size: 12px; font-weight: 600; color: #fff; }
.topbar-user-role { font-size: 10px; color: #94a3b8; text-transform: uppercase; letter-spacing: 0.05em; }

/* --- LAYOUT --- */
.layout { display: flex; flex-direction: column; height: calc(100dvh - 56px); overflow: hidden; }
.content { flex: 1; padding: 18px 24px; height: 100%; overflow-y: auto; display: flex; flex-direction: column; gap: 16px; }

/* --- TIPOGRAFI & PANEL --- */
.mono, .card b, .r, td[data-sort], .sum.total, .sum.change, input[type="number"] { font-family: var(--font-mono) !important; font-variant-numeric: tabular-nums; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 18px 20px; margin: 0; box-shadow: var(--sh-sm); }
.panel-title { margin: 0; font-size: 15px; font-weight: 700; color: var(--navy); letter-spacing: -0.01em; }
.cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.card { border-radius: var(--r-md); padding: 16px 18px; color: #fff; display: flex; flex-direction: column; gap: 4px; position: relative; overflow: hidden; box-shadow: var(--sh-sm); transition: transform var(--t), box-shadow var(--t); }
.card::after { content: ''; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(255, 255, 255, 0.09), transparent 55%); pointer-events: none; }
.card:hover { transform: translateY(-1px); box-shadow: var(--sh); }
.card span { font-size: 11.5px; opacity: 0.92; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; position: relative; z-index: 1; }
.card b { font-size: 24px; letter-spacing: -0.02em; line-height: 1.2; position: relative; z-index: 1; }
.emerald { background: linear-gradient(135deg, #059669 0%, #10b981 100%); }
.amber { background: linear-gradient(135deg, #d97706 0%, #f59e0b 100%); }
.indigo { background: linear-gradient(135deg, #3730a3 0%, #4f46e5 100%); }

/* --- FORM & BUTTONS --- */
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field { background: var(--bg); padding: 10px 12px; border-radius: var(--r-sm); font-weight: 600; font-size: 13px; }
label { display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--text-2); font-weight: 600; }
input, select, textarea { padding: 8px 12px; border: 1px solid #cbd5e1; border-radius: var(--r); font-size: 13.5px; min-height: 38px; background: var(--surface); width: 100%; color: var(--text); transition: border-color var(--t-fast), box-shadow var(--t-fast); }
select { appearance: none; background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'/%3e%3c/svg%3e"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 34px; cursor: pointer; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--indigo); box-shadow: var(--ring); }
input.big { font-size: 15px; padding: 12px 14px; border: 2px solid var(--indigo); font-weight: 600; border-radius: var(--r-md); min-height: 46px; }

.btn { display: inline-flex; justify-content: center; align-items: center; gap: 6px; padding: 8px 16px; min-height: 36px; border: 1px solid #cbd5e1; border-radius: var(--r); background: var(--surface); color: var(--navy); font-weight: 600; cursor: pointer; text-decoration: none; font-size: 13px; white-space: nowrap; transition: all var(--t-fast); }
.btn:hover:not(:disabled) { background: var(--surface-2); border-color: #94a3b8; }
.btn.primary { background: var(--indigo); border-color: var(--indigo); color: #fff; }
.btn.primary:hover:not(:disabled) { background: #4338ca; border-color: #4338ca; }
.btn.danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn.danger:hover:not(:disabled) { background: #b91c1c; border-color: #b91c1c; }
.btn.danger-outline { background: transparent; color: var(--red); border-color: var(--red); }
.btn.danger-outline:hover:not(:disabled) { background: #fef2f2; }
.btn.ghost { background: transparent; color: #e2e8f0; border-color: #334155; }
.btn.ghost:hover { background: rgba(255, 255, 255, 0.08); color: #fff; }
.btn.sm { min-height: 30px; padding: 4px 10px; font-size: 12px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* --- ACTION BARS (FIXED) --- */
.shift-actions-bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--line); flex-wrap: nowrap; }
.shift-actions-left { display: flex; align-items: center; gap: 10px; }
.shift-actions-right { display: flex; align-items: center; gap: 8px; }
.close-shift-form { display: flex; align-items: center; gap: 8px; margin: 0; }
.close-shift-form input[name="counted_cash"] { width: 160px; height: 38px; margin: 0; }
.close-shift-form .btn { height: 38px; }

/* --- TOOLBAR & TABLE --- */
.table-toolbar-inline, .panel-header-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 10px; flex-wrap: wrap; }
.toolbar-left, .toolbar-right { display: flex; align-items: center; gap: 8px; }
.dt-lbl { font-size: 12.5px; color: var(--text-2); font-weight: 500; }
.dt-select-compact, .dt-select-sm { height: 32px; padding: 0 28px 0 10px; font-size: 12.5px; border-radius: var(--r); background-color: var(--surface); background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'/%3e%3c/svg%3e"); background-repeat: no-repeat; background-position: right 8px center; appearance: none; }
.dt-input-compact, .dt-input-sm { height: 32px; padding: 0 10px; font-size: 12.5px; width: 200px; border-radius: var(--r); }

.table-wrap { overflow-y: auto; overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface); }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 12px; border-bottom: 1px solid var(--line); text-align: left; font-size: 13px; vertical-align: middle; }
th { cursor: pointer; user-select: none; background: var(--surface-2); font-weight: 700; color: var(--navy-3); position: sticky; top: 0; z-index: 10; white-space: nowrap; }
tbody tr { transition: background var(--t-fast); }
tbody tr:hover { background: var(--surface-2); }
tbody tr:last-child td { border-bottom: 0; }
.r { text-align: right; }

/* --- PAGINATION & UTILS --- */
.table-footer-compact { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 10px; padding-top: 8px; font-size: 12.5px; color: var(--text-3); }
.pagination-btns { display: flex; align-items: center; gap: 4px; }
.page-btn { min-width: 30px; height: 30px; padding: 0 8px; border: 1px solid var(--line); background: var(--surface); color: var(--navy-3); border-radius: var(--r-sm); cursor: pointer; font-size: 12px; font-weight: 600; transition: all var(--t-fast); }
.page-btn:hover:not(:disabled) { background: var(--surface-2); border-color: #94a3b8; }
.page-btn.active { background: var(--navy); color: #fff; border-color: var(--navy); }
.neg { color: var(--red); font-weight: 700; }
.ok { color: var(--emerald); font-weight: 700; }
.muted { color: var(--text-3); }
.center { text-align: center; }

/* --- POS DESKTOP --- */
.pos { display: grid; grid-template-columns: 1fr 340px; gap: 14px; align-items: stretch; height: 100%; min-height: 0; overflow: hidden; }
.results { list-style: none; margin: 8px 0; padding: 0; border: 1px solid var(--line); border-radius: var(--r-md); overflow: hidden; box-shadow: var(--sh-sm); }
.results button { width: 100%; text-align: left; padding: 10px 14px; background: #eef2ff; border: 0; border-bottom: 1px solid #c7d2fe; font-size: 13px; cursor: pointer; font-weight: 600; color: var(--navy); transition: background var(--t-fast); }
.results button:hover { background: #e0e7ff; }
.qty { display: flex; gap: 4px; align-items: center; min-width: 130px; }
.qty input { width: 60px; text-align: center; min-height: 34px; padding: 2px 6px; }
.pay { display: flex; flex-direction: column; justify-content: space-between; margin-bottom: 0; padding: 16px; overflow-y: auto; }
.sum { display: flex; justify-content: space-between; align-items: center; font-size: 13.5px; font-weight: 600; }
.sum.total { font-size: 20px; padding: 14px 16px; background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%); color: #fff; border-radius: var(--r-md); box-shadow: var(--sh-sm); }
.sum.change { font-size: 18px; color: var(--emerald); padding: 10px 14px; background: rgba(5, 150, 105, 0.08); border-radius: var(--r-md); }
.quick { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.empty-state { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 40px 20px; color: var(--text-3); text-align: center; height: 100%; }
.empty-state svg { width: 64px; height: 64px; margin-bottom: 16px; opacity: 0.3; }
.empty-state h3 { margin: 0 0 8px; font-size: 16px; color: var(--navy-3); }
.empty-state p { margin: 0; font-size: 13px; }
.btn-icon { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; border-radius: var(--r-sm); border: 1px solid var(--line); background: var(--surface); color: var(--text-2); cursor: pointer; transition: all var(--t-fast); text-decoration: none; }
.btn-icon:hover { background: var(--surface-2); color: var(--navy); border-color: #cbd5e1; }
.btn-icon.danger { color: var(--red); border-color: #fca5a5; background: #fef2f2; }
.btn-icon.danger:hover { background: #fee2e2; color: #b91c1c; }
.btn-icon svg { width: 16px; height: 16px; fill: currentColor; }
.btn-reset-cart { background: transparent; color: var(--red); border: 1px solid transparent; font-size: 12px; cursor: pointer; font-weight: 600; padding: 4px 8px; border-radius: var(--r-sm); transition: all var(--t-fast); }
.btn-reset-cart:hover { background: #fef2f2; border-color: #fca5a5; }

/* =====================================================================
   PHASE 3: TOAST, MODAL, SPINNER, & SHORTCUT HINT
   ===================================================================== */
.toast-container { position: fixed; top: 24px; right: 24px; z-index: 9999; display: flex; flex-direction: column; gap: 10px; pointer-events: none; }
.toast { background: #fff; border-radius: var(--r-md); box-shadow: var(--sh-lg); display: flex; align-items: center; gap: 12px; padding: 12px 16px; min-width: 250px; max-width: 400px; border-left: 4px solid var(--indigo); transform: translateX(120%); transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275); pointer-events: auto; }
.toast.show { transform: translateX(0); }
.toast.success { border-left-color: var(--emerald); }
.toast.error { border-left-color: var(--red); }
.toast-icon { width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; color: #fff; flex-shrink: 0; }
.toast.success .toast-icon { background: var(--emerald); }
.toast.error .toast-icon { background: var(--red); }
.toast.info .toast-icon { background: var(--indigo); }
.toast-content { flex: 1; font-size: 13px; font-weight: 600; color: var(--navy-3); line-height: 1.3; }
.modal-overlay { position: fixed; inset: 0; background: rgba(15, 23, 42, 0.5); backdrop-filter: blur(2px); z-index: 10000; display: flex; align-items: center; justify-content: center; opacity: 0; visibility: hidden; transition: all 0.2s ease; }
.modal-overlay.open { opacity: 1; visibility: visible; }
.modal-box { background: var(--surface); border-radius: var(--r-xl); width: min(400px, 90vw); padding: 24px; box-shadow: var(--sh-lg); transform: translateY(20px) scale(0.95); transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275); text-align: center; }
.modal-overlay.open .modal-box { transform: translateY(0) scale(1); }
.modal-icon-wrapper { width: 56px; height: 56px; border-radius: 50%; background: #fef2f2; color: var(--red); display: grid; place-items: center; margin: 0 auto 16px; }
.modal-title { margin: 0 0 8px; font-size: 18px; font-weight: 700; color: var(--navy); }
.modal-message { margin: 0 0 24px; font-size: 14px; color: var(--text-2); line-height: 1.5; }
.modal-actions { display: flex; gap: 10px; justify-content: center; }
.modal-actions .btn { flex: 1; height: 42px; font-size: 14px; }
.spinner { display: inline-block; width: 16px; height: 16px; border: 2px solid rgba(255,255,255,0.3); border-radius: 50%; border-top-color: #fff; animation: spin 0.8s linear infinite; }
.btn.loading { pointer-events: none; opacity: 0.8; }
@keyframes spin { to { transform: rotate(360deg); } }
.kbd-hint { display: flex; align-items: center; gap: 12px; font-size: 12px; color: var(--text-3); margin-top: 8px; justify-content: flex-end; }
.kbd { display: inline-flex; align-items: center; justify-content: center; background: var(--surface-2); border: 1px solid var(--line); border-bottom-width: 2px; border-radius: var(--r-xs); padding: 2px 6px; font-family: var(--font-mono); font-size: 11px; font-weight: 700; color: var(--navy-3); }

/* =====================================================================
   📱 MOBILE RESPONSIVE
   ===================================================================== */
.mobile-bottom-nav { display: none; }
@media (max-width: 900px) {
  html, body { height: auto; max-height: none; overflow: auto; font-size: 13.5px; }
  .layout { height: auto; overflow: visible; }
  .topbar { height: 52px; padding: 0 14px; }
  .brand { border-right: none; padding-right: 0; font-size: 14px; }
  .top-nav, .who, .topbar-user { display: none; }
  .content { height: auto; overflow: visible; padding: 12px 14px calc(80px + env(safe-area-inset-bottom)); gap: 12px; }
  input, select, textarea { font-size: 16px !important; min-height: 44px; padding: 10px 12px; }
  .btn { min-height: 44px; padding: 10px 16px; font-size: 14px; }
  .btn.sm { min-height: 38px; padding: 8px 14px; font-size: 13px; }
  .cards, .grid2, .pos { grid-template-columns: 1fr; }
  .panel { padding: 14px 16px; border-radius: var(--r-md); }
  .shift-actions-bar { flex-direction: column; align-items: stretch; gap: 12px; }
  .shift-actions-left { flex-direction: column; align-items: stretch; gap: 8px; text-align: center; }
  .close-shift-form { flex-direction: column; align-items: stretch; }
  .close-shift-form input[name="counted_cash"] { width: 100%; }
  .table-toolbar-inline, .panel-header-toolbar { flex-direction: column; align-items: stretch; gap: 8px; }
  .toolbar-left, .toolbar-right { width: 100%; flex-wrap: wrap; }
  .dt-input-compact, .dt-input-sm, .dt-select-compact, .dt-select-sm { width: 100% !important; height: 44px; }
  .table-wrap { -webkit-overflow-scrolling: touch; border-radius: var(--r); }
  #shiftTable, #productTable, #reportTable, #pos .table-wrap table { min-width: 640px; }
  th, td { padding: 9px 10px; font-size: 12.5px; white-space: nowrap; }
  .table-footer-compact { flex-direction: column; align-items: stretch; gap: 8px; text-align: center; }
  .pagination-btns { justify-content: center; flex-wrap: wrap; }
  .content > div[style*="grid-template-columns:"] { height: auto !important; min-height: 0 !important; overflow: visible !important; grid-template-columns: 1fr !important; display: block !important; }
  .content > div[style*="grid-template-columns:"] > section.panel { height: auto !important; max-height: none !important; overflow: visible !important; }
  .content > .pos { height: auto !important; min-height: 0 !important; overflow: visible !important; display: block !important; }
  .pos > .panel:first-child { margin-bottom: calc(55vh + 20px + 62px + env(safe-area-inset-bottom)) !important; height: auto !important; overflow: visible !important; }
  .results { max-height: 220px; overflow-y: auto; }
  .pay { position: fixed; bottom: calc(62px + env(safe-area-inset-bottom)); left: 8px; right: 8px; max-height: 55vh; overflow: hidden !important; z-index: 100; border: 1.5px solid var(--indigo); border-radius: var(--r-xl) var(--r-xl) 0 0; box-shadow: 0 -10px 28px rgba(15, 23, 42, 0.18); padding: 12px 14px 14px !important; display: flex !important; flex-direction: column !important; justify-content: flex-start !important; }
  .pay > div:first-child { flex: 1 1 auto; min-height: 0; overflow-y: auto; overflow-x: hidden; padding-bottom: 10px; }
  .pay > div:last-child { flex-shrink: 0; background: var(--surface); border-top: 1px solid var(--line); padding-top: 10px; margin-top: 0 !important; }
  .pay .sum.total { font-size: 16px; padding: 10px 14px; }
  .pay .sum.change { font-size: 15px; padding: 8px 12px; margin-bottom: 6px; }
  .pay input { min-height: 40px !important; height: 40px !important; }
  .pay .quick { grid-template-columns: repeat(3, 1fr); gap: 4px; }
  .pay .quick .btn { min-height: 34px; padding: 5px 4px; font-size: 11px; }
  .pay #payBtn { height: 46px !important; font-size: 15px !important; font-weight: 700; min-height: 46px; }
  .kbd-hint { display: none; }
  .mobile-bottom-nav { display: flex; position: fixed; bottom: 0; left: 0; right: 0; height: 62px; background: var(--surface); border-top: 1px solid var(--line); z-index: 999; justify-content: space-around; align-items: center; box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.06); padding-bottom: env(safe-area-inset-bottom); }
  .mobile-nav-item { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-decoration: none; color: var(--text-3); font-size: 11px; font-weight: 600; gap: 4px; height: 100%; position: relative; }
  .mobile-nav-item svg { width: 18px; height: 18px; fill: currentColor; }
  .mobile-nav-item.active { color: var(--indigo); }
  .mobile-nav-item.active::before { content: ''; position: absolute; top: 0; left: 50%; transform: translateX(-50%); width: 28px; height: 3px; background: var(--indigo); border-radius: 0 0 3px 3px; }
}