/* =====================================================
   Fuel Station Management System - Main Stylesheet
   ===================================================== */

:root {
  --sidebar-width: 260px;
  --topbar-height: 60px;
  --transition: 0.25s ease;

  /* Light theme */
  --bg-body: #f0f2f5;
  --bg-sidebar: #1a1a2e;
  --bg-sidebar-hover: rgba(255,255,255,0.08);
  --bg-card: #ffffff;
  --bg-topbar: #ffffff;
  --text-primary: #212529;
  --text-secondary: #6c757d;
  --text-sidebar: rgba(255,255,255,0.85);
  --text-sidebar-active: #ffffff;
  --border-color: #dee2e6;
  --shadow: 0 2px 12px rgba(0,0,0,0.08);
  --sidebar-active-bg: linear-gradient(90deg,#f97316,#ef4444);
  --accent: #f97316;
  --fuel-gradient: linear-gradient(135deg,#667eea,#764ba2);
}

[data-bs-theme="dark"] {
  --bg-body: #0f0f1a;
  --bg-sidebar: #0a0a15;
  --bg-sidebar-hover: rgba(255,255,255,0.06);
  --bg-card: #1a1a2e;
  --bg-topbar: #1a1a2e;
  --text-primary: #e9ecef;
  --text-secondary: #adb5bd;
  --border-color: #2d2d45;
  --shadow: 0 2px 12px rgba(0,0,0,0.4);
}

/* Base */
body {
  font-family: 'Sarabun', 'Segoe UI', sans-serif;
  background: var(--bg-body);
  color: var(--text-primary);
  font-size: 15px;
  overflow-x: hidden;
}

/* Sidebar */
#sidebar {
  position: fixed;
  left: 0; top: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--bg-sidebar);
  z-index: 1040;
  display: flex;
  flex-direction: column;
  transition: transform var(--transition), width var(--transition);
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.1) transparent;
}

#sidebar::-webkit-scrollbar { width: 4px; }
#sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 2px; }

.sidebar-logo {
  padding: 20px 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  flex-shrink: 0;
}

.sidebar-logo .logo-text {
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  letter-spacing: 0.5px;
}

.sidebar-logo .logo-sub {
  font-size: 11px;
  color: rgba(255,255,255,0.5);
  margin-top: 2px;
}

.logo-icon {
  width: 38px; height: 38px;
  background: var(--sidebar-active-bg);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; color: #fff;
  flex-shrink: 0;
}

.sidebar-nav { flex: 1; padding: 10px 0; }

.nav-section-title {
  font-size: 10px;
  font-weight: 700;
  color: rgba(255,255,255,0.3);
  text-transform: uppercase;
  letter-spacing: 1.2px;
  padding: 14px 20px 4px;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  color: var(--text-sidebar);
  text-decoration: none;
  border-radius: 0;
  transition: all var(--transition);
  font-size: 14px;
  position: relative;
  white-space: nowrap;
}

.sidebar-link:hover {
  background: var(--bg-sidebar-hover);
  color: #fff;
}

.sidebar-link.active {
  background: var(--sidebar-active-bg);
  color: #fff;
  font-weight: 600;
}

.sidebar-link.active::before {
  content: '';
  position: absolute;
  right: 0; top: 0; bottom: 0;
  width: 3px;
  background: rgba(255,255,255,0.5);
  border-radius: 3px 0 0 3px;
}

.sidebar-link .nav-icon {
  width: 20px; text-align: center;
  font-size: 16px; flex-shrink: 0;
}

.sidebar-link .badge-notify {
  margin-left: auto;
  font-size: 10px; min-width: 18px; height: 18px;
  padding: 0 5px;
  display: flex; align-items: center; justify-content: center;
}

/* Main content */
#main-content {
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  display: flex; flex-direction: column;
  transition: margin var(--transition);
}

/* Topbar */
#topbar {
  height: var(--topbar-height);
  background: var(--bg-topbar);
  border-bottom: 1px solid var(--border-color);
  display: flex; align-items: center;
  padding: 0 20px;
  gap: 12px;
  position: sticky; top: 0; z-index: 1030;
  box-shadow: var(--shadow);
}

