/* ==========================================================================
   SISTEM INFORMASI PENJUALAN DAN PERSEDIAAN BARANG
   Modern, Premium Design System with CSS Variables, Dark/Light Mode & Glassmorphism
   ========================================================================== */

:root {
  /* Dynamic Theme Variables */
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: rgba(37, 99, 235, 0.1);
  --primary-glow: rgba(37, 99, 235, 0.25);
  --secondary: #4f46e5;
  --sidebar-bg: #0f172a;
  --sidebar-color: #94a3b8;
  --sidebar-active-bg: #1e293b;
  --sidebar-active-color: #38bdf8;
  --btn-color: #2563eb;
  --font-family: 'Plus Jakarta Sans', 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;

  /* Neutrals - Light Mode */
  --bg-app: #f8fafc;
  --bg-card: #ffffff;
  --bg-surface: #f1f5f9;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --border-color: #e2e8f0;
  --border-light: #f1f5f9;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -2px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.04);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.05);

  /* Status Badges & Accents */
  --success: #10b981;
  --success-light: rgba(16, 185, 129, 0.12);
  --warning: #f59e0b;
  --warning-light: rgba(245, 158, 11, 0.12);
  --danger: #ef4444;
  --danger-light: rgba(239, 68, 68, 0.12);
  --info: #06b6d4;
  --info-light: rgba(6, 182, 212, 0.12);

  --sidebar-width: 260px;
  --sidebar-collapsed-width: 78px;
  --header-height: 70px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-full: 9999px;
  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="dark"] {
  --bg-app: #0b1120;
  --bg-card: #1e293b;
  --bg-surface: #0f172a;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --border-color: #334155;
  --border-light: #1e293b;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.4);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.5);
  --sidebar-bg: #090e1a;
  --sidebar-active-bg: #1e293b;
}

/* Global Reset & Base */
* {
  box-sizing: border-box;
}

body {
  font-family: var(--font-family);
  background-color: var(--bg-app);
  color: var(--text-main);
  min-height: 100vh;
  margin: 0;
  padding: 0;
  overflow-x: hidden;
  transition: background-color var(--transition-normal), color var(--transition-normal);
}

/* Scrollbar Customization */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.35);
  border-radius: 9999px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(148, 163, 184, 0.6);
}

/* App Wrapper Layout */
#app-layout {
  display: flex;
  min-height: 100vh;
  width: 100%;
}

/* Sidebar Styles */
.app-sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  color: var(--sidebar-color);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  height: 100vh;
  position: sticky;
  top: 0;
  z-index: 1040;
  transition: width var(--transition-normal), transform var(--transition-normal);
  border-right: 1px solid rgba(255, 255, 255, 0.06);
}

.sidebar-brand {
  height: var(--header-height);
  padding: 0 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}

.brand-wrapper {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  color: #ffffff;
  overflow: hidden;
}

.brand-icon {
  width: 38px;
  height: 38px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: white;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  box-shadow: 0 4px 12px var(--primary-glow);
  flex-shrink: 0;
}

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

.brand-title {
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: -0.02em;
  color: #ffffff;
  line-height: 1.2;
}

.brand-sub {
  font-size: 0.72rem;
  color: #94a3b8;
  font-weight: 500;
}

.sidebar-nav {
  padding: 1rem 0.75rem;
  overflow-y: auto;
  flex: 1;
}

.nav-section-title {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #64748b;
  font-weight: 700;
  padding: 0.75rem 0.75rem 0.35rem;
}

.nav-item-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 0.85rem;
  border-radius: var(--radius-sm);
  color: var(--sidebar-color);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: 2px;
  transition: all var(--transition-fast);
}

.nav-item-link:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #ffffff;
}

.nav-item-link.active {
  background: var(--primary);
  color: #ffffff;
  font-weight: 600;
  box-shadow: 0 4px 12px var(--primary-glow);
}

.nav-item-link i {
  font-size: 1.15rem;
  width: 22px;
  text-align: center;
  flex-shrink: 0;
}

.nav-item-link .badge {
  margin-left: auto;
  font-size: 0.7rem;
  padding: 0.25em 0.55em;
  border-radius: 9999px;
}

/* Sidebar Collapsed State */
.app-sidebar.collapsed {
  width: var(--sidebar-collapsed-width);
}

.app-sidebar.collapsed .brand-text,
.app-sidebar.collapsed .nav-section-title,
.app-sidebar.collapsed .nav-text,
.app-sidebar.collapsed .badge,
.app-sidebar.collapsed .user-details {
  display: none !important;
}

