/* Import Google Fonts for modern sans-serif and clean Thai typography */
@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;500;600;700&family=Sarabun:wght@300;400;500;600;700&display=swap');

/* CSS Variables for Premium Design Tokens - Dark Theme (Default) */
:root {
  --font-main: 'Plus Jakarta Sans', 'Sarabun', sans-serif;
  
  /* Color Palette (Deep Slate & High-contrast Accent Colors) */
  --bg-main: #0b0f19;
  --bg-sidebar: #111827;
  --bg-card: rgba(22, 28, 45, 0.75);
  --bg-card-hover: rgba(30, 41, 59, 0.9);
  --border-color: rgba(255, 255, 255, 0.08);
  --border-focus: rgba(99, 102, 241, 0.5);
  
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  
  /* Accent Colors */
  --primary: #6366f1; /* Indigo */
  --primary-hover: #4f46e5;
  --secondary: #14b8a6; /* Teal */
  --secondary-hover: #0d9488;
  --success: #10b981; /* Emerald */
  --success-glow: rgba(16, 185, 129, 0.15);
  --warning: #f59e0b; /* Amber */
  --warning-glow: rgba(245, 158, 11, 0.15);
  --danger: #ef4444; /* Rose */
  --danger-glow: rgba(239, 68, 68, 0.15);
  
  /* UI Constants */
  --sidebar-width: 260px;
  --card-radius: 16px;
  --btn-radius: 10px;
  --input-radius: 10px;
  --shadow-sm: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.2), 0 4px 6px -4px rgb(0 0 0 / 0.2);
  --shadow-glow: 0 0 20px rgba(99, 102, 241, 0.15);
}

/* Light Theme Variables Overrides */
body.light-theme {
  --bg-main: #f8fafc;
  --bg-sidebar: #f1f5f9;
  --bg-card: rgba(255, 255, 255, 0.8);
  --bg-card-hover: rgba(255, 255, 255, 0.95);
  --border-color: rgba(0, 0, 0, 0.08);
  --border-focus: rgba(99, 102, 241, 0.4);
  
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;
  
  --shadow-sm: 0 4px 6px -1px rgba(0,0,0,0.05), 0 2px 4px -2px rgba(0,0,0,0.05);
  --shadow-lg: 0 10px 25px -3px rgba(0,0,0,0.08), 0 4px 6px -4px rgba(0,0,0,0.08);
}

/* Global Reset */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: var(--font-main);
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.1) transparent;
}

body.light-theme * {
  scrollbar-color: rgba(0, 0, 0, 0.1) transparent;
}

/* Scrollbar customizations */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 10px;
}
body.light-theme ::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.15);
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.3);
}

body {
  background-color: var(--bg-main);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  overflow-x: hidden;
  position: relative;
  transition: background-color 0.3s ease, color 0.3s ease;
}

/* Background Glowing Orbs for Premium Aesthetics */
body::before, body::after {
  content: '';
  position: absolute;
  width: 400px;
  height: 400px;
  border-radius: 50%;
  filter: blur(120px);
  z-index: -1;
  opacity: 0.15;
  transition: opacity 0.3s ease;
}
body.light-theme::before, body.light-theme::after {
  opacity: 0.06;
}
body::before {
  top: 10%;
  left: 20%;
  background: var(--primary);
}
body::after {
  bottom: 15%;
  right: 10%;
  background: var(--secondary);
}

/* Main Layout Structure */
#app-layout {
  display: flex;
  width: 100vw;
  min-height: 100vh;
}

