/* =====================================================
   Barokah POS – Main Stylesheet
   ===================================================== */

:root {
  --primary:     #2563eb;
  --primary-dark:#1d4ed8;
  --sidebar-bg:  #0f172a;
  --sidebar-w:   240px;
  --sidebar-collapsed: 68px;
  --topbar-h:    56px;
  --radius:      10px;
  --shadow:      0 2px 8px rgba(0,0,0,.08);
  --transition:  .25s ease;
}

/* ── Base ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; font-family: 'Segoe UI', system-ui, sans-serif; background: #f1f5f9; color: #1e293b; }
a { text-decoration: none; color: inherit; }

/* ── Auth Layout ─────────────────────────────────── */
.auth-body { background: linear-gradient(135deg, #1e40af 0%, #0f172a 100%); min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.auth-wrapper { width: 100%; max-width: 420px; padding: 16px; }
.auth-card { background: #fff; border-radius: 16px; padding: 40px 36px; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.auth-logo { text-align: center; font-size: 56px; color: var(--primary); margin-bottom: 8px; }
.auth-title { text-align: center; font-size: 22px; font-weight: 700; margin: 0; }
.auth-subtitle { text-align: center; color: #64748b; margin-bottom: 24px; }
.auth-footer { text-align: center; margin-top: 16px; }
.btn-login { height: 44px; font-weight: 600; letter-spacing: .3px; }

/* ── Main Layout ─────────────────────────────────── */
.main-layout { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  position: fixed;
  left: 0; top: 0; bottom: 0;
  z-index: 100;
  transition: width var(--transition);
  overflow: hidden;
}
.sidebar.collapsed { width: var(--sidebar-collapsed); }

/* Collapsed sidebar – icons only */
.sidebar.collapsed .sidebar-header { justify-content: center; padding: 14px 8px; }
.sidebar.collapsed .sidebar-brand { display: none; }
.sidebar.collapsed .sidebar-toggle-btn { width: 40px; display: flex; justify-content: center; }

.sidebar.collapsed .sidebar-user { justify-content: center; padding: 12px 8px; }
.sidebar.collapsed .user-info { display: none; }

.sidebar.collapsed .nav-label { height: 0; padding: 0; overflow: hidden; opacity: 0; }

.sidebar.collapsed .sidebar-nav li a {
  justify-content: center;
  padding: 11px 0;
  margin: 1px 6px;
  position: relative;
}
.sidebar.collapsed .sidebar-nav li a span { display: none; }

/* Tooltip on hover when collapsed */
.sidebar.collapsed .sidebar-nav li a::after {
  content: attr(data-label);
  position: absolute;
  left: calc(100% + 10px);
  top: 50%;
  transform: translateY(-50%);
  background: #1e293b;
  color: #e2e8f0;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  padding: 5px 10px;
  border-radius: 6px;
  pointer-events: none;
  opacity: 0;
  transition: opacity .15s;
  z-index: 200;
  border: 1px solid rgba(255,255,255,.1);
}
.sidebar.collapsed .sidebar-nav li a:hover::after { opacity: 1; }

.sidebar.collapsed .sidebar-footer { padding: 8px 6px; }
.sidebar.collapsed .logout-btn { justify-content: center; padding: 11px 0; }
.sidebar.collapsed .logout-btn span { display: none; }

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  border-bottom: 1px solid rgba(255,255,255,.06);
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  white-space: nowrap;
}
.sidebar-brand i { font-size: 22px; color: var(--primary); flex-shrink: 0; }
.sidebar-toggle-btn { background: none; border: none; color: #94a3b8; font-size: 20px; cursor: pointer; padding: 4px; border-radius: 6px; }
.sidebar-toggle-btn:hover { color: #fff; background: rgba(255,255,255,.08); }

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid rgba(255,255,255,.06);
}
.avatar-circle {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px;
  flex-shrink: 0;
}
.user-info { overflow: hidden; }
.user-name { color: #e2e8f0; font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 11px; }
.badge-role { display: inline-block; padding: 1px 8px; border-radius: 20px; font-size: 10px; font-weight: 600; text-transform: capitalize; }
.badge-role.admin   { background: rgba(239,68,68,.2); color: #fca5a5; }
.badge-role.manager { background: rgba(245,158,11,.2); color: #fcd34d; }
.badge-role.cashier { background: rgba(59,130,246,.2); color: #93c5fd; }

/* Sidebar Nav */
.sidebar-nav { list-style: none; padding: 8px 0; margin: 0; flex: 1; overflow-y: auto; overflow-x: hidden; }
.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,.1); border-radius: 2px; }
.nav-label {
  color: #475569;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: 12px 16px 4px;
  white-space: nowrap;
  overflow: hidden;
}
.sidebar-nav li a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  color: #94a3b8;
  font-size: 13px;
  font-weight: 500;
  border-radius: 8px;
  margin: 1px 8px;
  transition: all .15s;
  white-space: nowrap;
}
.sidebar-nav li a i { font-size: 18px; flex-shrink: 0; }
.sidebar-nav li a:hover { color: #fff; background: rgba(255,255,255,.08); }
.sidebar-nav li.active a { color: #fff; background: var(--primary); }

.sidebar-footer { padding: 12px; border-top: 1px solid rgba(255,255,255,.06); }
.logout-btn {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  color: #94a3b8;
  font-size: 13px;
  border-radius: 8px;
  cursor: pointer;
  transition: all .15s;
  white-space: nowrap;
}
.logout-btn:hover { color: #f87171; background: rgba(248,113,113,.08); }
.logout-btn i { font-size: 18px; flex-shrink: 0; }

/* Main Content */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  transition: margin-left var(--transition);
  min-height: 100vh;
}
.sidebar.collapsed ~ .main-content { margin-left: var(--sidebar-collapsed); }

/* Topbar */
.topbar {
  height: var(--topbar-h);
  background: #fff;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: var(--shadow);
}
.topbar-toggle { background: none; border: none; font-size: 22px; cursor: pointer; color: #64748b; padding: 4px 8px; border-radius: 6px; display: none; }
.topbar-title { font-weight: 700; font-size: 15px; flex: 1; }
.topbar-right { display: flex; align-items: center; gap: 8px; }
.topbar-date { color: #64748b; font-size: 13px; }

/* Page Content */
.page-content { padding: 24px; flex: 1; }

/* ── Stat Cards ─────────────────────────────────── */
.stat-card {
  background: #fff;
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow);
  border-left: 4px solid transparent;
}
.stat-card--blue   { border-left-color: #2563eb; }
.stat-card--green  { border-left-color: #16a34a; }
.stat-card--orange { border-left-color: #ea580c; }
.stat-card--red    { border-left-color: #dc2626; }
.stat-card--purple { border-left-color: #7c3aed; }
.stat-icon {
  width: 48px; height: 48px;
  border-radius: 12px;
  background: #f1f5f9;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
  color: var(--primary);
  flex-shrink: 0;
}
.stat-card--green  .stat-icon { color: #16a34a; }
.stat-card--orange .stat-icon { color: #ea580c; }
.stat-card--red    .stat-icon { color: #dc2626; }
.stat-card--purple .stat-icon { color: #7c3aed; }
.stat-value { font-size: 20px; font-weight: 700; line-height: 1; }
.stat-label { color: #64748b; font-size: 13px; margin-top: 4px; }

/* ── Cards ────────────────────────────────────────── */
.card { border: 1px solid #e2e8f0; box-shadow: var(--shadow); border-radius: var(--radius); }
.card-header { background: #f8fafc; border-bottom: 1px solid #e2e8f0; padding: 12px 16px; }

/* ── Categories ─────────────────────────────────── */
.category-card { border-radius: var(--radius); overflow: hidden; }
.category-color-bar { height: 4px; }

/* ── Customer Avatar ─────────────────────────────── */
.avatar-sm {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 12px;
  flex-shrink: 0;
}

/* ── Table Fixes ─────────────────────────────────── */
.table { margin: 0; }
.table th { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .5px; color: #64748b; background: #f8fafc; }

/* ── Alerts ──────────────────────────────────────── */
.alert { border-radius: var(--radius); }

/* ── Responsive ──────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar { left: calc(-1 * var(--sidebar-w)); width: var(--sidebar-w); }
  .sidebar.mobile-open { left: 0; box-shadow: 4px 0 24px rgba(0,0,0,.4); }
  .main-content { margin-left: 0 !important; }
  .topbar-toggle { display: block; }
  .topbar-date { display: none; }
  .page-content { padding: 16px 12px; }
  .stat-card { padding: 14px; gap: 10px; }
  .stat-icon { width: 40px; height: 40px; font-size: 18px; }
  .stat-value { font-size: 16px; }
  .stat-label { font-size: 11px; }
}

/* Sidebar backdrop overlay */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 99;
}
.sidebar-backdrop.show { display: block; }

@media (max-width: 576px) {
  .page-content { padding: 12px 8px; }
  .topbar { padding: 0 12px; gap: 8px; }
  .topbar-title { font-size: 14px; }
  .card-header { padding: 10px 12px; }
}

/* ── POS Topbar ──────────────────────────────────── */
.pos-topbar {
  height: 52px;
  background: var(--sidebar-bg);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px;
  color: #e2e8f0;
  font-size: 14px;
}
.pos-back-btn { color: #94a3b8; font-size: 13px; }
.pos-back-btn:hover { color: #fff; }
.pos-brand { font-weight: 700; color: #fff; font-size: 15px; }
.pos-user { color: #94a3b8; font-size: 13px; }
