/* ==========================================================================
   DESIGN SYSTEM & VARIABLES
   ========================================================================== */

:root {
  /* DARK THEME (Default) */
  --bg-base: #0b0f19;
  --bg-surface: #151c2c;
  --bg-surface-glass: rgba(21, 28, 44, 0.75);
  --border-color: rgba(255, 255, 255, 0.07);
  --border-focus: rgba(99, 102, 241, 0.4);
  
  --text-primary: #f3f4f6;
  --text-secondary: #9ca3af;
  --text-muted: #6b7280;
  
  --primary: #6366f1;
  --primary-hover: #4f46e5;
  --primary-soft: rgba(99, 102, 241, 0.15);
  
  --success: #10b981;
  --success-hover: #059669;
  --success-soft: rgba(16, 185, 129, 0.15);
  
  --danger: #f43f5e;
  --danger-hover: #e11d48;
  --danger-soft: rgba(244, 63, 94, 0.15);
  
  --warning: #f59e0b;
  --warning-soft: rgba(245, 158, 11, 0.15);
  
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4), 0 2px 4px -2px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5), 0 4px 6px -4px rgba(0, 0, 0, 0.5);
  
  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 18px;
  
  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  
  --sidebar-width: 260px;
}

html[data-theme="light"] {
  /* LIGHT THEME */
  --bg-base: #f8fafc;
  --bg-surface: #ffffff;
  --bg-surface-glass: rgba(255, 255, 255, 0.85);
  --border-color: rgba(0, 0, 0, 0.08);
  --border-focus: rgba(79, 70, 229, 0.4);
  
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-soft: rgba(79, 70, 229, 0.08);
  
  --success: #059669;
  --success-hover: #047857;
  --success-soft: rgba(5, 150, 105, 0.08);
  
  --danger: #e11d48;
  --danger-hover: #be123c;
  --danger-soft: rgba(225, 29, 72, 0.08);
  
  --warning: #d97706;
  --warning-soft: rgba(217, 119, 6, 0.08);
  
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.04), 0 4px 6px -4px rgba(0, 0, 0, 0.04);
}

/* ==========================================================================
   RESET & BASE STYLES
   ========================================================================== */

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

body {
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background-color: var(--bg-base);
  color: var(--text-primary);
  line-height: 1.5;
  overflow-x: hidden;
  transition: background-color var(--transition-normal), color var(--transition-normal);
}

a {
  text-decoration: none;
  color: inherit;
}

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
  background: none;
  border: none;
}

/* Scrollbar styling */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: var(--bg-base);
}
::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* ==========================================================================
   LAYOUT STRUCTURE
   ========================================================================== */

.app-container {
  display: flex;
  min-height: 100vh;
  min-height: 100dvh;
}

/* Sidebar Layout */
.sidebar {
  width: var(--sidebar-width);
  background-color: var(--bg-surface);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 100;
  transition: background-color var(--transition-normal), border-color var(--transition-normal);
}

.sidebar-brand {
  padding: 24px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--border-color);
}

.brand-logo {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, var(--primary), var(--success));
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.logo-icon {
  color: #ffffff;
  width: 22px;
  height: 22px;
}

.brand-text {
  display: flex;
  flex-direction: column;
}

.brand-name {
  font-weight: 700;
  font-size: 1.15rem;
  letter-spacing: 0.5px;
  background: linear-gradient(to right, var(--text-primary), var(--text-secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-tagline {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-weight: 500;
}

.sidebar-menu {
  padding: 20px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}

.menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-weight: 500;
  font-size: 0.95rem;
  color: var(--text-secondary);
  transition: all var(--transition-fast);
  cursor: pointer;
}

.menu-item i {
  width: 20px;
  height: 20px;
}

.menu-item:hover {
  background-color: var(--primary-soft);
  color: var(--text-primary);
}

.menu-item.active {
  background-color: var(--primary);
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.25);
}

.menu-item.active i {
  color: #ffffff !important;
}

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sidebar-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  border-radius: var(--radius-md);
  width: 100%;
  font-weight: 500;
  font-size: 0.9rem;
  cursor: pointer;
  background-color: var(--primary-soft);
  color: var(--primary);
  transition: all var(--transition-fast);
}