/* Sidebar Navigation */
.sidebar {
  width: var(--sidebar-width);
  background-color: var(--bg-sidebar);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  padding: 24px 16px;
  position: fixed;
  height: 100vh;
  z-index: 10;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

.brand-logo {
  width: 38px;
  height: 38px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 20px;
  color: #fff;
  box-shadow: 0 0 15px rgba(99, 102, 241, 0.4);
}

.brand-name {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.5px;
  background: linear-gradient(to right, #ffffff, #94a3b8);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
body.light-theme .brand-name {
  background: linear-gradient(to right, #0f172a, #475569);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* Theme Toggle Button Style in Sidebar Footer */
.theme-toggle-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background-color: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-color);
  border-radius: var(--btn-radius);
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  transition: all 0.25s ease;
}

.theme-toggle-btn:hover {
  color: var(--text-primary);
  background-color: rgba(255, 255, 255, 0.08);
}

body.light-theme .theme-toggle-btn {
  background-color: rgba(0, 0, 0, 0.03);
}

.theme-toggle-btn i {
  font-size: 16px;
  width: 20px;
  text-align: center;
}


.menu-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex-grow: 1;
}

.menu-item a {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 11px 16px;
  color: var(--text-secondary);
  text-decoration: none;
  border-radius: var(--btn-radius);
  font-weight: 500;
  font-size: 15px;
  transition: all 0.25s ease;
  cursor: pointer;
}

.menu-item a:hover {
  color: var(--text-primary);
  background-color: rgba(255, 255, 255, 0.04);
}
body.light-theme .menu-item a:hover {
  background-color: rgba(0, 0, 0, 0.03);
}

.menu-item.active a {
  color: #fff;
  background: linear-gradient(to right, rgba(99, 102, 241, 0.2), rgba(20, 184, 166, 0.05));
  border-left: 3px solid var(--primary);
  padding-left: 13px; /* Offset the border */
}

body.light-theme .menu-item.active a {
  color: var(--primary);
  background: linear-gradient(to right, rgba(99, 102, 241, 0.08), rgba(20, 184, 166, 0.02));
}

.menu-item i {
  font-size: 18px;
  width: 20px;
  text-align: center;
}

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

.btn-backup-restore {
  width: 100%;
  background: transparent;
  border: 1px dashed var(--border-color);
  color: var(--text-secondary);
  padding: 10px;
  border-radius: var(--btn-radius);
  font-size: 13px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.2s ease;
}

.btn-backup-restore:hover {
  border-color: var(--secondary);
  color: var(--secondary);
  background-color: rgba(20, 184, 166, 0.05);
}

/* Main Content Area */
.main-content {
  margin-left: var(--sidebar-width);
  flex-grow: 1;
  padding: 32px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 28px;
  max-width: calc(100vw - var(--sidebar-width));
  transition: margin-left 0.3s ease, max-width 0.3s ease;
}

/* Page Headers */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.page-title h1 {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.5px;
  margin-bottom: 4px;
}

.page-title p {
  color: var(--text-secondary);
  font-size: 14px;
}

/* Action Groups: Placed on the right side of header to keep layout clean and organized */
.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Standardized Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: var(--btn-radius);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  border: none;
  white-space: nowrap;
}

.btn-primary {
  background-color: var(--primary);
  color: #fff;
  box-shadow: 0 4px 10px rgba(99, 102, 241, 0.25);
}
.btn-primary:hover {
  background-color: var(--primary-hover);
  transform: translateY(-1px);
  box-shadow: 0 6px 15px rgba(99, 102, 241, 0.35);
}
.btn-primary:active {
  transform: translateY(0);
}

.btn-secondary {
  background-color: var(--secondary);
  color: #fff;
  box-shadow: 0 4px 10px rgba(20, 184, 166, 0.25);
}
.btn-secondary:hover {
  background-color: var(--secondary-hover);
  transform: translateY(-1px);
  box-shadow: 0 6px 15px rgba(20, 184, 166, 0.35);
}

.btn-danger {
  background-color: var(--danger);
  color: #fff;
  box-shadow: 0 4px 10px rgba(239, 68, 68, 0.25);
}
.btn-danger:hover {
  background-color: #dc2626;
  transform: translateY(-1px);
}

.btn-outline {
  background-color: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-primary);
}
.btn-outline:hover {
  background-color: rgba(255, 255, 255, 0.05);
  border-color: var(--text-secondary);
}
body.light-theme .btn-outline {
  border-color: rgba(0,0,0,0.15);
}
body.light-theme .btn-outline:hover {
  background-color: rgba(0,0,0,0.03);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 12px;
  border-radius: 6px;
}

