/* ============================================================
   APP THEME — Clean Professional POS
   Color palette: Slate + Indigo accent
   ============================================================ */
:root {
  --sidebar-w: 240px;
  --topbar-h: 52px;

  /* Brand */
  --brand:        #4f46e5; /* indigo-600 */
  --brand-dark:   #3730a3; /* indigo-800 */
  --brand-light:  #e0e7ff; /* indigo-100 */
  --brand-accent: #06b6d4; /* cyan-500  */

  /* Sidebar */
  --sb-bg:        #1e1b4b; /* indigo-950 */
  --sb-hover:     #312e81; /* indigo-900 */
  --sb-active:    #4f46e5; /* indigo-600 */
  --sb-text:      #c7d2fe; /* indigo-200 */
  --sb-text-muted:#818cf8; /* indigo-400 */
  --sb-border:    rgba(255,255,255,.06);

  /* Surface */
  --surface:      #ffffff;
  --surface-2:    #f8fafc;
  --border:       #e2e8f0;
  --text:         #0f172a;
  --text-muted:   #64748b;

  /* Status */
  --success:      #10b981;
  --danger:       #ef4444;
  --warning:      #f59e0b;
}

/* ── Reset / Base ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  font-size: .9375rem;
  color: var(--text);
  background: var(--surface-2);
  margin: 0;
}
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
:focus:not(:focus-visible) { outline: none; }

/* ── Sidebar ──────────────────────────────────────────────── */
.sidebar {
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  width: var(--sidebar-w);
  background: var(--sb-bg);
  color: var(--sb-text);
  z-index: 1000;
  transition: transform .25s ease;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.sidebar.collapsed { transform: translateX(-100%); }

.sidebar-header {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: 1.1rem 1.25rem;
  border-bottom: 1px solid var(--sb-border);
  flex-shrink: 0;
}
.sidebar-header img { border-radius: 6px; }
.sidebar-header span {
  font-weight: 700;
  font-size: .95rem;
  letter-spacing: .3px;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-menu {
  list-style: none;
  padding: .5rem 0;
  margin: 0;
  overflow-y: auto;
  flex: 1;
}
.sidebar-menu::-webkit-scrollbar { width: 6px; }
.sidebar-menu::-webkit-scrollbar-track { background: rgba(255,255,255,.04); border-radius: 4px; }
.sidebar-menu::-webkit-scrollbar-thumb { background: rgba(255,255,255,.18); border-radius: 4px; transition: background .2s; }
.sidebar-menu::-webkit-scrollbar-thumb:hover { background: #4ade80; }

/* Global page scrollbar */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: #f1f5f9; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 4px; transition: background .2s; }
::-webkit-scrollbar-thumb:hover { background: #4ade80; }

.sidebar-menu li { margin: 1px .5rem; }

.sidebar-group-label {
  font-size: .65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .8px;
  color: var(--sb-text);
  opacity: .4;
  padding: .9rem .85rem .25rem;
  margin: 0 !important;
  pointer-events: none;
  white-space: nowrap;
}

.sidebar.collapsed .sidebar-group-label { display: none; }

.sidebar-menu a {
  display: flex;
  align-items: center;
  gap: .65rem;
  padding: .55rem .85rem;
  color: var(--sb-text);
  text-decoration: none;
  border-radius: 7px;
  font-size: .875rem;
  font-weight: 500;
  transition: background .15s, color .15s, box-shadow .15s, transform .15s;
  white-space: nowrap;
}
.sidebar-menu a span:first-child { font-size: 1rem; flex-shrink: 0; }
.sidebar-menu a:hover {
  background: linear-gradient(90deg, #6366f1 0%, #4f46e5 100%);
  color: #fff;
  box-shadow: 0 2px 10px rgba(99,102,241,.45);
  transform: translateX(2px);
}
.sidebar-menu a.active {
  background: linear-gradient(90deg, #6366f1 0%, #4f46e5 100%);
  color: #fff;
  font-weight: 600;
  box-shadow: 0 2px 10px rgba(99,102,241,.4);
}

/* Dropdown inside sidebar */
.sidebar-menu .dropdown-menu {
  background: rgba(255,255,255,.05);
  border: none;
  border-radius: 7px;
  padding: .25rem 0;
  margin: 2px 0 0 0;
  position: static !important;
  transform: none !important;
  box-shadow: none;
}
.sidebar-menu .dropdown-item {
  color: var(--sb-text);
  font-size: .84rem;
  padding: .45rem 1rem .45rem 2.25rem;
  border-radius: 5px;
  margin: 1px .25rem;
}
.sidebar-menu .dropdown-item:hover { background: var(--sb-hover); color: #fff; }
.sidebar-menu .dropdown-divider { border-color: var(--sb-border); margin: .25rem .5rem; }

/* ── Sidebar toggle button ────────────────────────────────── */
.sidebar-toggle {
  position: fixed;
  top: 12px; left: 12px;
  z-index: 1001;
  background: var(--sb-bg);
  color: var(--sb-text);
  border: none;
  width: 34px; height: 34px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  transition: background .15s;
  box-shadow: 0 2px 8px rgba(0,0,0,.25);
}
.sidebar-toggle:hover { background: var(--sb-hover); }

/* ── Sidebar overlay (mobile) ─────────────────────────────── */
.sidebar-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 999;
  display: none;
  backdrop-filter: blur(2px);
}
.sidebar-overlay.show { display: block; }

/* ── Topbar ───────────────────────────────────────────────── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--topbar-h);
  margin-left: var(--sidebar-w);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 1.25rem;
  gap: 1rem;
  transition: margin-left .25s;
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
}
.topbar.expanded { margin-left: 0; }
#live-datetime {
  font-size: .8rem;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
  flex: 1;
}

/* ── Main content ─────────────────────────────────────────── */
.main-content {
  margin-left: var(--sidebar-w);
  transition: margin-left .25s;
  min-height: calc(100vh - var(--topbar-h));
  padding: 1.5rem;
}
.main-content.expanded { margin-left: 0; }

/* ── Footer ───────────────────────────────────────────────── */
footer {
  margin-left: var(--sidebar-w);
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: .75rem 1.5rem;
  font-size: .8rem;
  color: var(--text-muted);
  transition: margin-left .25s;
}

/* ── Status pill ──────────────────────────────────────────── */
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .3rem .75rem;
  border-radius: 999px;
  font-size: .75rem;
  font-weight: 700;
  letter-spacing: .5px;
  text-transform: uppercase;
  background: var(--success);
  color: #fff;
  white-space: nowrap;
}
.offline .status-pill { background: var(--danger); animation: pulse-offline 2s infinite; }
.status-dot {
  width: .5rem; height: .5rem;
  border-radius: 50%;
  background: rgba(255,255,255,.9);
  flex-shrink: 0;
}
@keyframes pulse-offline {
  0%,100% { opacity:1; } 50% { opacity:.7; }
}

/* ── Bootstrap overrides ──────────────────────────────────── */
.btn-primary { background: var(--brand); border-color: var(--brand); }
.btn-primary:hover, .btn-primary:focus { background: var(--brand-dark); border-color: var(--brand-dark); }
.btn-outline-primary { color: var(--brand); border-color: var(--brand); }
.btn-outline-primary:hover { background: var(--brand); border-color: var(--brand); }

.form-control:focus, .form-select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 .2rem rgba(79,70,229,.15);
}

.card {
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 1px 4px rgba(0,0,0,.05);
}
.card-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: .9rem;
}

.table > thead th {
  background: var(--surface-2);
  font-size: .8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}
.table-hover > tbody > tr:hover > * { background: rgba(79,70,229,.04); }
.table-sticky thead th {
  position: sticky;
  top: var(--topbar-h);
  background: var(--surface-2);
  z-index: 2;
}

/* ── Toast ────────────────────────────────────────────────── */
#toast-container-wrapper {
  position: fixed;
  top: 70px; right: 20px;
  z-index: 99999;
  pointer-events: none;
  max-width: 380px;
}
#toast-stack { pointer-events: auto; }
.custom-toast {
  background: var(--surface);
  border-left: 4px solid var(--success);
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0,0,0,.15);
  padding: .85rem 1rem;
  margin-bottom: .5rem;
  display: flex;
  align-items: center;
  gap: .75rem;
  font-size: .9rem;
  font-weight: 500;
  color: var(--text);
  animation: slideInRight .2s ease-out;
}
.custom-toast.danger { border-left-color: var(--danger); }
.custom-toast.warning { border-left-color: var(--warning); }
.custom-toast.info { border-left-color: var(--brand-accent); }
.toast-icon { font-size: 1.2rem; flex-shrink: 0; }
.toast-message { flex: 1; line-height: 1.4; }
.toast-close {
  background: none; border: none;
  color: var(--text-muted);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 0 .25rem;
  line-height: 1;
  border-radius: 4px;
}
.toast-close:hover { color: var(--text); background: var(--surface-2); }
@keyframes slideInRight {
  from { transform: translateX(30px); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.show { transform: translateX(0); }
  .main-content, .topbar, footer { margin-left: 0; }
  .main-content { padding: 1rem; }
}

/* ── DataTables spacing ───────────────────────────────────── */
.dataTables_scrollBody { margin-bottom: 0; }
.dataTables_paginate   { margin-top: 1rem !important; }
.dataTables_info       { margin-top: 1rem !important; }

/* ── Sticky table header (laporan) ───────────────────────── */
.table-sticky-wrap {
  overflow: auto;
  max-height: 70vh;
  isolation: isolate;
}
.table-sticky-wrap table {
  border-collapse: separate;
  border-spacing: 0;
}
.table-sticky-wrap thead th {
  position: sticky;
  top: 0;
  z-index: 10;
  background: #f1f5f9;
  box-shadow: 0 1px 0 #e2e8f0;
}