.sidebar-btn:hover {
  filter: brightness(1.1);
}

.sidebar-btn-secondary {
  background-color: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
}

.sidebar-btn-secondary:hover {
  background-color: var(--border-color);
  color: var(--text-primary);
}

/* Theme Toggle Icon Swapping */
html[data-theme="dark"] .sun-icon { display: block; }
html[data-theme="dark"] .moon-icon { display: none; }
html[data-theme="light"] .sun-icon { display: none; }
html[data-theme="light"] .moon-icon { display: block; }

/* Main Content Layout */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  padding: 40px;
  display: flex;
  flex-direction: column;
  min-width: 0; /* Prevents flex items from overflowing */
}

/* Topbar Header */
.topbar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 32px;
  gap: 20px;
}

#page-title {
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: 4px;
}

#page-description {
  color: var(--text-secondary);
  font-size: 0.95rem;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Connection status badge */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 99px;
  font-size: 0.8rem;
  font-weight: 600;
}

.badge-online {
  background-color: var(--success-soft);
  color: var(--success);
}
.badge-online .status-dot {
  background-color: var(--success);
}

.badge-offline {
  background-color: var(--warning-soft);
  color: var(--warning);
}
.badge-offline .status-dot {
  background-color: var(--warning);
  animation: pulse-orange 2s infinite;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

@keyframes pulse-orange {
  0% { transform: scale(0.9); opacity: 0.6; }
  50% { transform: scale(1.15); opacity: 1; }
  100% { transform: scale(0.9); opacity: 0.6; }
}

/* ==========================================================================
   PAGE SECTIONS & NAVIGATION SWITCHING
   ========================================================================== */

.page-section {
  display: none;
  animation: fade-in 0.35s ease;
}

.page-section.active {
  display: block;
}

@keyframes fade-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ==========================================================================
   CARDS & PREMIUM GLASSMORPHISM
   ========================================================================== */

.card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  transition: transform var(--transition-normal), box-shadow var(--transition-normal), background-color var(--transition-normal);
}

.card.glass {
  background-color: var(--bg-surface-glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.card:hover {
  box-shadow: var(--shadow-lg);
}

.card-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-color);
}

.card-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
}

.card-subtitle {
  font-size: 0.8rem;
  color: var(--text-muted);
  display: block;
  margin-top: 2px;
}

.card-body {
  padding: 24px;
}

/* Grid Layouts */
.grid-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
  margin-bottom: 24px;
}

.grid-split {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 24px;
  align-items: start;
}

.grid-split-3-7 {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 24px;
  align-items: start;
}

/* Summary stat cards */
.card-stat {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 20px 24px;
}

.card-stat-icon {
  width: 52px;
  height: 52px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
}

.card-stat-icon i {
  width: 26px;
  height: 26px;
}

.card-stat-info {
  display: flex;
  flex-direction: column;
}

.card-stat-label {
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.card-stat-value {
  font-size: 1.65rem;
  font-weight: 800;
  line-height: 1.2;
}

/* Soft backgrounds for icons */
.bg-primary-soft { background-color: var(--primary-soft); }
.bg-success-soft { background-color: var(--success-soft); }
.bg-danger-soft { background-color: var(--danger-soft); }
.bg-warning-soft { background-color: var(--warning-soft); }

/* ==========================================================================
   CHARTS & REPORTS
   ========================================================================== */

.chart-card-wrapper {
  min-height: 380px;
}

.chart-body {
  height: 300px;
  position: relative;
}

.report-card {
  min-height: 380px;
}

.report-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  margin-top: 24px;
}

/* ==========================================================================
   TABLES
   ========================================================================== */

.table-responsive {
  width: 100%;
  overflow-x: auto;
}

