/* ============================================================
   KASIR APP — BASE STYLESHEET (MOBILE RESPONSIVE)
============================================================ */

/* --- Reset & Base --- */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --primary: #4f46e5;
  --primary-dark: #3730a3;
  --primary-light: #e0e7ff;
  --success: #16a34a;
  --danger: #dc2626;
  --warning: #d97706;
  --info: #0891b2;
  --dark: #1e293b;
  --gray: #64748b;
  --light: #f1f5f9;
  --white: #ffffff;
  --border: #e2e8f0;
  --sidebar-w: 240px;
  --header-h: 60px;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.1), 0 1px 2px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.07), 0 2px 4px rgba(0, 0, 0, 0.06);
}

body {
  font-family:
    "Segoe UI",
    system-ui,
    -apple-system,
    sans-serif;
  font-size: 14px;
  color: var(--dark);
  background: var(--light);
  line-height: 1.5;
}

a {
  color: var(--primary);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}
img {
  max-width: 100%;
}

/* ============================================================
   LAYOUT
============================================================ */
.app-wrapper {
  display: flex;
  min-height: 100vh;
}

/* ============================================================
   SIDEBAR OVERLAY (Mobile)
============================================================ */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 99;
  opacity: 0;
  transition: opacity 0.3s;
}

.sidebar-overlay.active {
  display: block;
  opacity: 1;
}

/* --- Sidebar --- */
.sidebar {
  width: var(--sidebar-w);
  background: var(--dark);
  color: #cbd5e1;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: 100;
  transition: transform 0.3s ease;
}

.sidebar-brand {
  padding: 18px 20px;
  font-size: 16px;
  font-weight: 700;
  color: var(--white);
  border-bottom: 1px solid #334155;
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-brand span {
  font-size: 22px;
}

/* Tombol close sidebar (hanya tampil di mobile) */
.sidebar-close {
  display: none;
  margin-left: auto;
  background: none;
  border: none;
  color: #94a3b8;
  font-size: 20px;
  cursor: pointer;
  padding: 4px;
  line-height: 1;
}

.sidebar-close:hover {
  color: var(--white);
}

.sidebar-menu {
  padding: 12px 0;
  flex: 1;
}

.sidebar-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #475569;
  padding: 12px 20px 4px;
}

.sidebar-menu a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  color: #94a3b8;
  font-size: 13.5px;
  transition:
    background 0.15s,
    color 0.15s;
  border-left: 3px solid transparent;
  /* Touch-friendly minimum height */
  min-height: 44px;
}

.sidebar-menu a:hover,
.sidebar-menu a.active {
  background: #0f172a;
  color: var(--white);
  border-left-color: var(--primary);
  text-decoration: none;
}

.sidebar-menu a .icon {
  font-size: 16px;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}

.sidebar-footer {
  padding: 14px 20px;
  border-top: 1px solid #334155;
  font-size: 12px;
  color: #475569;
}

/* --- Main Content --- */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-width: 0; /* prevent overflow */
}

/* --- Header / Topbar --- */
.topbar {
  height: var(--header-h);
  background: var(--white);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: var(--shadow);
  gap: 12px;
}

/* Tombol hamburger (hanya tampil di mobile) */
.topbar-hamburger {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius);
  color: var(--dark);
  font-size: 20px;
  line-height: 1;
  flex-shrink: 0;
  min-width: 36px;
  min-height: 36px;
  align-items: center;
  justify-content: center;
}

.topbar-hamburger:hover {
  background: var(--light);
}

.topbar-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--dark);
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-shrink: 0;
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--gray);
}

/* Sembunyikan nama user di layar kecil */
.topbar-user .user-name {
  display: inline;
}

.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
  flex-shrink: 0;
}

/* --- Page Content --- */
.page-content {
  padding: 24px;
  flex: 1;
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 20px;
  gap: 12px;
  flex-wrap: wrap;
}

.page-header h1 {
  font-size: 20px;
  font-weight: 700;
}
.page-header p {
  font-size: 13px;
  color: var(--gray);
  margin-top: 2px;
}

/* ============================================================
   CARDS
============================================================ */
.card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 20px;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  gap: 8px;
}

.card-title {
  font-size: 15px;
  font-weight: 600;
}

/* Stat Cards */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.stat-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 14px;
}

.stat-icon {
  width: 46px;
  height: 46px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}

.stat-icon.blue {
  background: #eff6ff;
  color: #2563eb;
}
.stat-icon.green {
  background: #f0fdf4;
  color: #16a34a;
}
.stat-icon.yellow {
  background: #fffbeb;
  color: #d97706;
}
.stat-icon.red {
  background: #fef2f2;
  color: #dc2626;
}
.stat-icon.purple {
  background: #f5f3ff;
  color: #7c3aed;
}

