/* ===== CSS VARIABLES (Dark Mode) ===== */
:root {
  --bg-primary: #0a0d14; /* Deep dark background */
  --bg-secondary: #101520; /* Sidebar background */
  --bg-card: #151a28; /* Card/Table background */
  --bg-hover: #1e2536; /* Hover state */
  --accent: #2563eb; /* Primary blue */
  --accent-light: #3b82f6;
  --accent-dark: #1d4ed8;
  --success: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
  --text-primary: #f8fafc;
  --text-secondary: #cbd5e1;
  --text-muted: #64748b;
  --border: #1e2638; /* Soft borders */
  --sidebar-width: 250px;
  --radius: 12px;
  --shadow: 0 4px 12px rgba(0,0,0,0.1);
  --transition: 0.2s ease;
}

/* ===== RESET ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }
body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.6;
}
a { color: var(--text-secondary); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--text-primary); }

/* ===== LAYOUT ===== */
.sidebar {
  position: fixed;
  top: 0; left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 100;
  overflow-y: auto;
  transition: width var(--transition);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 24px 20px;
  white-space: nowrap;
}
.brand-icon {
  background: var(--accent-light);
  color: white;
  width: 32px; height: 32px;
  min-width: 32px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-weight: bold; font-size: 1.2rem;
}
.brand-text { font-size: 1.25rem; font-weight: 700; color: var(--text-primary); letter-spacing: -0.01em; transition: opacity var(--transition); }

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  margin: 0 12px 16px;
  background: rgba(255, 255, 255, 0.03);
  border-radius: var(--radius);
  border: 1px solid rgba(255,255,255,0.05);
  white-space: nowrap;
  overflow: hidden;
}
.user-avatar {
  width: 38px; height: 38px;
  min-width: 38px;
  border-radius: 50%;
  background: #334155;
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 1rem; color: #cbd5e1;
}
.user-info { transition: opacity var(--transition); }
.user-name { font-weight: 600; font-size: 0.95rem; line-height: 1.2; color: var(--text-primary); }
.user-role { font-size: 0.8rem; color: var(--text-muted); margin-top: 2px;}

.sidebar-nav { flex: 1; padding: 12px; display: flex; flex-direction: column; gap: 4px; overflow-x: hidden; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  color: var(--text-secondary);
  font-size: 0.95rem;
  font-weight: 500;
  transition: background-color var(--transition), color var(--transition);
  border-radius: 8px;
  cursor: pointer;
  white-space: nowrap;
}
.nav-item:hover, .nav-item.active {
  background: var(--bg-hover);
  color: var(--text-primary);
}
.nav-icon { min-width: 20px; color: var(--text-muted); transition: color var(--transition); }
.nav-item:hover .nav-icon, .nav-item.active .nav-icon { color: var(--text-primary); }
.nav-text { transition: opacity var(--transition); }

.sidebar-footer { padding: 12px; border-top: 1px solid var(--border); white-space: nowrap; overflow: hidden; }

.main-content {
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: margin-left var(--transition);
}

/* ===== SIDEBAR TOGGLE TAB ===== */
.sidebar-toggle-tab {
  position: fixed;
  top: 50%;
  left: var(--sidebar-width);
  transform: translateY(-50%);
  width: 40px;
  height: 56px;
  background-color: var(--accent);
  border: none;
  border-radius: 0 16px 16px 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  cursor: pointer;
  box-shadow: 2px 0 8px rgba(0,0,0,0.2);
  transition: left var(--transition), background-color var(--transition);
  z-index: 101;
}
.sidebar-toggle-tab:hover {
  background-color: var(--accent-light);
}

/* ===== SIDEBAR COLLAPSED ===== */
body.sidebar-collapsed .sidebar { width: 80px; }
body.sidebar-collapsed .sidebar-toggle-tab { left: 80px; }
body.sidebar-collapsed .main-content { margin-left: 80px; }
body.sidebar-collapsed .brand-text, 
body.sidebar-collapsed .user-info, 
body.sidebar-collapsed .nav-text {
  opacity: 0;
  display: none;
}
body.sidebar-collapsed .sidebar-brand { justify-content: center; padding: 24px 0; }
body.sidebar-collapsed .sidebar-user { padding: 12px 0; justify-content: center; }
body.sidebar-collapsed .nav-item { justify-content: center; }

.topbar {
  padding: 24px 32px 0;
  background: transparent;
  position: relative;
  border: none;
}
.page-title { font-size: 1.5rem; font-weight: 700; color: var(--text-primary); }