.table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.92rem;
}

.table th, .table td {
  padding: 16px 24px;
  border-bottom: 1px solid var(--border-color);
}

.table th {
  font-weight: 600;
  color: var(--text-secondary);
  background-color: rgba(0, 0, 0, 0.02);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.table tr {
  transition: background-color var(--transition-fast);
}

.table tbody tr:hover {
  background-color: rgba(255, 255, 255, 0.02);
}

html[data-theme="light"] .table tbody tr:hover {
  background-color: rgba(0, 0, 0, 0.01);
}

/* Action button styles inside tables */
.btn-action {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
  border: 1px solid var(--border-color);
}

.btn-action:hover {
  background-color: var(--border-color);
  color: var(--text-primary);
}

.btn-action-delete:hover {
  background-color: var(--danger-soft);
  color: var(--danger);
  border-color: var(--danger);
}

/* ==========================================================================
   BUTTONS
   ========================================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 20px;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 0.92rem;
  cursor: pointer;
  transition: all var(--transition-fast);
  gap: 8px;
  border: 1px solid transparent;
}

.btn-icon-text i {
  width: 18px;
  height: 18px;
}

.btn-primary {
  background-color: var(--primary);
  color: #ffffff;
}
.btn-primary:hover {
  background-color: var(--primary-hover);
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.25);
}

.btn-success {
  background-color: var(--success);
  color: #ffffff;
}
.btn-success:hover {
  background-color: var(--success-hover);
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.25);
}

.btn-danger {
  background-color: var(--danger);
  color: #ffffff;
}
.btn-danger:hover {
  background-color: var(--danger-hover);
  box-shadow: 0 4px 12px rgba(244, 63, 94, 0.25);
}

.btn-secondary {
  background-color: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
}
.btn-secondary:hover {
  background-color: var(--border-color);
  color: var(--text-primary);
}

.btn-icon-only {
  width: 42px;
  height: 42px;
  padding: 0;
  border-radius: var(--radius-md);
}

.btn-link {
  font-size: 0.88rem;
  color: var(--primary);
  font-weight: 600;
  transition: color var(--transition-fast);
}
.btn-link:hover {
  color: var(--primary-hover);
  text-decoration: underline;
}

/* ==========================================================================
   FORMS & INPUTS
   ========================================================================== */

.form-vertical {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.form-group label {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.form-control {
  width: 100%;
  padding: 10px 14px;
  background-color: var(--bg-base);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 1rem; /* Prevent iOS input zoom (minimum 16px font-size) */
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--border-focus);
}

.form-control::placeholder {
  color: var(--text-muted);
}

.form-control:disabled, .form-control[readonly] {
  opacity: 0.65;
  cursor: not-allowed;
  background-color: rgba(0, 0, 0, 0.15);
}

/* Fix: input date & datetime-local agar teks terlihat di dark mode */
input[type="date"].form-control,
input[type="datetime-local"].form-control,
input[type="month"].form-control {
  color: var(--text-primary);
  background-color: var(--bg-base);
  color-scheme: dark;
}

[data-theme="light"] input[type="date"].form-control,
[data-theme="light"] input[type="datetime-local"].form-control,
[data-theme="light"] input[type="month"].form-control {
  color-scheme: light;
}

/* Pastikan calendar icon/picker terlihat */
input[type="date"].form-control::-webkit-calendar-picker-indicator,
input[type="datetime-local"].form-control::-webkit-calendar-picker-indicator,
input[type="month"].form-control::-webkit-calendar-picker-indicator {
  filter: invert(1) brightness(1.5);
  cursor: pointer;
  padding: 2px;
  border-radius: 4px;
}

[data-theme="light"] input[type="date"].form-control::-webkit-calendar-picker-indicator,
[data-theme="light"] input[type="datetime-local"].form-control::-webkit-calendar-picker-indicator,
[data-theme="light"] input[type="month"].form-control::-webkit-calendar-picker-indicator {
  filter: none;
}

/* Search bar control wrapper */
.table-controls {
  margin-bottom: 20px;
}

.search-wrapper {
  position: relative;
  flex: 1;
  max-width: 320px;
}

.search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  color: var(--text-muted);
}

.search-input {
  padding-left: 42px !important;
}

.filter-select {
  max-width: 180px;
}

.input-action-wrapper {
  display: flex;
  gap: 8px;
}

.input-action-wrapper .form-control {
  flex: 1;
}

/* ==========================================================================
   MODAL WINDOWS
   ========================================================================== */

.modal {
  display: none; /* Hidden by default */
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.6);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 20px;
  backdrop-filter: blur(4px);
  animation: fade-in-backdrop 0.25s ease;
}

