/* ============================================================
   assets/css/style.css — POS Installment System
   Bootstrap 5.3 + Custom Design System
============================================================ */

/* ── Theme variables ─────────────────────────────────────── */
:root {
  --bg:       #0d0f14;
  --surface:  #161b24;
  --surface2: #1e2533;
  --surface3: #242d3d;
  --accent:   #f59e0b;
  --accent2:  #fb923c;
  --text:     #e2e8f0;
  --muted:    #64748b;
  --border:   #2a3244;
  --green:    #22c55e;
  --red:      #ef4444;
  --blue:     #3b82f6;
  --purple:   #a855f7;
  --sidebar-w: 240px;
}
body.light-mode {
  --bg:       #f1f5f9;
  --surface:  #ffffff;
  --surface2: #f8fafc;
  --surface3: #f1f5f9;
  --accent:   #d97706;
  --accent2:  #ea580c;
  --text:     #0f172a;
  --muted:    #64748b;
  --border:   #e2e8f0;
}

/* ── Reset & base ────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: 'Noto Sans Thai', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
}
a { color: var(--accent); text-decoration: none; }

/* ── Layout ──────────────────────────────────────────────── */
#wrapper    { display: flex; min-height: 100vh; }
#sidebar    { width: var(--sidebar-w); background: var(--surface); border-right: 1px solid var(--border); display: flex; flex-direction: column; position: fixed; top: 0; left: 0; height: 100vh; z-index: 100; transition: transform .25s; }
#main       { margin-left: var(--sidebar-w); flex: 1; display: flex; flex-direction: column; min-height: 100vh; }
.topbar     { background: var(--surface); border-bottom: 1px solid var(--border); padding: 0 24px; height: 56px; display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 99; }
.page-content { padding: 24px; flex: 1; }

/* ── Sidebar ─────────────────────────────────────────────── */
.sidebar-brand { padding: 20px 16px 12px; border-bottom: 1px solid var(--border); }
.sidebar-brand .brand-icon { width: 36px; height: 36px; border-radius: 10px; background: linear-gradient(135deg, var(--accent), var(--accent2)); display: flex; align-items: center; justify-content: center; font-size: 18px; color: #000; }
.brand-name  { font-size: 13px; font-weight: 800; line-height: 1.2; margin-left: 10px; }
.brand-sub   { font-size: 10px; color: var(--muted); }
.sidebar-nav { flex: 1; overflow-y: auto; padding: 8px 0; }
.nav-section { font-size: 10px; font-weight: 700; color: var(--text); opacity: .5; text-transform: uppercase; letter-spacing: .6px; padding: 12px 16px 4px; }
.nav-item    { display: flex; align-items: center; gap: 10px; padding: 9px 16px; color: var(--text); font-size: 13px; font-weight: 500; border-radius: 8px; margin: 1px 8px; cursor: pointer; transition: .15s; text-decoration: none; opacity: .85; }
.nav-item:hover { background: rgba(245,158,11,.1); color: var(--accent); opacity: 1; }
.nav-item.active  { background: rgba(245,158,11,.15); color: var(--accent); opacity: 1; font-weight: 700; }
.nav-item i  { font-size: 16px; width: 20px; text-align: center; }
.sidebar-footer { padding: 12px 16px; border-top: 1px solid var(--border); }
.user-name   { font-size: 13px; font-weight: 700; }
.user-role   { font-size: 11px; color: var(--muted); }

/* ── Cards ───────────────────────────────────────────────── */
.card-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
}
.stat-icon  { width: 44px; height: 44px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 20px; flex-shrink: 0; }
.stat-val   { font-size: 22px; font-weight: 800; font-family: 'JetBrains Mono', monospace; }
.stat-label { font-size: 11px; color: var(--muted); font-weight: 600; margin-top: 2px; }