.stat-info .label {
  font-size: 12px;
  color: var(--gray);
}
.stat-info .value {
  font-size: 20px;
  font-weight: 700;
  color: var(--dark);
}
.stat-info .sub {
  font-size: 11px;
  color: var(--gray);
  margin-top: 2px;
}

/* ============================================================
   TABLES
============================================================ */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: var(--radius);
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 500px; /* Paksa scroll horizontal jika sempit */
}

thead th {
  background: var(--light);
  padding: 10px 14px;
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--gray);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

tbody td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 13.5px;
  vertical-align: middle;
}

tbody tr:last-child td {
  border-bottom: none;
}
tbody tr:hover {
  background: #f8fafc;
}

/* ============================================================
   FORMS
============================================================ */
.form-group {
  margin-bottom: 16px;
}

label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 5px;
  color: var(--dark);
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="tel"],
select,
textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13.5px;
  color: var(--dark);
  background: var(--white);
  transition:
    border-color 0.15s,
    box-shadow 0.15s;
  outline: none;
  /* Cegah zoom otomatis di iOS */
  font-size: 16px;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

textarea {
  resize: vertical;
  min-height: 80px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.form-row-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 16px;
}

.form-hint {
  font-size: 11px;
  color: var(--gray);
  margin-top: 4px;
}

/* ============================================================
   BUTTONS
============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition:
    opacity 0.15s,
    transform 0.1s;
  text-decoration: none;
  line-height: 1.4;
  /* Touch-friendly */
  min-height: 40px;
  -webkit-tap-highlight-color: transparent;
}

.btn:hover {
  opacity: 0.88;
  text-decoration: none;
}
.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: var(--primary);
  color: white;
}
.btn-success {
  background: var(--success);
  color: white;
}
.btn-danger {
  background: var(--danger);
  color: white;
}
.btn-warning {
  background: var(--warning);
  color: white;
}
.btn-info {
  background: var(--info);
  color: white;
}
.btn-dark {
  background: var(--dark);
  color: white;
}
.btn-light {
  background: var(--light);
  color: var(--dark);
  border: 1px solid var(--border);
}
.btn-outline {
  background: transparent;
  color: var(--primary);
  border: 1px solid var(--primary);
}

.btn-sm {
  padding: 5px 10px;
  font-size: 12px;
  min-height: 32px;
}
.btn-lg {
  padding: 11px 22px;
  font-size: 15px;
  min-height: 48px;
}
.btn-block {
  width: 100%;
  justify-content: center;
}

/* ============================================================
   BADGES
============================================================ */
.badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.badge-success {
  background: #dcfce7;
  color: #15803d;
}
.badge-danger {
  background: #fee2e2;
  color: #b91c1c;
}
.badge-warning {
  background: #fef3c7;
  color: #92400e;
}
.badge-info {
  background: #e0f2fe;
  color: #0369a1;
}
.badge-gray {
  background: #f1f5f9;
  color: #475569;
}
.badge-purple {
  background: #f5f3ff;
  color: #6d28d9;
}

/* ============================================================
   ALERTS
============================================================ */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  font-size: 13.5px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.alert-success {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  color: #15803d;
}
.alert-danger {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #b91c1c;
}
.alert-warning {
  background: #fffbeb;
  border: 1px solid #fde68a;
  color: #92400e;
}
.alert-info {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  color: #1d4ed8;
}

/* ============================================================
   LOGIN PAGE
============================================================ */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  padding: 16px;
}

.login-box {
  background: white;
  border-radius: 12px;
  padding: 40px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
}

.login-logo {
  text-align: center;
  margin-bottom: 28px;
}

.login-logo h1 {
  font-size: 24px;
  font-weight: 800;
  color: var(--primary);
}
.login-logo p {
  font-size: 13px;
  color: var(--gray);
  margin-top: 4px;
}

/* ============================================================
   UTILITIES
============================================================ */
.text-right {
  text-align: right;
}
.text-center {
  text-align: center;
}
.text-muted {
  color: var(--gray);
}
.text-sm {
  font-size: 12px;
}
.text-success {
  color: var(--success);
}
.text-danger {
  color: var(--danger);
}
.text-warning {
  color: var(--warning);
}

.fw-bold {
  font-weight: 700;
}
.fw-medium {
  font-weight: 500;
}

.mt-1 {
  margin-top: 4px;
}
.mt-2 {
  margin-top: 8px;
}
.mt-3 {
  margin-top: 16px;
}
.mt-4 {
  margin-top: 24px;
}
.mb-1 {
  margin-bottom: 4px;
}
.mb-2 {
  margin-bottom: 8px;
}
.mb-3 {
  margin-bottom: 16px;
}
.mb-4 {
  margin-bottom: 24px;
}