.modal.active {
  display: flex;
}

.modal-content {
  width: 100%;
  max-width: 520px;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  animation: scale-up 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  overflow: hidden;
  max-height: calc(100vh - 40px);
  max-height: calc(100dvh - 40px);
  display: flex;
  flex-direction: column;
}

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

.modal-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-primary);
}

.close-btn {
  font-size: 1.75rem;
  color: var(--text-secondary);
  cursor: pointer;
  line-height: 1;
  transition: color var(--transition-fast);
  padding: 8px;
  margin: -8px -8px -8px auto; /* Tapping target padding offset */
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.close-btn:hover {
  color: var(--text-primary);
}

.modal-body {
  padding: 24px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch; /* Smooth scrolling in iOS Safari */
}

@keyframes fade-in-backdrop {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes scale-up {
  from { transform: scale(0.95) translateY(10px); opacity: 0; }
  to { transform: scale(1) translateY(0); opacity: 1; }
}

/* ==========================================================================
   BARCODE SCANNER SECTION
   ========================================================================== */

.scanner-container {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 400px;
}

.scanner-viewfinder {
  width: 100%;
  background-color: #000000;
  border-bottom: 1px solid var(--border-color);
  position: relative;
  min-height: 320px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.scanner-inline-container {
  width: 100%;
  height: 200px;
  background-color: #000000;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

/* HTML5 QR Code Scanner Library Styles Override */
#reader {
  border: none !important;
}
#reader video {
  width: 100% !important;
  height: auto !important;
  object-fit: cover !important;
  border-radius: 0;
}
#reader img {
  display: none !important; /* hide default file scan buttons */
}
#reader__dashboard_section_csr button {
  background-color: var(--primary) !important;
  color: #ffffff !important;
  border: none !important;
  padding: 8px 16px !important;
  border-radius: var(--radius-md) !important;
  font-weight: 600 !important;
  cursor: pointer !important;
  margin: 10px 0 !important;
}
#reader__status_span {
  font-size: 0.8rem !important;
  color: var(--text-secondary) !important;
  font-weight: 500 !important;
}

.select-xs {
  font-size: 0.78rem;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  background-color: var(--bg-surface);
}

.scan-item-details {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 20px;
  background-color: rgba(0, 0, 0, 0.1);
}

/* ==========================================================================
   TOAST NOTIFICATIONS
   ========================================================================== */

.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 380px;
  width: calc(100% - 48px);
}

.toast {
  padding: 14px 20px;
  border-radius: var(--radius-md);
  background-color: var(--bg-surface);
  border-left: 4px solid var(--primary);
  box-shadow: var(--shadow-lg);
  color: var(--text-primary);
  font-size: 0.9rem;
  font-weight: 500;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  animation: slide-in-right 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  backdrop-filter: blur(12px);
}

.toast-success {
  border-left-color: var(--success);
}
.toast-danger {
  border-left-color: var(--danger);
}
.toast-warning {
  border-left-color: var(--warning);
}

.toast-close {
  cursor: pointer;
  opacity: 0.6;
  font-size: 1.2rem;
  font-weight: 700;
  transition: opacity var(--transition-fast);
}

.toast-close:hover {
  opacity: 1;
}

