/* --- SMARTKEY KASIR TOKO - GLOBAL CORE STYLES (PREMIUM MPA) --- */
@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&family=Outfit:wght@500;700;900&display=swap');

:root {
  --bg-primary: #080c14;
  --bg-secondary: #0f172a;
  --glass-bg: rgba(15, 23, 42, 0.45);
  --glass-border: rgba(255, 255, 255, 0.08);
  --teal-accent: #0d9488;
  --teal-glow: rgba(13, 148, 136, 0.3);
  --blue-accent: #0ea5e9;
  --blue-glow: rgba(14, 165, 233, 0.25);
  --red-accent: #f43f5e;
  --red-glow: rgba(244, 63, 94, 0.25);
  --gold-accent: #f59e0b;
  --gold-glow: rgba(245, 158, 11, 0.25);
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --sidebar-width: 280px;
  --title-gradient: linear-gradient(135deg, #ffffff 40%, #a5f3fc 100%);
}

/* --- THEME ADAPTATION OVERRIDES --- */
[data-theme="light"] {
  --bg-primary: #f8fafc;
  --bg-secondary: #ffffff;
  --glass-bg: rgba(255, 255, 255, 0.94);
  --glass-border: rgba(15, 23, 42, 0.12);
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --title-gradient: linear-gradient(135deg, #0f172a 30%, #0d9488 100%);
  color-scheme: light;
}

[data-theme="dark"] {
  --bg-primary: #080c14;
  --bg-secondary: #0f172a;
  --glass-bg: rgba(15, 23, 42, 0.65);
  --glass-border: rgba(255, 255, 255, 0.08);
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --title-gradient: linear-gradient(135deg, #ffffff 40%, #a5f3fc 100%);
  color-scheme: dark;
}

[data-theme="light"] body {
  background-color: #f8fafc !important;
  color: #0f172a !important;
}

[data-theme="light"] .title-gradient {
  background: linear-gradient(135deg, #0f172a 30%, #0d9488 100%) !important;
  -webkit-background-clip: text !important;
  -webkit-text-fill-color: transparent !important;
}

[data-theme="light"] h1,
[data-theme="light"] h2,
[data-theme="light"] h3,
[data-theme="light"] h4,
[data-theme="light"] h5,
[data-theme="light"] h6 {
  color: #0f172a !important;
}

[data-theme="light"] .card-glass {
  background: rgba(255, 255, 255, 0.94) !important;
  border-color: rgba(15, 23, 42, 0.12) !important;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.06) !important;
}

/* Dalam Light Mode: teks putih di inline style otomatis disesuaikan jadi gelap */
[data-theme="light"] [style*="color:#fff"],
[data-theme="light"] [style*="color: #fff"],
[data-theme="light"] [style*="color:#ffffff"],
[data-theme="light"] [style*="color: #ffffff"] {
  color: #0f172a !important;
}

/* Pengecualian: tombol solid, badge berwarna, dan tab aktif tetap bertuliskan putih */
[data-theme="light"] .btn-primary,
[data-theme="light"] .btn-primary *,
[data-theme="light"] .badge-emerald,
[data-theme="light"] .badge-rose,
[data-theme="light"] .badge-amber,
[data-theme="light"] .theme-mode-btn.active,
[data-theme="light"] .sidebar-btn.active-tab {
  color: #ffffff !important;
}

/* Table Light Mode */
[data-theme="light"] .table-glass th {
  color: #475569 !important;
  border-bottom: 1px solid rgba(15, 23, 42, 0.12) !important;
}
[data-theme="light"] .table-glass td {
  color: #0f172a !important;
  border-bottom: 1px solid rgba(15, 23, 42, 0.06) !important;
}
[data-theme="light"] .table-glass tbody tr:hover {
  background: rgba(15, 23, 42, 0.03) !important;
}

/* Inputs Light Mode */
[data-theme="light"] .input-glass {
  background: #ffffff !important;
  border-color: rgba(15, 23, 42, 0.2) !important;
  color: #0f172a !important;
}
[data-theme="light"] .input-glass::placeholder {
  color: #64748b !important;
}

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

body {
  font-family: 'Plus Jakarta Sans', sans-serif;
  background-color: var(--bg-primary);
  background-image: 
    radial-gradient(circle at 10% 20%, rgba(13, 148, 136, 0.03) 0%, transparent 40%),
    radial-gradient(circle at 90% 80%, rgba(99, 102, 241, 0.02) 0%, transparent 40%);
  color: var(--text-primary);
  overflow-x: hidden;
  min-height: 100vh;
}

/* Scrollbar Customization */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: var(--bg-primary);
}
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--teal-accent);
}