.app-sidebar.collapsed .sidebar-brand {
  justify-content: center;
  padding: 0;
}

.app-sidebar.collapsed .nav-item-link {
  justify-content: center;
  padding: 0.75rem;
}

/* Sidebar User Footer */
.sidebar-footer {
  padding: 0.85rem;
  border-top: 1px solid rgba(255, 255, 255, 0.07);
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  background: #334155;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #e2e8f0;
  font-weight: 600;
  font-size: 0.85rem;
  flex-shrink: 0;
  border: 2px solid rgba(255, 255, 255, 0.15);
}

.user-details {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  white-space: nowrap;
}

.user-name {
  font-size: 0.825rem;
  font-weight: 600;
  color: #f8fafc;
  line-height: 1.2;
}

.user-role {
  font-size: 0.7rem;
  color: #94a3b8;
}

/* Main Content Area */
.app-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 100vh;
}

/* Top Header Bar */
.app-header {
  height: var(--header-height);
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-color);
  padding: 0 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 1020;
  box-shadow: var(--shadow-sm);
  transition: background-color var(--transition-normal), border-color var(--transition-normal);
}

.header-left, .header-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.btn-header-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: var(--bg-surface);
  color: var(--text-main);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-header-icon:hover {
  background: var(--primary-light);
  color: var(--primary);
  border-color: var(--primary);
}

.header-page-title {
  font-size: 1.2rem;
  font-weight: 700;
  margin: 0;
  color: var(--text-main);
  letter-spacing: -0.02em;
}

.db-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.3rem 0.75rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
}
.db-status-badge.online {
  background: var(--success-light);
  color: var(--success);
}
.db-status-badge.offline {
  background: var(--warning-light);
  color: var(--warning);
}
.pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: currentColor;
  display: inline-block;
  animation: pulseAnimation 2s infinite;
}

@keyframes pulseAnimation {
  0% { transform: scale(0.95); opacity: 0.8; }
  50% { transform: scale(1.2); opacity: 1; }
  100% { transform: scale(0.95); opacity: 0.8; }
}

/* Page Container */
.page-container {
  padding: 1.5rem;
  flex: 1;
}

/* Card Modern Style */
.card-modern {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  transition: all var(--transition-normal);
  overflow: hidden;
}

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

.card-header-modern {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: transparent;
}

.card-title-modern {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-main);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.card-body-modern {
  padding: 1.25rem;
}

/* Metric / KPI Cards */
.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  position: relative;
  overflow: hidden;
  transition: all var(--transition-fast);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 120px;
}

.kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--primary);
}

.kpi-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 0.5rem;
}

.kpi-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.kpi-icon-box {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
}

.kpi-icon-box.blue { background: var(--primary-light); color: var(--primary); }
.kpi-icon-box.green { background: var(--success-light); color: var(--success); }
.kpi-icon-box.amber { background: var(--warning-light); color: var(--warning); }
.kpi-icon-box.red { background: var(--danger-light); color: var(--danger); }
.kpi-icon-box.cyan { background: var(--info-light); color: var(--info); }

.kpi-value {
  font-size: 1.55rem;
  font-weight: 800;
  color: var(--text-main);
  letter-spacing: -0.03em;
  line-height: 1.1;
}

.kpi-subtext {
  font-size: 0.775rem;
  color: var(--text-muted);
  margin-top: 0.4rem;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

/* Custom Tables */
.table-modern-wrapper {
  overflow-x: auto;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-card);
}

.table-modern {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
  color: var(--text-main);
  margin: 0;
}

.table-modern thead th {
  background: var(--bg-surface);
  color: var(--text-muted);
  font-weight: 700;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
}

.table-modern tbody td {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border-color);
  vertical-align: middle;
}

.table-modern tbody tr:last-child td {
  border-bottom: none;
}

.table-modern tbody tr:hover {
  background: var(--bg-surface);
}

/* Form Controls & Inputs */
.form-label {
  font-size: 0.825rem;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 0.35rem;
}

.form-control, .form-select {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.85rem;
  font-size: 0.875rem;
  transition: all var(--transition-fast);
}

.form-control:focus, .form-select:focus {
  background-color: var(--bg-card);
  color: var(--text-main);
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
  outline: none;
}

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

/* Buttons */
.btn-primary-modern {
  background: var(--btn-color);
  border: none;
  color: #ffffff;
  padding: 0.6rem 1.15rem;
  font-size: 0.875rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  cursor: pointer;
  box-shadow: 0 2px 4px var(--primary-glow);
  transition: all var(--transition-fast);
}