@keyframes slide-in-right {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

@keyframes slide-out-right {
  from { transform: translateX(0); opacity: 1; }
  to { transform: translateX(120%); opacity: 0; }
}

.toast.fade-out {
  animation: slide-out-right 0.25s ease forwards;
}

/* ==========================================================================
   UTILITY CLASSES
   ========================================================================== */

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

.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }
.font-mono { font-family: monospace; }
.text-sm { font-size: 0.85rem; }
.text-xs { font-size: 0.75rem; }
.text-lg { font-size: 1.15rem; }
.text-right { text-align: right; }
.text-center { text-align: center; }

.flex-between { display: flex; justify-content: space-between; align-items: center; }
.flex-start { display: flex; justify-content: flex-start; align-items: center; }
.flex-end { display: flex; justify-content: flex-end; align-items: center; }
.flex-center { display: flex; justify-content: center; align-items: center; }
.flex-wrap { flex-wrap: wrap; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }

.mt-6 { margin-top: 24px; }
.mb-4 { margin-bottom: 16px; }
.mb-1 { margin-bottom: 4px; }
.py-6 { padding-top: 24px; padding-bottom: 24px; }
.p-4 { padding: 16px; }
.mx-auto { margin-left: auto; margin-right: auto; }
.max-w-2xl { max-width: 42rem; }
.w-full { width: 100%; }
.overflow-hidden { overflow: hidden; }
.hidden, .mobile-only.hidden { display: none !important; }

.label-xs {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 2px;
  display: block;
}

.width-auto { width: auto !important; }

.grid-2-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
}
.grid-3-columns {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
}

/* Animations */
.animation-slide-up {
  animation: slide-up 0.3s ease;
}

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

/* Mobile specific menu hiding */
.mobile-only {
  display: none !important;
}

.mobile-nav {
  display: none;
}

/* Barcode visual badge style */
.barcode-badge {
  font-family: monospace;
  background-color: var(--border-color);
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.5px;
  border: 1px solid var(--border-color);
}

/* ==========================================================================
   RESPONSIVE MEDIA QUERIES
   ========================================================================== */

/* Mobile & Tablet Styles (Below 992px) */
@media (max-width: 991.98px) {
  :root {
    --sidebar-width: 0px;
  }
  
  .sidebar {
    display: none !important; /* Hide desktop sidebar completely */
  }
  
  .main-content {
    margin-left: 0;
    padding: 24px 20px calc(88px + env(safe-area-inset-bottom, 0px)) 20px; /* Safe area padding for notch devices */
  }
  
  .mobile-only {
    display: inline-flex !important;
  }
  
  /* Grid conversions */
  .grid-split, .grid-split-3-7 {
    grid-template-columns: 1fr;
    gap: 20px;
  }
  
  .chart-card-wrapper {
    min-height: auto;
  }
  
  .chart-body {
    height: 250px;
  }
  
  .report-card {
    min-height: auto;
  }
  
  /* Mobile Bottom Navigation Bar */
  .mobile-nav {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: calc(64px + env(safe-area-inset-bottom, 0px));
    padding-bottom: env(safe-area-inset-bottom, 0px);
    background-color: var(--bg-surface);
    border-top: 1px solid var(--border-color);
    box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.15);
    z-index: 900;
    justify-content: space-around;
    align-items: center;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    background-color: var(--bg-surface-glass);
  }
  
  .mobile-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    font-size: 0.68rem;
    font-weight: 500;
    gap: 4px;
    flex: 1;
    height: 100%;
    transition: color var(--transition-fast);
  }
  
  .mobile-nav-item i {
    width: 20px;
    height: 20px;
  }
  
  .mobile-nav-item:hover, .mobile-nav-item.active {
    color: var(--primary);
  }
  
  /* Center circular scanner button */
  .mobile-nav-item-center {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    width: 60px;
    height: 100%;
  }
  
  .scan-circle {
    position: absolute;
    top: -24px;
    width: 54px;
    height: 54px;
    background: linear-gradient(135deg, var(--primary), var(--success));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 16px rgba(99, 102, 241, 0.4);
    border: 4px solid var(--bg-base);
    color: #ffffff;
    transition: transform 0.2s ease;
  }
  
  .scan-circle i {
    width: 24px;
    height: 24px;
  }
  
  .mobile-nav-item-center:active .scan-circle {
    transform: scale(0.92);
  }
}