/* Glassmorphism Design System */
.card-glass {
  background: var(--glass-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
  border-radius: 18px;
  box-shadow: 0 20px 40px 0 rgba(0, 0, 0, 0.35);
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.card-glass.hover-lift:hover {
  transform: translateY(-4px);
  border-color: rgba(255, 255, 255, 0.15);
  box-shadow: 0 30px 60px 0 rgba(0, 0, 0, 0.45);
}

.glow-teal {
  box-shadow: 0 0 30px var(--teal-glow), 0 10px 30px 0 rgba(0, 0, 0, 0.3);
}

.fade-in {
  animation: fadeIn 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

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

/* Main Layout for Authenticated Pages */
.app-container {
  display: flex;
  min-height: 100vh;
  position: relative;
}

.sidebar {
  width: var(--sidebar-width);
  height: 100vh;
  position: fixed;
  left: 0;
  top: 0;
  background: rgba(8, 12, 22, 0.85);
  border-right: 1px solid var(--glass-border);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  padding: 30px 20px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  z-index: 1000;
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  padding: 40px;
  min-height: 100vh;
  transition: margin-left 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Collapsed classes */
body.sidebar-collapsed .sidebar {
  transform: translateX(-100%);
}

body.sidebar-collapsed .main-content {
  margin-left: 0 !important;
}

/* Headers & Gradient Accents */
h1, h2, h3, h4, .font-outfit {
  font-family: 'Outfit', sans-serif;
  letter-spacing: -0.01em;
}

.title-gradient {
  background: linear-gradient(135deg, #ffffff 40%, #a5f3fc 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  font-weight: 900;
}

/* Button UI with Micro-Animations */
.btn-primary {
  background: linear-gradient(135deg, #0d9488, #0e7490);
  color: #fff;
  border: none;
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.02em;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 4px 15px var(--teal-glow);
  padding: 12px 20px;
  border-radius: 12px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 25px rgba(13, 148, 136, 0.45);
  filter: brightness(1.1);
}
.btn-primary:active {
  transform: translateY(1px);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--glass-border);
  color: var(--text-primary);
  font-weight: 600;
  font-size: 12px;
  padding: 10px 18px;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.2);
}

/* Sidebar navigation buttons */
.sidebar-btn {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 14px 18px;
  border-radius: 12px;
  color: var(--text-secondary);
  font-weight: 600;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  border: none;
  background: transparent;
  text-align: left;
  cursor: pointer;
  margin-bottom: 6px;
  text-decoration: none;
  font-size: 13px;
}
.sidebar-btn svg {
  opacity: 0.65;
  transition: transform 0.25s;
}
.sidebar-btn:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.03);
}
.sidebar-btn:hover svg {
  opacity: 1;
  transform: translateX(2px);
}
.sidebar-btn.active-tab {
  color: #fff;
  background: linear-gradient(135deg, rgba(13, 148, 136, 0.15), rgba(14, 165, 233, 0.05));
  border-left: 4px solid var(--teal-accent);
  box-shadow: inset 8px 0 20px rgba(13, 148, 136, 0.08);
  border-radius: 0 12px 12px 0;
}
.sidebar-btn.active-tab svg {
  opacity: 1;
  color: var(--teal-accent);
}

/* Inputs */
.input-glass {
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid var(--glass-border);
  color: #fff;
  border-radius: 12px;
  padding: 12px 16px;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  font-family: inherit;
  font-size: 13px;
}
.input-glass:focus {
  outline: none;
  border-color: var(--blue-accent);
  box-shadow: 0 0 0 4px rgba(14, 165, 233, 0.15);
  background: rgba(15, 23, 42, 0.8);
}
.input-glass::placeholder {
  color: rgba(255, 255, 255, 0.2);
}

select.input-glass {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 14px center;
  background-size: 14px;
  padding-right: 40px !important;
  cursor: pointer;
}

/* Premium Modal Entry Animation System */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(8, 12, 20, 0);
  backdrop-filter: blur(0px);
  -webkit-backdrop-filter: blur(0px);
  animation: fadeInBg 0.25s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes fadeInBg {
  to {
    background: rgba(8, 12, 20, 0.75);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
  }
}

.modal-content-card {
  transform: scale(0.9) translateY(20px);
  opacity: 0;
  animation: scaleUp 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes scaleUp {
  to {
    transform: scale(1) translateY(0);
    opacity: 1;
  }
}

/* Tables */
.table-glass {
  width: 100%;
  border-collapse: collapse;
}
.table-glass th {
  text-align: left;
  padding: 16px 20px;
  font-weight: 700;
  color: var(--text-secondary);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.08em;
}
.table-glass td {
  padding: 18px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
  font-size: 13px;
}
.table-glass tbody tr:hover {
  background: rgba(255, 255, 255, 0.02);
}

.show-on-mobile {
  display: none;
}

/* Status Badges */
.badge-emerald {
  background: rgba(16, 185, 129, 0.12);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.2);
}
.badge-rose {
  background: rgba(244, 63, 94, 0.12);
  color: #fb7185;
  border: 1px solid rgba(244, 63, 94, 0.2);
}
.badge-amber {
  background: rgba(245, 158, 11, 0.12);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.2);
}

/* Utilities & Tailwind-style Helpers */
.hidden { display: none !important; }
.text-center { text-align: center !important; }
.w-full { width: 100% !important; }
.h-full { height: 100% !important; }
.cursor-pointer { cursor: pointer !important; }

/* Padding Utilities */
.p-1 { padding: 4px !important; }
.p-2 { padding: 8px !important; }
.p-3 { padding: 12px !important; }
.p-4 { padding: 16px !important; }
.p-5 { padding: 20px !important; }
.p-6 { padding: 24px !important; }
.p-8 { padding: 32px !important; }
.py-2 { padding-top: 8px !important; padding-bottom: 8px !important; }
.py-3 { padding-top: 12px !important; padding-bottom: 12px !important; }
.py-4 { padding-top: 16px !important; padding-bottom: 16px !important; }
.py-10 { padding-top: 40px !important; padding-bottom: 40px !important; }
.px-4 { padding-left: 16px !important; padding-right: 16px !important; }

/* Margin Utilities */
.mt-0.5 { margin-top: 2px !important; }
.mt-1 { margin-top: 4px !important; }
.mt-2 { margin-top: 8px !important; }
.mt-3 { margin-top: 12px !important; }
.mt-4 { margin-top: 16px !important; }
.mt-6 { margin-top: 24px !important; }
.mb-1 { margin-bottom: 4px !important; }
.mb-2 { margin-bottom: 8px !important; }
.mb-4 { margin-bottom: 16px !important; }
.mb-6 { margin-bottom: 24px !important; }
.mr-2 { margin-right: 8px !important; }
.mt-auto { margin-top: auto !important; }

/* Flexbox Utilities */
.flex { display: flex !important; }
.flex-col { flex-direction: column !important; }
.items-center { align-items: center !important; }
.justify-between { justify-content: space-between !important; }
.justify-center { justify-content: center !important; }
.gap-2 { gap: 8px !important; }
.gap-3 { gap: 12px !important; }
.gap-4 { gap: 16px !important; }

/* Text Sizing & Weight */
.text-xs { font-size: 11px !important; }
.text-sm { font-size: 13px !important; }
.text-md { font-size: 15px !important; }
.text-lg { font-size: 18px !important; }
.text-xl { font-size: 20px !important; }
.font-semibold { font-weight: 600 !important; }
.font-bold { font-weight: 700 !important; }
.font-extrabold { font-weight: 800 !important; }
.font-black { font-weight: 900 !important; }
.uppercase { text-transform: uppercase !important; }
.tracking-wider { letter-spacing: 0.05em !important; }
.leading-snug { line-height: 1.375 !important; }

/* Text Colors */
.text-white { color: #ffffff !important; }
.text-teal-400 { color: #2dd4bf !important; }
.text-teal-300 { color: #5eead4 !important; }
.text-slate-400 { color: #94a3b8 !important; }
.text-slate-300 { color: #cbd5e1 !important; }
.text-red-400 { color: #f87171 !important; }
.text-emerald-400 { color: #34d399 !important; }

/* --- RESPONSIVE BOTTOM NAVIGATION BAR FOR MOBILE (PWA / APK) --- */
.bottom-nav {
  display: none;
}

.mobile-drawer {
  display: none;
}

@media (max-width: 768px) {
  /* Ubah Sidebar Menjadi Overlay Drawer */
  .sidebar {
    position: fixed !important;
    left: 0 !important;
    top: 0 !important;
    bottom: 0 !important;
    width: var(--sidebar-width) !important;
    height: 100vh !important;
    z-index: 2000 !important;
    transform: translateX(-100%) !important;
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1) !important;
    display: flex !important;
    box-shadow: 10px 0 30px rgba(0,0,0,0.5) !important;
  }

  body.sidebar-open .sidebar {
    transform: translateX(0) !important;
  }

  /* Sesuaikan Konten Utama agar Penuh Layar dengan Safe Area top/bottom */
  .main-content {
    margin-left: 0 !important;
    padding: calc(70px + env(safe-area-inset-top, 0px)) 12px calc(16px + env(safe-area-inset-bottom, 0px)) 12px !important;
    min-width: 0 !important;
  }

  .app-container {
    overflow-x: hidden !important;
    max-width: 100vw !important;
  }

  .card-glass {
    padding: 14px !important;
    border-radius: 12px !important;
  }

  /* Perkecil Ukuran Font agar Cocok di HP */
  h2, .title-gradient {
    font-size: 22px !important;
  }

  .stat-card-value {
    font-size: 22px !important;
  }

  /* Matikan Bottom Nav dan Slide Up Drawer Lama */
  .bottom-nav, .mobile-drawer {
    display: none !important;
  }

  /* Cegah tabel gepeng/overflow dengan memaksa scroll horizontal */
  .table-glass {
    min-width: 750px !important;
  }

  .hide-on-mobile {
    display: none !important;
  }

  .show-on-mobile {
    display: table-cell !important;
  }

  .table-mobile-fit {
    min-width: 100% !important;
  }

  /* --- ATURAN MODAL & FORM RESPONSIVE UTAMA --- */
  .modal-overlay {
    padding: 10px !important;
    align-items: center !important;
    justify-content: center !important;
  }

  .modal-content-card {
    max-width: 96vw !important;
    width: 96vw !important;
    max-height: 92vh !important;
    padding: 16px !important;
    border-radius: 14px !important;
    box-sizing: border-box !important;
  }

  /* Otomatis jadikan semua baris input flex dalam modal menjadi column-wrap di HP */
  .modal-content-card div[style*="display:flex"],
  .modal-content-card div[style*="display: flex"] {
    flex-wrap: wrap !important;
  }

  /* Semua input box, select, textarea tidak boleh melebihi lebar layar */
  .input-glass, input, select, textarea, button {
    max-width: 100% !important;
    box-sizing: border-box !important;
  }

  /* Pembungkus grid responsif */
  div[style*="display:grid"], div[style*="display: grid"] {
    grid-template-columns: 1fr !important;
  }
}

/* --- FLOAT MENU TOGGLE & DRAWER OVERLAY --- */
.floating-menu-btn {
  position: fixed;
  top: 16px;
  left: 16px;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 998;
  transition: all 0.25s ease;
  opacity: 0;
  pointer-events: none;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

.floating-menu-btn:hover {
  background: rgba(255, 255, 255, 0.08);
}

body.sidebar-collapsed .floating-menu-btn {
  opacity: 1;
  pointer-events: auto;
}

@media (max-width: 768px) {
  .floating-menu-btn {
    opacity: 1;
    pointer-events: auto;
  }
}

.sidebar-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 1999;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

body.sidebar-open .sidebar-overlay {
  opacity: 1;
  pointer-events: auto;
}

/* --- SIDEBAR NESTED ACCORDION SUBMENUS --- */
.sidebar-submenu-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-radius: 12px;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.25s ease;
  margin-bottom: 2px;
}

.sidebar-submenu-header:hover {
  background: rgba(255, 255, 255, 0.03);
  color: #fff;
}

.sidebar-submenu-header.active-parent {
  color: #fff;
  background: rgba(255, 255, 255, 0.02);
}

.sidebar-submenu-container {
  display: flex;
  flex-direction: column;
  padding-left: 28px;
  margin-top: 2px;
  gap: 2px;
  overflow: hidden;
  transition: max-height 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-submenu-container.collapsed {
  max-height: 0 !important;
  margin-bottom: 0;
}

.sidebar-submenu-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 8px;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
  transition: all 0.2s;
}

.sidebar-submenu-btn:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.03);
}

.sidebar-submenu-btn.active-tab {
  color: var(--teal-accent);
  background: rgba(13, 148, 136, 0.08);
  font-weight: 700;
}

.submenu-chevron {
  font-size: 10px;
  color: var(--text-secondary);
  transition: transform 0.25s ease;
}

.submenu-chevron.open {
  transform: rotate(90deg);
  color: #fff;
}

/* --- BACK TO TOP FLOATING BUTTON --- */
.back-to-top-btn {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(15, 23, 42, 0.75);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 1500;
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
  transition: opacity 0.3s ease, transform 0.3s ease, background 0.2s;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
}

.back-to-top-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  transform: translateY(-3px);
}

.back-to-top-btn.visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

/* Safe area padding adjustment for PWA/Android bottom spacing if needed */
@media (max-width: 768px) {
  .back-to-top-btn {
    bottom: calc(20px + env(safe-area-inset-bottom, 0px));
    right: 20px;
    width: 40px;
    height: 40px;
  }
}