.btn-icon-only {
  width: 36px;
  height: 36px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
}

/* Glassmorphic Cards */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--card-radius);
  padding: 24px;
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition: border-color 0.3s ease, box-shadow 0.3s ease, background-color 0.3s ease;
}

.card:hover {
  border-color: rgba(255, 255, 255, 0.12);
  box-shadow: var(--shadow-lg);
}

body.light-theme .card:hover {
  border-color: rgba(0, 0, 0, 0.12);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.card-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
}

/* Dashboard Grid Layout */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
}

.stat-card {
  display: flex;
  align-items: center;
  gap: 20px;
}

.stat-icon {
  width: 50px;
  height: 50px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
}

.stat-icon.primary { background: rgba(99, 102, 241, 0.15); color: var(--primary); }
.stat-icon.secondary { background: rgba(20, 184, 166, 0.15); color: var(--secondary); }
.stat-icon.success { background: rgba(16, 185, 129, 0.15); color: var(--success); }
.stat-icon.warning { background: rgba(245, 158, 11, 0.15); color: var(--warning); }

.stat-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.stat-label {
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 500;
}

.stat-value {
  font-size: 24px;
  font-weight: 700;
  color: var(--text-primary);
}

/* Dashboard Bottom Grid */
.dashboard-details-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 24px;
}

/* Alerts List Styling */
.alerts-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.alert-item {
  display: flex;
  align-items: start;
  gap: 14px;
  padding: 14px 16px;
  border-radius: 10px;
  border-left: 4px solid transparent;
  transition: all 0.25s ease;
}

.alert-item.danger {
  background-color: var(--danger-glow);
  border-left-color: var(--danger);
}
.alert-item.warning {
  background-color: var(--warning-glow);
  border-left-color: var(--warning);
}
.alert-item.success {
  background-color: var(--success-glow);
  border-left-color: var(--success);
}

.alert-body {
  flex-grow: 1;
}

.alert-title {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 2px;
}

.alert-desc {
  font-size: 12px;
  color: var(--text-secondary);
}

.alert-icon {
  font-size: 18px;
  margin-top: 2px;
}
.alert-item.danger .alert-icon { color: var(--danger); }
.alert-item.warning .alert-icon { color: var(--warning); }
.alert-item.success .alert-icon { color: var(--success); }

/* Custom HTML Bar Chart for Sales */
.chart-container {
  height: 200px;
  display: flex;
  align-items: flex-end;
  justify-content: space-around;
  padding-top: 20px;
  border-bottom: 1px solid var(--border-color);
  position: relative;
}

.chart-bar-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 12%;
  height: 100%;
  justify-content: flex-end;
}

.chart-bar {
  width: 100%;
  border-top-left-radius: 6px;
  border-top-right-radius: 6px;
  background: linear-gradient(to top, var(--primary), var(--secondary));
  transition: height 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  min-height: 4px;
  position: relative;
  cursor: pointer;
}

.chart-bar:hover {
  filter: brightness(1.2);
}

.chart-tooltip {
  position: absolute;
  top: -35px;
  left: 50%;
  transform: translateX(-50%);
  background-color: var(--bg-sidebar);
  border: 1px solid var(--border-color);
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  white-space: nowrap;
  box-shadow: var(--shadow-sm);
  z-index: 5;
}

.chart-bar:hover .chart-tooltip {
  opacity: 1;
}

.chart-label {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 8px;
  text-align: center;
}

/* POS Panel Grid Layout */
.pos-layout {
  display: grid;
  grid-template-columns: 1.5fr 1fr;
  gap: 24px;
  height: calc(100vh - 150px);
  min-height: 550px;
}

/* Left POS: Medication Selector and Search */
.pos-products {
  display: flex;
  flex-direction: column;
  gap: 16px;
  height: 100%;
  overflow-y: hidden;
}