/* Tablet Specific Styles (Between 576px and 992px) */
@media (min-width: 576px) and (max-width: 991.98px) {
  .report-actions {
    grid-template-columns: 1fr 1fr;
  }
}

/* Small Screens (Below 576px) */
@media (max-width: 575.98px) {
  #page-title {
    font-size: 1.45rem;
  }
  
  .main-content {
    padding: 20px 14px 80px 14px;
  }
  
  .topbar-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }
  
  .topbar-actions {
    width: 100%;
    justify-content: flex-start;
    flex-wrap: wrap;
    gap: 8px;
  }
  
  .topbar-actions .badge {
    flex-grow: 1;
    justify-content: center;
  }
  
  .card-stat {
    padding: 16px 20px;
  }
  
  .card-stat-icon {
    width: 44px;
    height: 44px;
  }
  
  .card-stat-icon i {
    width: 22px;
    height: 22px;
  }
  
  .card-stat-value {
    font-size: 1.4rem;
  }
  
  .grid-cards {
    grid-template-columns: 1fr;
    gap: 16px;
  }
  
  .grid-2-columns, .grid-3-columns {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  
  .table-controls {
    flex-direction: column;
    align-items: stretch;
    gap: 12px !important;
  }
  
  .table-controls .flex-start {
    flex-direction: column;
    align-items: stretch;
    width: 100%;
    gap: 8px !important;
  }
  
  .table-controls button {
    width: 100%;
  }
  
  .search-wrapper {
    max-width: 100%;
  }
  
  .filter-select {
    max-width: 100%;
    width: 100%;
  }
  
  .table th, .table td {
    padding: 10px 12px;
  }
  
  .modal {
    padding: 10px;
  }
  
  .modal-content {
    border-radius: var(--radius-md);
    max-height: calc(100vh - 20px);
    max-height: calc(100dvh - 20px);
  }
  
  .modal-body {
    padding: 16px;
  }
  
  .flex-end {
    flex-direction: column-reverse;
    align-items: stretch;
    gap: 8px !important;
  }
  
  .flex-end .btn {
    width: 100%;
  }
  
  .btn-action {
    width: 38px;
    height: 38px;
  }
  
  .btn-action i {
    width: 18px;
    height: 18px;
  }
}

/* ==========================================================================
   FITUR BARU: CLICKABLE STAT CARDS & CHART FILTER
   ========================================================================== */

/* Stat card clickable */
.card-stat-clickable {
  cursor: pointer;
  position: relative;
  transition: transform var(--transition-normal), box-shadow var(--transition-normal), border-color var(--transition-normal);
}

.card-stat-clickable:hover {
  transform: translateY(-3px) scale(1.02);
  box-shadow: 0 12px 30px rgba(99, 102, 241, 0.18);
  border-color: rgba(99, 102, 241, 0.3);
}

.card-stat-clickable:active {
  transform: translateY(-1px) scale(1.01);
}

/* Chevron arrow di ujung kanan stat card */
.card-stat-arrow {
  display: flex;
  align-items: center;
  margin-left: auto;
  padding-left: 8px;
  opacity: 0.4;
  transition: opacity var(--transition-fast), transform var(--transition-fast);
}

.card-stat-clickable:hover .card-stat-arrow {
  opacity: 1;
  transform: translateX(3px);
}

.card-stat-arrow i {
  width: 16px;
  height: 16px;
}

/* Chart category filter dropdown */
.chart-filter-select {
  min-width: 140px;
  max-width: 180px;
  padding: 6px 10px;
  font-size: 0.8rem;
  height: auto;
  margin-top: 0;
}