.d-flex {
  display: flex;
}
.align-center {
  align-items: center;
}
.justify-between {
  justify-content: space-between;
}
.gap-2 {
  gap: 8px;
}
.gap-3 {
  gap: 12px;
}

.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 16px 0;
}

/* ============================================================
   RESPONSIVE — Tablet (≤ 1024px)
============================================================ */
@media (max-width: 1024px) {
  .stat-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .form-row-3 {
    grid-template-columns: 1fr 1fr;
  }
}

/* ============================================================
   RESPONSIVE — Mobile (≤ 768px)
============================================================ */
@media (max-width: 768px) {
  /* Sidebar tersembunyi, muncul saat .open */
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
  }

  /* Tampilkan tombol close di dalam sidebar */
  .sidebar-close {
    display: flex;
    align-items: center;
    justify-content: center;
  }

  /* Main content full width */
  .main-content {
    margin-left: 0;
  }

  /* Tampilkan hamburger di topbar */
  .topbar-hamburger {
    display: flex;
  }

  .topbar {
    padding: 0 16px;
  }

  /* Page content padding lebih kecil */
  .page-content {
    padding: 16px;
  }

  /* Page header stack vertikal */
  .page-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .page-header h1 {
    font-size: 18px;
  }

  /* Form grid jadi 1 kolom */
  .form-row,
  .form-row-3 {
    grid-template-columns: 1fr;
  }

  /* Stat grid 2 kolom */
  .stat-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }

  .stat-card {
    padding: 14px;
    gap: 10px;
  }

  .stat-info .value {
    font-size: 17px;
  }

  /* Card padding lebih kecil */
  .card {
    padding: 14px;
  }

  /* Login box */
  .login-box {
    padding: 28px 20px;
  }

  /* Sembunyikan nama user, tampilkan avatar saja */
  .topbar-user .user-name {
    display: none;
  }
}

/* ============================================================
   RESPONSIVE — Small Mobile (≤ 480px)
============================================================ */
@media (max-width: 480px) {
  /* Stat grid 1 kolom di layar sangat kecil */
  .stat-grid {
    grid-template-columns: 1fr;
  }

  .topbar-title {
    font-size: 14px;
  }

  .btn {
    font-size: 13px;
    padding: 7px 12px;
  }

  .page-header h1 {
    font-size: 16px;
  }
}

/* Notifikasi */
.topbar-notif {
  position: relative;
  cursor: pointer;
  display: flex;
  align-items: center;
}

.topbar-impersonation {
  padding: 5px 9px;
  border-radius: 99px;
  background: #fffbeb;
  color: #92400e;
  border: 1px solid #fde68a;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.notif-icon {
  font-size: 20px;
  line-height: 1;
}
.notif-badge {
  position: absolute;
  top: -4px;
  right: -6px;
  background: #dc2626;
  color: white;
  font-size: 10px;
  font-weight: 700;
  border-radius: 99px;
  padding: 1px 5px;
  min-width: 16px;
  text-align: center;
}

/* User info */
.user-fullname {
  font-weight: 600;
  font-size: 13px;
  color: #1e293b;
}
.user-role {
  font-size: 11px;
  color: #94a3b8;
  text-transform: capitalize;
}

/* Logout */
.logout-icon {
  font-size: 14px;
}

/* ── Mobile (≤ 768px) ── */
@media (max-width: 768px) {
  /* Sembunyikan teks nama user */
  .user-name {
    display: none;
  }

  /* Sembunyikan teks "Keluar", tampilkan ikon saja */
  .logout-text {
    display: none;
  }
  .topbar-impersonation {
    display: none;
  }
  /* FIX: buat tombol logout jadi kotak ikon saja */
  .topbar-logout {
    padding: 6px !important;
    min-width: 36px;
    min-height: 36px;
    justify-content: center;
  }
  .logout-icon {
    font-size: 18px;
    line-height: 1;
  }
  /* Notif badge tetap terlihat */
  .notif-icon {
    font-size: 18px;
  }
}

.sidebar-subtitle {
  font-size: 10px;
  color: #64748b;
  font-weight: 400;
}

.sidebar-footer-user {
  font-weight: 600;
  color: #94a3b8;
  font-size: 12px;
}

.sidebar-footer-logout {
  margin-top: 6px;
}

.sidebar-logout-link {
  color: #ef4444;
  font-size: 12px;
  text-decoration: none;
}

.sidebar-logout-link:hover {
  text-decoration: underline;
}