.search-bar-container {
  display: flex;
  gap: 12px;
}

.search-input-wrapper {
  position: relative;
  flex-grow: 1;
}

.search-input-wrapper i {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
}

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

.form-control {
  width: 100%;
  background-color: rgba(15, 23, 42, 0.6);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 10px 14px 10px 40px;
  border-radius: var(--input-radius);
  outline: none;
  font-size: 14px;
  transition: all 0.2s ease;
}

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

body.light-theme .form-control,
body.light-theme .filter-select,
body.light-theme .form-group input,
body.light-theme .form-group textarea,
body.light-theme .form-group select,
body.light-theme .checkout-input-group input {
  background-color: #ffffff;
  border-color: rgba(0, 0, 0, 0.15);
  color: #0f172a;
}

body.light-theme .form-control:focus,
body.light-theme .filter-select:focus,
body.light-theme .form-group input:focus,
body.light-theme .form-group textarea:focus,
body.light-theme .form-group select:focus,
body.light-theme .checkout-input-group input:focus {
  border-color: var(--primary);
}

.no-icon-input {
  padding-left: 14px !important;
}

.pos-grid-scroll {
  flex-grow: 1;
  overflow-y: auto;
  padding-right: 4px;
}

.pos-products-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}

.product-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
  height: 100%;
}

.product-card:hover {
  transform: translateY(-2px);
  border-color: rgba(99, 102, 241, 0.4);
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
}

.product-card.out-of-stock {
  opacity: 0.65;
  cursor: not-allowed;
  border-color: rgba(239, 68, 68, 0.2);
}

.product-meta {
  display: flex;
  justify-content: space-between;
  align-items: start;
}

.product-category {
  font-size: 11px;
  background-color: rgba(255, 255, 255, 0.05);
  color: var(--text-secondary);
  padding: 2px 8px;
  border-radius: 50px;
  font-weight: 500;
}
body.light-theme .product-category {
  background-color: rgba(0, 0, 0, 0.05);
}

.product-stock-tag {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 4px;
}

.product-stock-tag.in-stock {
  color: var(--secondary);
  background: rgba(20, 184, 166, 0.1);
}
.product-stock-tag.low-stock {
  color: var(--warning);
  background: rgba(245, 158, 11, 0.1);
}
.product-stock-tag.empty {
  color: var(--danger);
  background: rgba(239, 68, 68, 0.1);
}
.product-stock-tag.expired {
  color: var(--danger);
  background: rgba(239, 68, 68, 0.15);
  animation: pulse-danger-tag 2s infinite;
}

@keyframes pulse-danger-tag {
  0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
  70% { box-shadow: 0 0 0 6px rgba(239, 68, 68, 0); }
  100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

.product-card-body h3 {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 2px;
  line-height: 1.3;
}

.product-generic-name {
  font-size: 12px;
  color: var(--text-secondary);
  font-style: italic;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 6px;
}

.product-card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top: 1px solid var(--border-color);
  padding-top: 10px;
}

.product-price {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
}

.product-price small {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 400;
  margin-left: 2px;
}

/* Right POS: Checkout Cart panel */
.pos-cart-panel {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow-y: hidden;
}

.customer-select-section {
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-color);
}