.select-xs {
  padding: 5px 10px;
  font-size: 0.8rem;
  height: 34px;
}

/* Badge di tabel kategori */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.01em;
}

/* Hover ripple effect pada stat cards */
.card-stat-clickable::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: radial-gradient(circle at center, rgba(99,102,241,0.08) 0%, transparent 70%);
  opacity: 0;
  transition: opacity var(--transition-normal);
  pointer-events: none;
}

.card-stat-clickable:hover::after {
  opacity: 1;
}

/* Flex Column Utility */
.flex-column {
  display: flex;
  flex-direction: column;
}

/* Sub-category styling */
.sub-cat-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}

.sub-cat-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background-color: var(--secondary-soft, rgba(100, 116, 139, 0.1));
  color: var(--secondary, #475569);
  padding: 2px 8px;
  border-radius: 9999px;
  font-size: 0.7rem;
  font-weight: 500;
  border: 1px solid var(--border);
  transition: all 0.2s ease;
}

.sub-cat-badge:hover {
  background-color: rgba(239, 68, 68, 0.1);
  color: #ef4444;
  border-color: rgba(239, 68, 68, 0.2);
}

.sub-cat-badge-delete {
  cursor: pointer;
  font-weight: bold;
  font-size: 0.8rem;
  line-height: 1;
}

.sub-cat-badge-delete:hover {
  color: #ef4444;
}

/* Accordion Row Category */
.category-row.cursor-pointer {
  cursor: pointer;
}

.category-row:hover {
  background-color: rgba(99, 102, 241, 0.02) !important;
}

.chevron-icon {
  transition: transform 0.2s ease;
  color: var(--text-muted, #94a3b8);
}

.category-row.expanded .chevron-icon {
  transform: rotate(90deg) !important;
  color: var(--primary, #6366f1);
}

.sub-cat-wrapper {
  transition: all 0.25s ease-out;
}

.sub-cat-wrapper.hidden {
  display: none;
}

/* Custom dashboard expired items styling */
#dashboard-expired-card .table-responsive::-webkit-scrollbar {
  width: 6px;
}
#dashboard-expired-card .table-responsive::-webkit-scrollbar-track {
  background: transparent;
}
#dashboard-expired-card .table-responsive::-webkit-scrollbar-thumb {
  background-color: var(--border, rgba(255, 255, 255, 0.1));
  border-radius: 3px;
}
#dashboard-expired-card td {
  padding: 10px 12px;
}

/* ==========================================================================
   AUTHENTICATION & LOGIN STYLING
   ========================================================================== */

.login-wrapper {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: var(--bg-base);
  background-image: radial-gradient(circle at 10% 20%, rgba(99, 102, 241, 0.15) 0%, transparent 40%),
                    radial-gradient(circle at 90% 80%, rgba(16, 185, 129, 0.1) 0%, transparent 40%);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  padding: 20px;
  overflow-y: auto;
}

.login-card {
  width: 100%;
  max-width: 440px;
  background-color: var(--bg-surface-glass);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 40px 32px;
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

.login-header {
  text-align: center;
  margin-bottom: 32px;
}

.login-error-alert {
  display: flex;
  align-items: center;
  gap: 12px;
  background-color: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.2);
  color: #ef4444;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  margin-bottom: 24px;
  font-size: 0.85rem;
  line-height: 1.4;
  animation: shake 0.4s ease-in-out;
}

.login-error-alert .error-icon {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  color: #ef4444;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-6px); }
  40%, 80% { transform: translateX(6px); }
}

.login-logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 64px;
  height: 64px;
  background: linear-gradient(135deg, var(--primary), var(--success));
  color: #ffffff;
  border-radius: var(--radius-md);
  margin-bottom: 16px;
  box-shadow: 0 8px 16px rgba(99, 102, 241, 0.3);
}

.login-logo i {
  width: 32px;
  height: 32px;
}

.login-title {
  font-size: 2rem;
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: 6px;
  letter-spacing: -0.5px;
}

