/* ==================== RESET & BASE ==================== */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --primary:       #4f46e5;
  --primary-dark:  #3730a3;
  --primary-light: #eef2ff;
  --success:       #059669;
  --danger:        #dc2626;
  --warning:       #d97706;
  --bg:            #f8fafc;
  --surface:       #ffffff;
  --text:          #0f172a;
  --text-muted:    #64748b;
  --border:        #e2e8f0;
  --radius:        12px;
  --radius-sm:     8px;
  --shadow:        0 1px 3px rgba(0,0,0,0.07), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md:     0 4px 16px rgba(0,0,0,0.10);
}

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}

/* ==================== LOGIN PAGE ==================== */
.login-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
  background: linear-gradient(135deg, #1e1b4b 0%, #312e81 40%, #4f46e5 100%);
  position: relative;
  overflow: hidden;
}

.login-wrapper::before {
  content: '';
  position: absolute;
  width: 500px; height: 500px;
  border-radius: 50%;
  background: rgba(255,255,255,0.03);
  top: -150px; right: -100px;
}

.login-wrapper::after {
  content: '';
  position: absolute;
  width: 300px; height: 300px;
  border-radius: 50%;
  background: rgba(255,255,255,0.04);
  bottom: -80px; left: -80px;
}

.login-box {
  background: var(--surface);
  width: 100%;
  max-width: 420px;
  border-radius: 20px;
  padding: 40px 36px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
  position: relative;
  z-index: 1;
}

.login-box .logo {
  text-align: center;
  margin-bottom: 28px;
}

.login-box .logo .logo-icon {
  width: 64px; height: 64px;
  background: var(--primary-light);
  border-radius: 16px;
  display: flex; align-items: center; justify-content: center;
  font-size: 30px;
  margin: 0 auto 14px;
}

.login-box .logo h1 {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
}

.login-box .logo p {
  color: var(--text-muted);
  font-size: 13px;
  margin-top: 4px;
}

.role-tabs {
  display: flex;
  gap: 8px;
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 4px;
  margin-bottom: 24px;
}

.role-tab {
  flex: 1;
  padding: 8px;
  text-align: center;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  transition: all 0.2s;
  border: none;
  background: transparent;
}

.role-tab.active {
  background: var(--surface);
  color: var(--primary);
  box-shadow: var(--shadow);
}

/* ==================== FORM ==================== */
.form-group { margin-bottom: 16px; }

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text);
}

.form-group input,
.form-group select {
  width: 100%;
  padding: 11px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  background: var(--surface);
  color: var(--text);
}

.form-group input:focus,
.form-group select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79,70,229,0.12);
}