.customer-selector-wrapper {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.customer-select-control {
  flex-grow: 1;
}

.customer-info-pill {
  margin-top: 10px;
  background-color: rgba(99, 102, 241, 0.08);
  border: 1px solid rgba(99, 102, 241, 0.2);
  padding: 10px 14px;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.customer-info-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.customer-info-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.customer-allergy-alert-banner {
  background-color: var(--danger-glow);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: var(--danger);
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}

.customer-info-detail {
  font-size: 12px;
  color: var(--text-secondary);
}

/* Member Points Discount styling container */
.member-points-redeem-box {
  margin-top: 6px;
  background-color: rgba(16, 185, 129, 0.08);
  border: 1px solid rgba(16, 185, 129, 0.2);
  border-radius: 8px;
  padding: 8px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
}

.member-points-label {
  font-weight: 600;
  color: var(--success);
}

.member-points-checkbox-container {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}

.member-points-checkbox-container input {
  cursor: pointer;
  accent-color: var(--success);
}

.cart-items-scroll {
  flex-grow: 1;
  overflow-y: auto;
  padding: 6px 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.cart-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background-color: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 8px 12px;
  border-radius: 8px;
  gap: 10px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

body.light-theme .cart-item {
  background-color: #ffffff;
  border-color: rgba(0, 0, 0, 0.08);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.03);
}

.cart-item-info {
  flex-grow: 1;
  min-width: 0;
}

.cart-item-name {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cart-item-price {
  font-size: 12px;
  color: var(--text-secondary);
}

.cart-item-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.cart-qty-btn {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: 1px solid var(--border-color);
  background-color: rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.15s ease;
}

body.light-theme .cart-qty-btn {
  background-color: rgba(0, 0, 0, 0.03);
}

.cart-qty-btn:hover {
  background-color: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.cart-qty-value {
  font-size: 14px;
  font-weight: 600;
  min-width: 20px;
  text-align: center;
}

.cart-item-total {
  font-size: 15px;
  font-weight: 700;
  min-width: 65px;
  text-align: right;
  color: var(--text-primary);
}

.cart-item-delete {
  color: var(--text-muted);
  font-size: 15px;
  cursor: pointer;
  padding: 4px;
  transition: color 0.15s ease;
}

.cart-item-delete:hover {
  color: var(--danger);
}

/* Allergy Conflict Cart Item Style */
.cart-item.allergy-warning {
  border-color: rgba(239, 68, 68, 0.5);
  background-color: rgba(239, 68, 68, 0.05);
  animation: shake 0.5s ease-in-out;
}

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

.cart-summary-section {
  border-top: 1px solid var(--border-color);
  padding-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.summary-row {
  display: flex;
  justify-content: space-between;
  font-size: 14px;
  color: var(--text-secondary);
}

.summary-row.total {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  margin-top: 4px;
  border-top: 1px dashed var(--border-color);
  padding-top: 8px;
}

/* POS Checkout Form Details */
.checkout-input-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 4px;
}

.checkout-input-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.checkout-input-group label {
  font-size: 11px;
  color: var(--text-secondary);
  font-weight: 600;
}

.checkout-input-group input {
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  background-color: rgba(15, 23, 42, 0.6);
  color: var(--text-primary);
  font-size: 14px;
  outline: none;
  font-weight: 600;
}

.checkout-input-group input:focus {
  border-color: var(--primary);
}

.pos-checkout-btn-container {
  margin-top: 12px;
}

.pos-checkout-btn-container button {
  width: 100%;
  padding: 12px;
  font-size: 16px;
  border-radius: 12px;
}

/* Tables and Data Lists */
.table-container {
  overflow-x: auto;
  margin-top: 12px;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

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

.data-table th {
  font-size: 12px;
  text-transform: uppercase;
  color: var(--text-secondary);
  font-weight: 600;
  letter-spacing: 0.5px;
  background-color: rgba(255, 255, 255, 0.01);
}

body.light-theme .data-table th {
  background-color: rgba(0, 0, 0, 0.02);
}

.data-table tbody tr {
  transition: background-color 0.15s ease;
}

.data-table tbody tr:hover {
  background-color: rgba(255, 255, 255, 0.02);
}
body.light-theme .data-table tbody tr:hover {
  background-color: rgba(0, 0, 0, 0.02);
}

.table-badge {
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 50px;
  font-weight: 600;
  display: inline-block;
}

.badge-success { background: rgba(16, 185, 129, 0.15); color: var(--success); }
.badge-warning { background: rgba(245, 158, 11, 0.15); color: var(--warning); }
.badge-danger { background: rgba(239, 68, 68, 0.15); color: var(--danger); }
.badge-info { background: rgba(99, 102, 241, 0.15); color: var(--primary); }

.table-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end; /* Keep buttons aligned neatly on the right */
}

/* Search and Filter Panel (Neat and organized) */
.filter-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 16px;
}

.filter-left {
  display: flex;
  gap: 12px;
  flex-grow: 1;
  max-width: 480px;
}

.filter-select {
  background-color: rgba(15, 23, 42, 0.6);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 10px 14px;
  border-radius: var(--input-radius);
  outline: none;
  font-size: 14px;
  cursor: pointer;
}

.filter-select:focus {
  border-color: var(--primary);
}

/* Modals (Clean Overlay with Blur and Animations) */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: rgba(7, 10, 20, 0.8);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-container {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--card-radius);
  width: 90%;
  max-width: 640px;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
  transform: scale(0.95);
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  display: flex;
  flex-direction: column;
}

.modal-overlay.active .modal-container {
  transform: scale(1);
}

.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  background: rgba(18, 25, 41, 0.95);
  backdrop-filter: blur(12px);
  z-index: 2;
}

body.light-theme .modal-header {
  background: rgba(241, 245, 249, 0.95);
}

.modal-title {
  font-size: 18px;
  font-weight: 700;
}

.modal-close {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 20px;
  cursor: pointer;
  transition: color 0.15s ease;
}

.modal-close:hover {
  color: var(--danger);
}

.modal-body {
  padding: 24px;
  overflow-y: auto;
  flex-grow: 1;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end; /* Align primary buttons to the bottom right */
  gap: 12px;
  background: rgba(18, 25, 41, 0.95);
  position: sticky;
  bottom: 0;
  z-index: 2;
}
body.light-theme .modal-footer {
  background: rgba(241, 245, 249, 0.95);
}

/* Modal Form Controls */
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

.form-group-full {
  grid-column: span 2;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
}

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

.form-group input, .form-group textarea, .form-group select {
  width: 100%;
  background-color: rgba(15, 23, 42, 0.6);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 10px 12px;
  border-radius: var(--input-radius);
  outline: none;
  font-size: 14px;
}

.form-group textarea {
  resize: vertical;
  min-height: 80px;
}

.form-group input:focus, .form-group textarea:focus, .form-group select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--border-focus);
}