.login-subtitle {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.login-tabs {
  display: flex;
  background-color: rgba(0, 0, 0, 0.15);
  padding: 4px;
  border-radius: var(--radius-sm);
  margin-bottom: 28px;
  border: 1px solid var(--border-color);
}

.login-tab-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: none;
  border: none;
  color: var(--text-secondary);
  padding: 10px;
  font-size: 0.9rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition-fast);
}

.login-tab-btn:hover {
  color: var(--text-primary);
}

.login-tab-btn.active {
  background-color: var(--bg-surface);
  color: var(--primary);
  box-shadow: var(--shadow-sm);
}

.login-tab-content {
  animation: fadeIn 0.3s ease;
}

.login-info-text {
  text-align: center;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 24px;
}

/* User profile dropdown styling in topbar-actions */
.user-profile-menu {
  position: relative;
}

.profile-trigger-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  padding: 6px 14px;
  border-radius: 99px;
  cursor: pointer;
  transition: var(--transition-fast);
  color: var(--text-primary);
}

.profile-trigger-btn:hover {
  border-color: var(--primary);
  background-color: rgba(99, 102, 241, 0.05);
}

.avatar-img {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  border: 1.5px solid var(--primary);
}

.avatar-placeholder {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--success));
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1rem;
}

.profile-info-wrapper {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  text-align: left;
}

.profile-name {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}

.profile-role-badge {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-muted);
  line-height: 1;
  margin-top: 2px;
  text-transform: uppercase;
}

.dropdown-chevron {
  width: 14px;
  height: 14px;
  color: var(--text-secondary);
}

.profile-dropdown-content {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 220px;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 8px;
  z-index: 1001;
  animation: slideDown 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.dropdown-user-details {
  padding: 12px 14px;
}

.dropdown-name {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text-primary);
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dropdown-email {
  font-size: 0.75rem;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dropdown-divider {
  margin: 6px 0;
  border: none;
  border-top: 1px solid var(--border-color);
}

.dropdown-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  background: none;
  border: none;
  padding: 10px 14px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-align: left;
  transition: var(--transition-fast);
}

.dropdown-item:hover {
  background-color: rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
}

.dropdown-item.text-danger:hover {
  background-color: var(--danger-soft);
  color: var(--danger);
}

/* Admin Only Notice banner */
.admin-only-notice {
  background-color: rgba(0, 0, 0, 0.1);
  border: 1px dashed var(--border-color);
  padding: 12px;
  border-radius: var(--radius-sm);
  text-align: center;
  color: var(--text-secondary);
  margin-top: 16px;
  font-size: 0.85rem;
}

/* Category Page Split Layout override for user */
.grid-split-3-7.user-role {
  grid-template-columns: 1fr;
}

/* Mock Google Account Button items */
.mock-google-account-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 14px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  padding: 12px 16px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: var(--transition-fast);
  text-align: left;
  color: var(--text-primary);
}

.mock-google-account-btn:hover {
  background: rgba(99, 102, 241, 0.08);
  border-color: var(--primary);
}

.mock-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background-color: rgba(255, 255, 255, 0.1);
  border: 1.5px solid var(--primary);
}

.mock-info {
  display: flex;
  flex-direction: column;
}

.mock-name {
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--text-primary);
}

.mock-email {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

/* Keyframes */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Responsive auth adjustments */
@media (max-width: 991.98px) {
  .profile-trigger-btn {
    padding: 6px;
  }
  .profile-info-wrapper, .profile-trigger-btn .dropdown-chevron {
    display: none;
  }
}

/* Button small variant */
.btn-sm {
  padding: 6px 14px;
  font-size: 0.8rem;
}

/* User management table in settings */
#user-list-wrapper .table {
  margin-top: 8px;
}
#user-list-wrapper .table th {
  font-size: 0.78rem;
  color: var(--text-secondary);
  padding: 6px 10px;
}
#user-list-wrapper .table td {
  padding: 8px 10px;
  vertical-align: middle;
}