/* ── Table ───────────────────────────────────────────────── */
.table-pos { width: 100%; border-collapse: collapse; font-size: 13px; }
.table-pos thead tr { border-bottom: 2px solid var(--border); }
.table-pos th { padding: 10px 12px; text-align: left; font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; white-space: nowrap; }
.table-pos td { padding: 11px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table-pos tbody tr:hover { background: var(--surface2); }
.table-pos tbody tr:last-child td { border-bottom: none; }

/* ── Buttons ─────────────────────────────────────────────── */
.btn-primary-pos {
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #000; border: none; border-radius: 8px;
  padding: 8px 16px; font-size: 13px; font-weight: 700;
  cursor: pointer; font-family: 'Noto Sans Thai', sans-serif;
  display: inline-flex; align-items: center; gap: 4px;
  transition: opacity .15s; text-decoration: none;
}
.btn-primary-pos:hover { opacity: .85; color: #000; }
.btn-outline-pos {
  background: transparent; color: var(--text);
  border: 1px solid var(--border); border-radius: 8px;
  padding: 8px 16px; font-size: 13px; font-weight: 600;
  cursor: pointer; font-family: 'Noto Sans Thai', sans-serif;
  display: inline-flex; align-items: center; gap: 4px;
  transition: .15s; text-decoration: none;
}
.btn-outline-pos:hover { border-color: var(--accent); color: var(--accent); }
.btn-danger-pos {
  background: rgba(239,68,68,.15); color: var(--red);
  border: 1px solid rgba(239,68,68,.3); border-radius: 8px;
  padding: 6px 10px; font-size: 12px; font-weight: 600;
  cursor: pointer; font-family: 'Noto Sans Thai', sans-serif;
  display: inline-flex; align-items: center; gap: 4px;
  transition: .15s;
}
.btn-danger-pos:hover { background: rgba(239,68,68,.25); }
.btn-edit-pos {
  background: rgba(245,158,11,.12); color: var(--accent);
  border: 1px solid rgba(245,158,11,.25); border-radius: 8px;
  padding: 6px 10px; font-size: 12px;
  cursor: pointer; display: inline-flex; align-items: center; gap: 4px;
  transition: .15s;
}
.btn-edit-pos:hover { background: rgba(245,158,11,.22); }
.w-100 { width: 100% !important; }

/* ── Form controls ───────────────────────────────────────── */
.form-ctrl {
  background: var(--surface2); border: 1px solid var(--border);
  color: var(--text); border-radius: 8px;
  padding: 9px 12px; font-size: 13px; width: 100%;
  font-family: 'Noto Sans Thai', sans-serif; transition: border-color .15s;
}
.form-ctrl:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(245,158,11,.12); outline: none; }
.form-ctrl option { background: var(--surface2); }
.lbl { font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; display: block; margin-bottom: 5px; }

/* ── Modal ───────────────────────────────────────────────── */
.modal-pos { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 1050; align-items: center; justify-content: center; padding: 16px; }
.modal-pos.show { display: flex; }
.modal-box { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; width: 100%; max-height: 90vh; overflow-y: auto; }
.modal-header-pos { padding: 20px 24px 0; display: flex; align-items: center; justify-content: space-between; }
.modal-header-pos h4 { font-size: 16px; font-weight: 800; }
.modal-body-pos   { padding: 20px 24px; }
.modal-footer-pos { padding: 0 24px 20px; display: flex; gap: 8px; justify-content: flex-end; }
.modal-close { background: none; border: none; color: var(--muted); font-size: 18px; cursor: pointer; padding: 4px 8px; border-radius: 6px; }
.modal-close:hover { color: var(--text); background: var(--surface2); }

/* ── Badges ──────────────────────────────────────────────── */
.badge-active   { background: rgba(34,197,94,.15);  color: #22c55e; border-radius: 20px; padding: 3px 10px; font-size: 11px; font-weight: 700; }
.badge-inactive { background: rgba(100,116,139,.15); color: var(--muted); border-radius: 20px; padding: 3px 10px; font-size: 11px; font-weight: 700; }
.badge-danger   { background: rgba(239,68,68,.15);  color: var(--red); border-radius: 20px; padding: 3px 10px; font-size: 11px; font-weight: 700; }
.badge-warning  { background: rgba(245,158,11,.15); color: var(--accent); border-radius: 20px; padding: 3px 10px; font-size: 11px; font-weight: 700; }
.badge-manager  { background: rgba(168,85,247,.15); color: var(--purple); border-radius: 20px; padding: 3px 10px; font-size: 11px; font-weight: 700; }
.badge-superadmin { background: rgba(245,158,11,.2); color: var(--accent); border-radius: 20px; padding: 3px 10px; font-size: 11px; font-weight: 700; }
.badge-admin    { background: rgba(59,130,246,.15); color: var(--blue); border-radius: 20px; padding: 3px 10px; font-size: 11px; font-weight: 700; }
.badge-user     { background: rgba(100,116,139,.15); color: var(--muted); border-radius: 20px; padding: 3px 10px; font-size: 11px; font-weight: 700; }

/* ── Toast ───────────────────────────────────────────────── */
#toast-container { position: fixed; bottom: 24px; right: 24px; z-index: 9999; display: flex; flex-direction: column; gap: 8px; }
.toast-msg { padding: 12px 18px; border-radius: 10px; font-size: 13px; font-weight: 600; min-width: 220px; box-shadow: 0 4px 20px rgba(0,0,0,.3); animation: slideIn .2s ease; }
.toast-success { background: rgba(34,197,94,.15); border: 1px solid rgba(34,197,94,.3); color: #86efac; }
.toast-error   { background: rgba(239,68,68,.15);  border: 1px solid rgba(239,68,68,.3);  color: #fca5a5; }
.toast-info    { background: rgba(59,130,246,.15); border: 1px solid rgba(59,130,246,.3); color: #93c5fd; }
@keyframes slideIn { from { transform: translateX(40px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ── Misc ────────────────────────────────────────────────── */
.mono { font-family: 'JetBrains Mono', monospace; }
.page-title { font-size: 20px; font-weight: 800; margin: 0; }
.page-sub   { font-size: 12px; color: var(--muted); margin: 0; }
.divider    { border: none; border-top: 1px solid var(--border); margin: 16px 0; }
.loading-spinner { display: inline-block; width: 16px; height: 16px; border: 2px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin .6s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 768px) {
  #sidebar { transform: translateX(-100%); }
  #sidebar.open { transform: translateX(0); }
  #main { margin-left: 0; }
  .page-content { padding: 16px; }
}