/* Clinical Drug Info Layout in Detail Modal */
.clinical-section {
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border-color);
}

.clinical-section:last-child {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: none;
}

.clinical-title {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--secondary);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.clinical-title.danger-title {
  color: var(--danger);
}

.clinical-text {
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-primary);
  background-color: rgba(255, 255, 255, 0.02);
  padding: 12px;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  white-space: pre-line; /* Support newlines in seed data */
}
body.light-theme .clinical-text {
  background-color: #ffffff;
  border-color: rgba(0, 0, 0, 0.1);
}

/* Customer Profile View & Timeline */
.customer-profile-layout {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 24px;
}

.customer-detail-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.detail-info-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.detail-info-label {
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 500;
}

.detail-info-value {
  font-size: 14px;
  font-weight: 600;
}

.customer-history-timeline {
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-height: 450px;
  overflow-y: auto;
  padding-right: 8px;
}

.timeline-item {
  position: relative;
  padding-left: 24px;
  border-left: 2px solid var(--border-color);
  padding-bottom: 16px;
}

.timeline-item::before {
  content: '';
  position: absolute;
  left: -6px;
  top: 4px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background-color: var(--primary);
  border: 2px solid var(--bg-main);
}
body.light-theme .timeline-item::before {
  border-color: #fff;
}

.timeline-date {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
  margin-bottom: 4px;
}

.timeline-title {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 6px;
}