.topbar-title {
  font-size: 16px; font-weight: 600;
  color: var(--text-primary);
  flex: 1;
}

.topbar-btn {
  width: 38px; height: 38px;
  border-radius: 10px;
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  color: var(--text-primary);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: all var(--transition);
  font-size: 16px;
}

.topbar-btn:hover { background: var(--accent); color: #fff; border-color: var(--accent); }

.branch-badge {
  background: linear-gradient(90deg, #f97316, #ef4444);
  color: #fff;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}

/* Page content */
.page-content {
  padding: 24px;
  flex: 1;
}

/* Cards */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  box-shadow: var(--shadow);
}

.card-header {
  background: transparent;
  border-bottom: 1px solid var(--border-color);
  padding: 16px 20px;
  font-weight: 600;
  font-size: 15px;
}

/* Stat Cards */
.stat-card {
  border-radius: 16px;
  padding: 20px;
  color: #fff;
  position: relative;
  overflow: hidden;
  border: none;
  box-shadow: 0 4px 20px rgba(0,0,0,0.15);
}

.stat-card::after {
  content: '';
  position: absolute;
  top: -30px; right: -30px;
  width: 120px; height: 120px;
  border-radius: 50%;
  background: rgba(255,255,255,0.1);
}

.stat-card .stat-icon {
  width: 52px; height: 52px;
  background: rgba(255,255,255,0.2);
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  font-size: 24px; margin-bottom: 16px;
}

.stat-card .stat-value {
  font-size: 28px; font-weight: 700;
  line-height: 1;
}

.stat-card .stat-label {
  font-size: 13px; opacity: 0.85; margin-top: 4px;
}

.stat-card .stat-change {
  font-size: 12px; opacity: 0.8; margin-top: 6px;
}

.gradient-orange { background: linear-gradient(135deg, #f97316, #ef4444); }
.gradient-blue   { background: linear-gradient(135deg, #3b82f6, #6366f1); }
.gradient-green  { background: linear-gradient(135deg, #10b981, #059669); }
.gradient-purple { background: linear-gradient(135deg, #8b5cf6, #7c3aed); }
.gradient-teal   { background: linear-gradient(135deg, #14b8a6, #0d9488); }
.gradient-pink   { background: linear-gradient(135deg, #ec4899, #db2777); }
.gradient-yellow { background: linear-gradient(135deg, #f59e0b, #d97706); }
.gradient-indigo { background: linear-gradient(135deg, #6366f1, #4f46e5); }

/* Tables */
.table {
  --bs-table-bg: transparent;
  --bs-table-color: var(--text-primary);
  font-size: 14px;
}

.table thead th {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
  border-bottom: 2px solid var(--border-color);
  padding: 10px 12px;
  white-space: nowrap;
}

.table tbody td { padding: 12px; vertical-align: middle; border-color: var(--border-color); }
.table-hover tbody tr:hover { background: rgba(249,115,22,0.04); }

/* Fuel type colors */
.fuel-badge {
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 12px; font-weight: 700;
  white-space: nowrap;
}

/* POS / Sale screen */
.pos-container {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 20px;
  height: calc(100vh - var(--topbar-height) - 48px);
}

.pos-left { display: flex; flex-direction: column; gap: 16px; overflow-y: auto; }
.pos-right {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  display: flex; flex-direction: column;
  overflow: hidden;
}

.pos-basket-header {
  padding: 16px;
  border-bottom: 1px solid var(--border-color);
  font-weight: 700; font-size: 15px;
}

.pos-basket-items { flex: 1; overflow-y: auto; padding: 8px; }

.basket-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px;
  border-radius: 10px;
  border: 1px solid var(--border-color);
  margin-bottom: 8px;
  background: var(--bg-body);
}

.pos-footer { padding: 16px; border-top: 1px solid var(--border-color); }

/* Fuel dispenser grid */
.dispenser-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
}

.dispenser-card {
  border: 2px solid var(--border-color);
  border-radius: 14px;
  padding: 16px;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition);
  background: var(--bg-card);
}

.dispenser-card:hover, .dispenser-card.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(249,115,22,0.15);
}

.dispenser-card .dispenser-icon {
  font-size: 32px; margin-bottom: 8px;
}

.dispenser-card.maintenance { opacity: 0.5; cursor: not-allowed; }

/* Tank gauge */
.tank-gauge {
  position: relative;
  height: 200px;
  border-radius: 12px;
  overflow: hidden;
  background: var(--bg-body);
  border: 2px solid var(--border-color);
}

.tank-fill {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  transition: height 1s ease;
  border-radius: 0 0 10px 10px;
}

.tank-label {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  font-weight: 700; font-size: 18px;
  text-shadow: 0 1px 3px rgba(0,0,0,0.3);
  color: #fff;
}

/* Charts */
.chart-container { position: relative; }

/* Receipt / Thermal */
.receipt-wrapper {
  max-width: 300px;
  margin: 0 auto;
  font-family: 'Courier New', monospace;
  font-size: 12px;
  background: #fff;
  color: #000;
  padding: 16px;
}

.receipt-divider { border-top: 1px dashed #000; margin: 8px 0; }
.receipt-title { text-align: center; font-weight: bold; font-size: 14px; }
.receipt-row { display: flex; justify-content: space-between; }

/* Notification badge */
.notification-dot {
  width: 8px; height: 8px;
  background: #ef4444;
  border-radius: 50%;
  position: absolute;
  top: 6px; right: 6px;
}

/* Mobile responsive */
@media (max-width: 768px) {
  #sidebar {
    transform: translateX(-100%);
  }
  #sidebar.open {
    transform: translateX(0);
  }
  #main-content { margin-left: 0; }
  .pos-container { grid-template-columns: 1fr; height: auto; }
  .page-content { padding: 16px; }
}

/* Dark mode table overrides */
[data-bs-theme="dark"] .table { border-color: var(--border-color); }
[data-bs-theme="dark"] .modal-content { background: var(--bg-card); border-color: var(--border-color); }
[data-bs-theme="dark"] .dropdown-menu { background: var(--bg-card); border-color: var(--border-color); }
[data-bs-theme="dark"] .dropdown-item { color: var(--text-primary); }
[data-bs-theme="dark"] .dropdown-item:hover { background: rgba(255,255,255,0.05); }
[data-bs-theme="dark"] .form-control, [data-bs-theme="dark"] .form-select {
  background: var(--bg-body);
  border-color: var(--border-color);
  color: var(--text-primary);
}
[data-bs-theme="dark"] .input-group-text {
  background: var(--bg-body);
  border-color: var(--border-color);
  color: var(--text-secondary);
}

/* Breadcrumb */
.breadcrumb { font-size: 13px; }
.breadcrumb-item + .breadcrumb-item::before { color: var(--text-secondary); }

/* Custom scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(128,128,128,0.25); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(128,128,128,0.45); }

/* Loader */
.page-loader {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.3);
  display: flex; align-items: center; justify-content: center;
  z-index: 9999;
}

/* Animation */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

.animate-in { animation: fadeInUp 0.35s ease; }

/* Print styles */
@media print {
  #sidebar, #topbar, .no-print { display: none !important; }
  #main-content { margin-left: 0 !important; }
  .page-content { padding: 0; }
}

/* Flatpickr overrides */
.flatpickr-calendar {
  border-radius: 12px !important;
  box-shadow: 0 8px 30px rgba(0,0,0,0.15) !important;
}

/* Status indicators */
.status-dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  margin-right: 6px;
}

.status-dot.online  { background: #10b981; box-shadow: 0 0 0 3px rgba(16,185,129,0.2); }
.status-dot.offline { background: #ef4444; }
.status-dot.warning { background: #f59e0b; }

/* Input group */
.input-group .form-control:focus { z-index: 3; }

/* Number inputs */
input[type="number"] { text-align: right; }

/* Shift status */
.shift-open   { background: #d1fae5; color: #065f46; }
.shift-closed { background: #fee2e2; color: #991b1b; }

[data-bs-theme="dark"] .shift-open   { background: rgba(16,185,129,0.15); color: #34d399; }
[data-bs-theme="dark"] .shift-closed { background: rgba(239,68,68,0.15); color: #f87171; }