.content-wrapper { padding: 24px 32px; flex: 1; }

/* ===== ALERTS (TOASTS) ===== */
.alert-container {
  position: fixed;
  top: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 12px;
  pointer-events: none;
}
.alert {
  padding: 14px 20px;
  border-radius: var(--radius);
  font-size: 0.95rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.2);
  transform: translateX(120%);
  opacity: 0;
  animation: toastSlideIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
  max-width: 350px;
  pointer-events: auto;
}
.alert.hide {
  animation: toastSlideOut 0.3s ease-in forwards;
}
.alert-success { background: #10b981; color: white; border: 1px solid rgba(255,255,255,0.1); }
.alert-error { background: #ef4444; color: white; border: 1px solid rgba(255,255,255,0.1); }

@keyframes toastSlideIn { to { transform: translateX(0); opacity: 1; } }
@keyframes toastSlideOut { to { transform: translateX(120%); opacity: 0; } }

/* ===== CARDS ===== */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 4px 6px rgba(0,0,0,0.05);
  overflow: hidden;
}

/* ===== STATS GRID ===== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 24px;
  display: flex;
  align-items: center;
  gap: 16px;
  transition: box-shadow var(--transition);
}
.stat-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.stat-card.stat-alert { border-color: rgba(245,158,11,0.3); }
.stat-icon { font-size: 2.2rem; }
.stat-label { font-size: 0.85rem; color: var(--text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 4px; }
.stat-value { font-size: 1.8rem; font-weight: 700; color: var(--text-primary); line-height: 1.1; }

/* ===== TABLE ===== */
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 0.95rem; }
.table thead th {
  background: var(--bg-card);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 16px 20px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
.table tbody td { padding: 16px 20px; border-bottom: 1px solid rgba(255,255,255,0.03); vertical-align: middle; color: var(--text-secondary); }
.table tbody tr:hover td { background: rgba(255,255,255,0.02); }
.table tbody tr:last-child td { border-bottom: none; }
.table .row-alert td { background: rgba(245,158,11,0.05); }
.actions { display: flex; gap: 10px; align-items: center; }

/* ===== BADGES ===== */
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  color: white;
}
.badge-success, .badge-active, .badge-qris { background: #10b981; }
.badge-danger, .badge-expired { background: #ef4444; }
.badge-warning, .badge-trial, .badge-transfer { background: #f59e0b; }
.badge-cash { background: #6366f1; }
.badge-role-superadmin { background: #ef4444; }
.badge-role-owner { background: #8b5cf6; } /* purple */
.badge-role-manager { background: #10b981; } /* green */
.badge-role-cashier { background: #d97706; } /* orange/yellow */

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  border: none;
  font-family: inherit;
  text-decoration: none;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: white; }
.btn-primary:hover:not(:disabled) { background: var(--accent-light); }
.btn-secondary { background: rgba(255,255,255,0.1); color: var(--text-primary); }
.btn-secondary:hover { background: rgba(255,255,255,0.15); }
.btn-info { background: #3b82f6; color: white; }
.btn-info:hover { background: #60a5fa; }
.btn-danger { background: #ef4444; color: white; }
.btn-danger:hover { background: #f87171; }
.btn-sm { padding: 6px 12px; font-size: 0.8rem; border-radius: 6px; }
.btn-icon { padding: 8px; border-radius: 6px; display: inline-flex; align-items: center; justify-content: center; }
.btn-full { width: 100%; justify-content: center; }

/* ===== FORMS ===== */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}
.form-group label { font-size: 0.85rem; font-weight: 600; color: var(--text-secondary); }
.form-group input, .form-group select, .form-group textarea {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  color: var(--text-primary);
  font-size: 0.9rem;
  font-family: inherit;
  transition: border-color var(--transition);
}
.form-group input:focus, .form-group select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(99,102,241,0.15);
}
select option {
  background-color: var(--bg-secondary);
  color: var(--text-primary);
}
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0 20px; }
.form-actions { display: flex; gap: 10px; margin-top: 8px; }
.form-inline { display: flex; gap: 16px; align-items: flex-end; flex-wrap: wrap; }

.page-actions {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
  align-items: center;
}
.search-form { display: flex; gap: 8px; margin-bottom: 20px; }
.search-form input { flex: 1; background: var(--bg-card); border: 1px solid var(--border); border-radius: 8px; padding: 10px 14px; color: var(--text-primary); font-size: 0.9rem; font-family: inherit; }
.search-form input:focus { outline: none; border-color: var(--accent); }

/* ===== SECTION TITLE ===== */
.section-title { font-size: 1rem; font-weight: 700; color: var(--text-primary); margin: 24px 0 12px; }

/* ===== AUTH ===== */
.auth-bg-shapes {
  position: fixed;
  top: 0; left: 0; width: 100%; height: 100%;
  overflow: hidden;
  z-index: 0;
  pointer-events: none;
}
.auth-bg-shapes .shape {
  position: absolute;
  filter: blur(100px);
  opacity: 0.65;
  border-radius: 50%;
  animation: float 12s infinite alternate ease-in-out;
}
.shape-1 {
  width: 500px; height: 500px;
  background: linear-gradient(135deg, #4f46e5, #0ea5e9);
  top: -200px; left: -100px;
}
.shape-2 {
  width: 450px; height: 450px;
  background: linear-gradient(135deg, #ec4899, #8b5cf6);
  bottom: -150px; right: -100px;
  animation-delay: -6s;
}
.shape-3 {
  width: 400px; height: 400px;
  background: linear-gradient(135deg, #10b981, #3b82f6);
  top: 40%; left: 30%;
  animation-delay: -3s;
  opacity: 0.4;
}
@keyframes float {
  0% { transform: translate(0, 0) scale(1); }
  100% { transform: translate(30px, 50px) scale(1.1); }
}

.auth-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  z-index: 1;
  background: linear-gradient(135deg, #0f172a 0%, #1e1b4b 100%);
  overflow: hidden;
}
.auth-card {
  background: rgba(16, 21, 32, 0.6);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 20px;
  padding: 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 24px 40px rgba(0, 0, 0, 0.4);
}
.auth-header { text-align: center; margin-bottom: 28px; }
.auth-title { 
  font-size: 1.8rem; 
  font-weight: 800; 
  background: linear-gradient(to right, #60a5fa, #c084fc);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.auth-subtitle { font-size: 0.95rem; color: var(--text-muted); margin-top: 6px; }
.auth-footer { text-align: center; margin-top: 16px; font-size: 0.85rem; color: var(--text-muted); }
.auth-card .btn-primary {
  background: linear-gradient(135deg, #4f46e5, #9333ea);
  border: none;
  box-shadow: 0 4px 15px rgba(99, 102, 241, 0.4);
  transition: all 0.3s ease;
}
.auth-card .btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(99, 102, 241, 0.6);
  background: linear-gradient(135deg, #4338ca, #7e22ce);
}

/* ===== POS LAYOUT ===== */
.pos-layout {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 20px;
  height: calc(100vh - 110px);
}
.pos-products { overflow-y: auto; padding-right: 4px; }
.search-bar { margin-bottom: 16px; }
.search-bar input {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 16px;
  color: var(--text-primary);
  font-size: 0.9rem;
  font-family: inherit;
}
.search-bar input:focus { outline: none; border-color: var(--accent); }

.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
}
.product-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  cursor: pointer;
  transition: all var(--transition);
  text-align: center;
}
.product-card:hover { border-color: var(--accent); transform: translateY(-2px); box-shadow: 0 4px 16px rgba(99,102,241,0.2); }
.product-card.out-of-stock { opacity: 0.4; cursor: not-allowed; }
.product-name { font-weight: 600; font-size: 0.9rem; margin-bottom: 4px; }
.product-sku { font-size: 0.75rem; color: var(--text-muted); margin-bottom: 8px; font-family: monospace; }
.product-price { font-size: 1rem; font-weight: 700; color: var(--accent-light); }
.product-stock { font-size: 0.75rem; color: var(--text-muted); margin-top: 6px; }
.stock-low { color: var(--warning) !important; }

/* ===== POS CART ===== */
.pos-cart {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.cart-title { font-size: 1rem; font-weight: 700; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.cart-items { flex: 1; overflow-y: auto; padding: 12px; }
.cart-empty { color: var(--text-muted); text-align: center; padding: 40px 0; font-size: 0.9rem; }
.cart-item { display: flex; align-items: center; gap: 8px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.cart-item-info { flex: 1; min-width: 0; }
.cart-item-name { font-size: 0.85rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cart-item-price { font-size: 0.75rem; color: var(--text-muted); }
.cart-item-qty { display: flex; align-items: center; gap: 6px; }
.qty-btn { background: var(--bg-hover); border: 1px solid var(--border); color: var(--text-primary); width: 24px; height: 24px; border-radius: 6px; cursor: pointer; font-size: 1rem; display: flex; align-items: center; justify-content: center; transition: background var(--transition); }
.qty-btn:hover { background: var(--accent); }
.qty-val { font-weight: 700; min-width: 24px; text-align: center; font-size: 0.9rem; }
.cart-item-subtotal { font-size: 0.85rem; font-weight: 700; color: var(--accent-light); white-space: nowrap; }
.remove-btn { background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 0.9rem; padding: 2px; line-height: 1; }
.remove-btn:hover { color: var(--danger); }

.cart-summary { padding: 12px 16px; border-top: 1px solid var(--border); }
.summary-row { display: flex; justify-content: space-between; align-items: center; font-size: 1rem; }
.summary-row strong { font-size: 1.3rem; color: var(--accent-light); }

.payment-section { padding: 12px 16px; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 10px; }
.payment-section label { font-size: 0.8rem; font-weight: 600; color: var(--text-secondary); }
.payment-section select, .payment-section input[type="number"] {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.9rem;
  width: 100%;
}
.change-display { font-size: 0.85rem; color: var(--success); font-weight: 600; }

/* ===== RECEIPT ===== */
.receipt-wrapper { display: flex; justify-content: center; padding: 20px 0; }
.receipt {
  background: white;
  color: #111;
  width: 300px;
  padding: 20px;
  border-radius: 8px;
  font-family: 'Courier New', monospace;
  font-size: 0.85rem;
}
.receipt-header { text-align: center; margin-bottom: 12px; }
.receipt-header h2 { font-size: 1.1rem; }
.receipt-meta p { margin: 2px 0; }
.receipt-table { width: 100%; border-collapse: collapse; margin: 8px 0; }
.receipt-table th, .receipt-table td { padding: 4px 0; }
.receipt-table th { border-bottom: 1px dashed #ccc; }
.receipt-total { display: flex; justify-content: space-between; margin: 4px 0; font-weight: bold; }
.receipt-footer { text-align: center; margin-top: 12px; font-size: 0.75rem; color: #666; }

/* ===== PAGINATION ===== */
.pagination { display: flex; align-items: center; gap: 12px; justify-content: space-between; margin-top: 20px; flex-wrap: wrap; }
.pagination-controls { display: flex; align-items: center; gap: 6px; }
.page-info { font-size: 0.85rem; color: var(--text-muted); }

/* ===== ERROR PAGE ===== */
.error-page { text-align: center; padding: 80px 20px; }
.error-page h1 { font-size: 5rem; font-weight: 900; color: var(--accent); line-height: 1; }
.error-page p { color: var(--text-muted); margin: 12px 0 24px; font-size: 1.1rem; }

/* ===== FILTER FORM ===== */
.filter-form { margin-bottom: 24px; }
.filter-select { appearance: none; -webkit-appearance: none; }
.filter-select:focus { outline: none; border-color: var(--accent); }
.filter-badges a { transition: all var(--transition); }
.card-header { flex-wrap: wrap; }

/* ===== RESPONSIVE ===== */
@media (max-width: 1024px) {
  .pos-layout { grid-template-columns: 1fr; }
  .pos-cart { max-height: 400px; }
}

@media (max-width: 768px) {
  :root { --sidebar-width: 0px; }
  .sidebar {
    transform: translateX(-100%);
    width: 250px;
  }
  body.sidebar-open .sidebar {
    transform: translateX(0);
  }
  .sidebar-toggle-tab { left: 0; }
  body.sidebar-open .sidebar-toggle-tab { left: 250px; }
  .main-content { margin-left: 0 !important; }
  body.sidebar-collapsed .main-content { margin-left: 0 !important; }
  
  .topbar { padding: 16px 16px 0; }
  .content-wrapper { padding: 16px; }
  .page-title { font-size: 1.2rem; }
  
  .form-grid { grid-template-columns: 1fr; }
  .form-group[style*="grid-column: span 2"] { grid-column: span 1 !important; }
  
  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .stat-card { padding: 16px; }
  .stat-value { font-size: 1.3rem; }
  
  .table { font-size: 0.85rem; }
  .table thead th, .table tbody td { padding: 12px 10px; }
  
  .pagination { justify-content: center; flex-direction: column; gap: 8px; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .page-actions { flex-direction: column; align-items: stretch; }
  .auth-card { padding: 24px; margin: 16px; }
}

/* ===== PRINT STYLES ===== */
@media print {
  body > *:not(.receipt-wrapper),
  .sidebar, .topbar, .page-actions, .btn, .alert, .pagination { display: none !important; }
  .receipt-wrapper { display: flex !important; padding: 0; }
  .receipt { box-shadow: none; }
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-secondary); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