.timeline-drugs-list {
  background-color: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 10px;
  font-size: 13px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
body.light-theme .timeline-drugs-list {
  background-color: #ffffff;
  border-color: rgba(0, 0, 0, 0.08);
}

.timeline-drug-row {
  display: flex;
  justify-content: space-between;
}

/* Critical Warning Box (e.g. Allergy Warnings) */
.danger-warning-box {
  background-color: var(--danger-glow);
  border: 2px solid var(--danger);
  border-radius: 12px;
  padding: 18px;
  display: flex;
  gap: 16px;
  align-items: start;
  margin-bottom: 20px;
  animation: pulse-danger-bg 2.5s infinite;
}

@keyframes pulse-danger-bg {
  0%, 100% { background-color: rgba(239, 68, 68, 0.12); }
  50% { background-color: rgba(239, 68, 68, 0.22); }
}

.danger-warning-icon {
  font-size: 28px;
  color: var(--danger);
}

.danger-warning-body {
  flex-grow: 1;
}

.danger-warning-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--danger);
  margin-bottom: 4px;
}

.danger-warning-desc {
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-primary);
}

/* Receipt Detail Modal Layout */
.receipt-invoice-box {
  background-color: #ffffff;
  color: #1e293b;
  padding: 24px;
  border-radius: 8px;
  font-family: monospace;
  font-size: 13px;
  box-shadow: var(--shadow-sm);
  border: 1px solid #e2e8f0;
}

.receipt-invoice-box h2 {
  font-size: 18px;
  font-weight: 700;
  text-align: center;
  margin-bottom: 12px;
}

.receipt-divider {
  border-top: 1px dashed #94a3b8;
  margin: 12px 0;
}

/* Medicine Label Editor */
.label-editor-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

.label-preview-container {
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: rgba(0, 0, 0, 0.2);
  border: 1px dashed var(--border-color);
  border-radius: 12px;
  padding: 20px;
}

/* The actual sticker mockup */
.medicine-label-sticker {
  width: 340px;
  background-color: #ffffff;
  color: #0f172a;
  border: 2px solid #0f172a;
  padding: 16px;
  border-radius: 4px;
  font-family: 'Sarabun', sans-serif;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.label-header {
  border-bottom: 2px solid #0f172a;
  padding-bottom: 6px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.label-pharmacy-name {
  font-size: 16px;
  font-weight: 700;
}

.label-pharmacy-tel {
  font-size: 11px;
  color: #475569;
}

.label-field {
  display: flex;
  font-size: 13px;
  line-height: 1.4;
  gap: 4px;
}

.label-field-title {
  font-weight: 700;
  white-space: nowrap;
}

.label-field-value {
  border-bottom: 1px dotted #475569;
  flex-grow: 1;
  word-break: break-word;
}

.label-dosage-box {
  background-color: #f1f5f9;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  padding: 8px;
  margin: 4px 0;
  font-size: 14px;
  font-weight: 700;
  text-align: center;
  color: #1e3a8a;
  line-height: 1.4;
}

.label-warning-text {
  font-size: 11px;
  font-weight: 700;
  color: #dc2626;
  text-align: center;
  border-top: 1px solid #e2e8f0;
  padding-top: 4px;
}

.label-footer-date {
  font-size: 10px;
  color: #64748b;
  text-align: right;
  margin-top: 4px;
}

/* Category manager list inside Modal */
.category-manager-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 250px;
  overflow-y: auto;
  border: 1px solid var(--border-color);
  padding: 8px;
  border-radius: 8px;
}

.category-manager-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  background-color: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-color);
  border-radius: 6px;
}
body.light-theme .category-manager-item {
  background-color: #ffffff;
  border-color: rgba(0,0,0,0.08);
}

/* Printing styling */
#print-section {
  display: none;
}

@media print {
  body * {
    visibility: hidden;
  }
  
  #print-section, #print-section * {
    visibility: visible;
  }
  
  #print-section {
    display: block;
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    background: white !important;
    color: black !important;
    padding: 0;
    margin: 0;
  }
  
  /* Reset margins for label printing */
  @page {
    margin: 0;
    size: auto;
  }
  
  /* Print layout modifications for receipt */
  .print-receipt-container {
    width: 80mm;
    font-family: monospace;
    font-size: 12px;
    padding: 10px;
    background: white;
    color: black;
  }
  
  /* Print layout modifications for drug labels */
  .print-label-container {
    width: 90mm;
    min-height: 60mm;
    padding: 15px;
    border: 1px solid black;
    background: white;
    color: black;
    box-shadow: none !important;
  }
}