.btn-primary-modern:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
  box-shadow: 0 4px 10px var(--primary-glow);
  color: #ffffff;
}

.btn-secondary-modern {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 0.6rem 1.15rem;
  font-size: 0.875rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  cursor: pointer;
  transition: all var(--transition-fast);
}

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

/* Status Badges */
.badge-status {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.65rem;
  border-radius: 9999px;
  font-size: 0.725rem;
  font-weight: 700;
  line-height: 1;
}

.badge-lunas { background: var(--success-light); color: var(--success); }
.badge-sebagian { background: var(--warning-light); color: var(--warning); }
.badge-belum { background: var(--danger-light); color: var(--danger); }
.badge-aktif { background: var(--success-light); color: var(--success); }
.badge-nonaktif { background: var(--danger-light); color: var(--danger); }
.badge-draft { background: var(--bg-surface); color: var(--text-muted); border: 1px solid var(--border-color); }
.badge-selesai { background: var(--primary-light); color: var(--primary); }
.badge-batal { background: var(--danger-light); color: var(--danger); }

/* Multi-select Tags Input UI */
.tag-container {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  padding: 0.4rem 0.5rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  min-height: 44px;
  align-items: center;
}

.tag-badge {
  background: var(--primary-light);
  color: var(--primary);
  font-size: 0.775rem;
  font-weight: 600;
  padding: 0.25rem 0.6rem;
  border-radius: 9999px;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.tag-remove-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  color: inherit;
  font-size: 0.9rem;
  padding: 0;
  display: inline-flex;
  align-items: center;
}

.tag-input {
  border: none;
  background: transparent;
  color: var(--text-main);
  outline: none;
  flex: 1;
  min-width: 120px;
  font-size: 0.85rem;
}

/* Image Drag and Drop Zone */
.photo-dropzone {
  border: 2px dashed var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.5rem 1rem;
  text-align: center;
  background: var(--bg-surface);
  cursor: pointer;
  transition: all var(--transition-fast);
  position: relative;
}

.photo-dropzone:hover, .photo-dropzone.dragover {
  border-color: var(--primary);
  background: var(--primary-light);
}

.photo-preview-box {
  width: 90px;
  height: 90px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  margin: 0 auto 0.75rem;
  display: block;
}

/* POS Cart Table Styles */
.pos-table th {
  background: var(--bg-surface);
  font-size: 0.75rem;
}

.pos-total-box {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.25rem;
}

.pos-grand-total {
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--primary);
  letter-spacing: -0.03em;
}

/* Modal Customization */
.modal-content {
  background-color: var(--bg-card);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
}

.modal-header {
  border-bottom: 1px solid var(--border-color);
  padding: 1.25rem 1.5rem;
}

.modal-footer {
  border-top: 1px solid var(--border-color);
  padding: 1rem 1.5rem;
}

.btn-close {
  filter: invert(var(--theme-invert, 0));
}
[data-theme="dark"] .btn-close {
  filter: invert(1);
}

/* Mobile Quick Navigation Bar */
.mobile-nav-bar {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 64px;
  background: var(--bg-card);
  border-top: 1px solid var(--border-color);
  z-index: 1030;
  box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.08);
  justify-content: space-around;
  align-items: center;
  padding: 0 0.5rem;
}

.mobile-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  color: var(--text-muted);
  font-size: 0.7rem;
  font-weight: 600;
  gap: 2px;
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
}

.mobile-nav-item.active, .mobile-nav-item:hover {
  color: var(--primary);
}

.mobile-nav-item i {
  font-size: 1.25rem;
}

/* Toast Notifications */
#toast-container {
  position: fixed;
  top: 1.5rem;
  right: 1.5rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.toast-custom {
  background: var(--bg-card);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 0.85rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 280px;
  max-width: 400px;
  animation: slideInToast 0.3s ease;
}

@keyframes slideInToast {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* Responsive Breakpoints */
@media (max-width: 992px) {
  .app-sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    transform: translateX(-100%);
    box-shadow: var(--shadow-xl);
  }

  .app-sidebar.show-mobile {
    transform: translateX(0);
  }

  .sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(2px);
    z-index: 1035;
  }

  .sidebar-backdrop.show {
    display: block;
  }

  .mobile-nav-bar {
    display: flex;
  }

  .page-container {
    padding: 1rem;
    padding-bottom: 80px; /* Space for bottom nav */
  }
}

@media (max-width: 576px) {
  .app-header {
    padding: 0 1rem;
  }
  .header-page-title {
    font-size: 1.05rem;
  }
  .kpi-value {
    font-size: 1.35rem;
  }
}