/* ==================== BUTTONS ==================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 18px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }

.btn-primary  { background: var(--primary); color: #fff; width: 100%; }
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); }
.btn-success  { background: var(--success); color: #fff; }
.btn-danger   { background: var(--danger);  color: #fff; }
.btn-secondary { background: var(--border); color: var(--text); }
.btn-secondary:hover { background: #d1d5db; }
.btn-sm { padding: 6px 12px; font-size: 12px; }

/* ==================== ALERTS ==================== */
.alert {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-bottom: 16px;
  display: none;
}
.alert.show { display: block; }
.alert-error   { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
.alert-success { background: #d1fae5; color: #065f46; border: 1px solid #a7f3d0; }

/* ==================== DASHBOARD LAYOUT ==================== */
.app-layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 240px;
  background: #0f172a;
  color: #cbd5e1;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: fixed;
  left: 0; top: 0; bottom: 0;
  z-index: 50;
  overflow-y: auto;
}

.sidebar .brand {
  padding: 22px 20px;
  font-size: 17px;
  font-weight: 700;
  color: #fff;
  border-bottom: 1px solid #1e293b;
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar .brand .brand-icon {
  width: 36px; height: 36px;
  background: var(--primary);
  border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.sidebar .brand .brand-text span {
  display: block;
  font-size: 11px;
  font-weight: 400;
  color: #64748b;
  margin-top: 1px;
}

.sidebar nav { flex: 1; padding: 12px 10px; }

.nav-section-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #475569;
  padding: 12px 14px 6px;
}

.sidebar nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  color: #94a3b8;
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  margin-bottom: 2px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.sidebar nav a:hover  { background: #1e293b; color: #e2e8f0; }
.sidebar nav a.active { background: var(--primary); color: #fff; }
.sidebar nav a .nav-icon { font-size: 16px; width: 20px; text-align: center; flex-shrink: 0; }

.sidebar .user-box {
  padding: 14px 16px;
  border-top: 1px solid #1e293b;
  font-size: 13px;
}

.sidebar .user-box .user-name {
  font-weight: 600;
  color: #e2e8f0;
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.role-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 10px;
}

.role-badge.admin { background: #fef3c7; color: #92400e; }
.role-badge.kasir { background: #dbeafe; color: #1e40af; }

.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  margin-left: 240px;
}

.topbar {
  background: var(--surface);
  padding: 14px 28px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar h2 { font-size: 17px; font-weight: 700; }

.page-content { padding: 24px 28px; flex: 1; overflow-y: auto; }

.view { display: none; }
.view.active { display: block; }

/* ==================== LOADING SCREEN ==================== */
.loading-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--bg);
  gap: 16px;
}

.spinner {
  width: 40px; height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.loading-text { color: var(--text-muted); font-size: 14px; font-weight: 500; }

/* ==================== CARDS / STATS ==================== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  border-left: 4px solid transparent;
}

.stat-card.blue   { border-left-color: var(--primary); }
.stat-card.green  { border-left-color: var(--success); }
.stat-card.orange { border-left-color: var(--warning); }

.stat-card .label { font-size: 12px; color: var(--text-muted); margin-bottom: 8px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.04em; }
.stat-card .value { font-size: 22px; font-weight: 700; }

.stat-card.green  .value { color: var(--success); }
.stat-card.blue   .value { color: var(--primary); }
.stat-card.orange .value { color: var(--warning); }

.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 20px;
  overflow: hidden;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
}

.card-header h3 { font-size: 15px; font-weight: 700; }

.card-body { padding: 20px; }

/* ==================== TABLE ==================== */
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }

table th, table td {
  padding: 11px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

table th {
  background: #f8fafc;
  font-weight: 600;
  color: var(--text-muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

table tr:last-child td { border-bottom: none; }
table tr:hover td { background: #fafafa; }

.badge {
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
}
.badge-admin { background: #fef3c7; color: #92400e; }
.badge-kasir { background: #dbeafe; color: #1e40af; }

.status-dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  margin-right: 6px;
}
.status-dot.aktif    { background: var(--success); }
.status-dot.nonaktif { background: var(--danger); }

.stock-badge {
  background: var(--primary-light);
  color: var(--primary);
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}
.stock-badge.low { background: #fee2e2; color: var(--danger); }

/* ==================== KASIR / POS LAYOUT ==================== */
.toolbar {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.toolbar input, .toolbar select {
  padding: 9px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: inherit;
  outline: none;
  background: var(--surface);
  transition: border-color 0.15s;
}
.toolbar input:focus, .toolbar select:focus { border-color: var(--primary); }
.toolbar input { flex: 1; min-width: 200px; }

.pos-layout {
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 20px;
  align-items: start;
}

.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
}

.product-item {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 14px;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
  border: 2px solid transparent;
  text-align: center;
}

.product-item:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
  border-color: var(--primary);
}

.product-item.out-of-stock {
  opacity: 0.5;
  cursor: not-allowed;
}

.product-item .product-icon { font-size: 28px; margin-bottom: 8px; }
.product-item .name  { font-weight: 600; font-size: 13px; margin-bottom: 4px; }
.product-item .price { color: var(--primary); font-weight: 700; font-size: 14px; }
.product-item .stock { font-size: 11px; color: var(--text-muted); margin-top: 4px; }

.cart-panel {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  position: sticky;
  top: 80px;
}

.cart-panel .cart-header {
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
  font-weight: 700;
  font-size: 15px;
}

.cart-items {
  max-height: 350px;
  overflow-y: auto;
  padding: 8px 0;
}

.cart-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 18px;
  gap: 8px;
  border-bottom: 1px solid var(--border);
}

.cart-row:last-child { border-bottom: none; }
.cart-row .info { flex: 1; min-width: 0; }
.cart-row .info .nm { font-size: 13px; font-weight: 600; }
.cart-row .info .pr { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

.qty-control { display: flex; align-items: center; gap: 8px; }
.qty-control button {
  width: 26px; height: 26px;
  border-radius: 6px;
  border: 1.5px solid var(--border);
  background: #fff;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  transition: background 0.1s;
  display: flex; align-items: center; justify-content: center;
}
.qty-control button:hover { background: var(--primary-light); border-color: var(--primary); color: var(--primary); }
.qty-control span { font-weight: 600; min-width: 20px; text-align: center; }

.cart-footer {
  padding: 14px 18px;
  border-top: 2px solid var(--border);
}

.cart-summary-row {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.text-success {
  color: var(--success) !important;
}

.cart-total-row {
  display: flex;
  justify-content: space-between;
  font-weight: 700;
  font-size: 16px;
  margin-bottom: 14px;
}

.empty-state {
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
  padding: 32px 20px;
}

/* ==================== MODAL ==================== */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,0.55);
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
  backdrop-filter: blur(2px);
}

.modal-overlay.show { display: flex; animation: fadeIn 0.15s ease; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal-box {
  background: var(--surface);
  border-radius: var(--radius);
  width: 100%;
  max-width: 460px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.25);
  animation: slideUp 0.2s ease;
}

@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  font-size: 16px;
  font-weight: 700;
}

.modal-body { padding: 20px 24px; }

.modal-actions {
  display: flex;
  gap: 10px;
  padding: 16px 24px;
  border-top: 1px solid var(--border);
}

.modal-actions .btn { flex: 1; }
.modal-actions .btn-primary { width: auto; }

/* ==================== STRUK / RECEIPT ==================== */
.receipt {
  font-family: 'Courier New', monospace;
  font-size: 13px;
  max-width: 300px;
  margin: 0 auto;
  padding: 16px;
}

.receipt .center { text-align: center; line-height: 1.6; }
.receipt hr { border: none; border-top: 1px dashed #aaa; margin: 10px 0; }
.receipt .row { display: flex; justify-content: space-between; margin: 4px 0; }

/* ==================== MISC ==================== */
.overflow-x { overflow-x: auto; }

code {
  background: var(--primary-light);
  color: var(--primary);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 12px;
}

/* Sidebar Toggle Button for Mobile */
.menu-toggle-btn {
  display: none;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: var(--text);
  cursor: pointer;
  padding: 8px;
  border-radius: var(--radius);
  margin-right: 12px;
  outline: none;
  transition: background var(--transition) ease;
}
.menu-toggle-btn:hover {
  background: var(--bg-accent);
}

/* Sidebar Overlay */
.sidebar-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(4px);
  z-index: 999;
  display: none;
  opacity: 0;
  transition: opacity 0.3s ease;
}
.sidebar-overlay.show {
  display: block;
  opacity: 1;
}

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

@media (max-width: 768px) {
  .menu-toggle-btn {
    display: flex;
  }
  .sidebar {
    position: fixed;
    top: 0;
    left: -260px; /* Sembunyikan di luar layar */
    bottom: 0;
    width: 260px;
    z-index: 1000;
    box-shadow: var(--shadow-lg);
    transition: left var(--transition) ease;
  }
  .sidebar.show {
    left: 0; /* Slide ke kanan */
  }
  .main-content {
    margin-left: 0 !important;
    width: 100%;
  }
  .page-content {
    padding: 16px;
  }
  .topbar {
    padding: 12px 16px;
  }
  .stats-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .modal-box { max-width: 100%; border-radius: var(--radius) var(--radius) 0 0; }
  .modal-overlay { align-items: flex-end; padding: 0; }
}