/* Notification Toast System */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 9999;
}

.toast {
  background-color: var(--bg-sidebar);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 14px 20px;
  border-radius: 8px;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 14px;
  min-width: 280px;
  max-width: 400px;
  transform: translateY(20px);
  opacity: 0;
  animation: slide-in 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

body.light-theme .toast {
  background-color: #ffffff;
}

@keyframes slide-in {
  to { transform: translateY(0); opacity: 1; }
}

.toast.success { border-left: 4px solid var(--success); }
.toast.danger { border-left: 4px solid var(--danger); }
.toast.warning { border-left: 4px solid var(--warning); }

.toast i {
  font-size: 18px;
}
.toast.success i { color: var(--success); }
.toast.danger i { color: var(--danger); }
.toast.warning i { color: var(--warning); }

/* Quick Navigation helper class */
.d-none {
  display: none !important;
}

.pointer {
  cursor: pointer;
}

.text-danger { color: var(--danger) !important; }
.text-warning { color: var(--warning) !important; }
.text-success { color: var(--success) !important; }
.text-secondary { color: var(--text-secondary) !important; }
.font-bold { font-weight: 700 !important; }

/* Responsive adjustments */
@media (max-width: 1024px) {
  .pos-layout {
    grid-template-columns: 1fr;
    height: auto;
  }
  .pos-cart-panel {
    height: 550px;
  }
  .dashboard-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .dashboard-details-grid {
    grid-template-columns: 1fr;
  }
  .label-editor-layout {
    grid-template-columns: 1fr;
  }
  .customer-profile-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .sidebar {
    width: 60px;
    padding: 24px 8px;
  }
  .brand-name, .sidebar-footer, .menu-item span, .theme-toggle-btn span {
    display: none;
  }
  .brand {
    justify-content: center;
    padding: 0 0 20px 0;
  }
  .theme-toggle-container {
    padding: 0;
  }
  .theme-toggle-btn {
    justify-content: center;
    padding: 10px 0;
  }
  .main-content {
    margin-left: 60px;
    max-width: calc(100vw - 60px);
    padding: 16px;
  }
  .dashboard-grid {
    grid-template-columns: 1fr;
  }
  .form-grid {
    grid-template-columns: 1fr;
  }
  .form-group-full {
    grid-column: span 1;
  }
}

/* Reports view specific styling */
.reports-layout {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.reports-financial-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr); /* 4 columns: Revenue, Cost, Profit, Expiry Loss */
  gap: 20px;
}

.financial-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 12px;
  padding: 20px;
  border-radius: var(--card-radius);
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: var(--shadow-sm);
  transition: all 0.25s ease;
}

.financial-card:hover {
  border-color: rgba(255,255,255,0.12);
  box-shadow: var(--shadow-lg);
  transform: translateY(-1px);
}

body.light-theme .financial-card:hover {
  border-color: rgba(0,0,0,0.12);
}

.financial-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.financial-title {
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 600;
}

.financial-icon {
  width: 38px;
  height: 38px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}

.financial-icon.revenue { background: rgba(20, 184, 166, 0.15); color: var(--secondary); }
.financial-icon.cogs { background: rgba(99, 102, 241, 0.15); color: var(--primary); }
.financial-icon.profit { background: rgba(16, 185, 129, 0.15); color: var(--success); }
.financial-icon.loss { background: rgba(239, 68, 68, 0.15); color: var(--danger); }

.financial-value {
  font-size: 24px;
  font-weight: 700;
}

.reports-tables-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

.reports-full-width-section {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

body.light-theme .financial-card {
  background: rgba(255, 255, 255, 0.8);
  border-color: rgba(0, 0, 0, 0.08);
}

@media (max-width: 1024px) {
  .reports-financial-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .reports-tables-grid {
    grid-template-columns: 1fr;
  }
}
