/* ============================================================
   FuelWise - Fuel Management System CRM Template
   Main Stylesheet
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
  /* Police unique comme le template HTML (Inter) */
  --fw-font-sans: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --primary: #e85d24;
  --primary-light: #eef0fe;
  --sidebar-width: 220px;
  --header-height: 64px;
  --bg: #f4f6fb;
  /* Fond carte logo Fueldesk (fueldesk_logo.svg) */
  --brand-surface: #f5f0e8;
  --brand-surface-border: #d4c9b0;
  --brand-surface-hover: rgba(44, 40, 32, 0.08);
  /* Orange logo Fueldesk (icône / texte « FUEL ») */
  --brand-accent: #e85d24;
  --white: #ffffff;
  --text: #1a1d2e;
  --text-muted: #7a7f9a;
  --border: #e8eaf0;
  --success: #22c55e;
  --danger: #ef4444;
  --warning: #f59e0b;
  --radius: 12px;
  --shadow: 0 2px 12px rgba(0,0,0,0.06);
  /* Bootstrap 5 : mêmes polices que le template */
  --bs-font-sans-serif: var(--fw-font-sans);
  --bs-body-font-family: var(--fw-font-sans);
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow-x: hidden;
}

html {
  font-family: var(--fw-font-sans);
}

body {
  font-family: var(--fw-font-sans);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ============================================================
   SCROLLBAR
   ============================================================ */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 10px; }

/* ============================================================
   LAYOUT WRAPPER
   ============================================================ */
.layout {
  display: flex;
  min-height: 100vh;
  width: 100%;
}

/* ============================================================
   SIDEBAR
   ============================================================ */
.sidebar {
  width: var(--sidebar-width);
  background: var(--brand-surface);
  border-right: 1px solid var(--brand-surface-border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  max-height: 100vh;
  z-index: 100;
  overflow: hidden;
  transition: transform 0.3s ease;
}

.sidebar-logo {
  display: flex;
  align-items: stretch;
  gap: 0;
  padding: 10px 10px 12px;
  border-bottom: 1px solid var(--brand-surface-border);
  flex-shrink: 0;
}

.sidebar-brand-link {
  display: block;
  width: 100%;
  line-height: 0;
}

.sidebar-brand-img {
  width: 100%;
  height: auto;
  display: block;
  vertical-align: top;
  object-fit: contain;
  object-position: center center;
}

.logo-icon {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, #ff6a00, #ff9500);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.logo-icon svg { color: white; }

.logo-text {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.3px;
}

.sidebar-nav {
  padding: 16px 0;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.sidebar-context-footer {
  flex-shrink: 0;
  position: relative;
  z-index: 120;
  padding: 12px 14px;
  background: var(--brand-accent);
  color: var(--white);
  font-size: 12px;
  font-weight: 600;
  text-align: center;
  line-height: 1.35;
  letter-spacing: 0.02em;
  border-top: 1px solid rgba(0, 0, 0, 0.08);
  box-shadow: 0 -6px 16px rgba(44, 40, 32, 0.12);
}

.sidebar-context-label {
  display: block;
  word-break: break-word;
  hyphens: auto;
}

.nav-section-title {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  padding: 12px 20px 6px;
}

/*
 * Liens du menu type template (pages HTML statiques).
 * Ne pas utiliser la classe seule `.nav-item` : elle entrerait en conflit avec
 * les `<li class="nav-item">` de Bootstrap dans la sidebar Laravel.
 */
a.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  color: var(--text-muted);
  text-decoration: none;
  border-radius: 0;
  transition: all 0.2s;
  font-size: 13.5px;
  font-weight: 500;
  position: relative;
  margin: 2px 0;
}

a.nav-item:hover {
  background: var(--primary-light);
  color: var(--primary);
}

a.nav-item.active {
  background: var(--primary-light);
  color: var(--primary);
}

a.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 4px;
  bottom: 4px;
  width: 3px;
  background: var(--primary);
  border-radius: 0 3px 3px 0;
}

a.nav-item svg, a.nav-item i {
  width: 18px;
  font-size: 15px;
  flex-shrink: 0;
}

/* ============================================================
   HEADER
   ============================================================ */
.header {
  position: fixed;
  top: 0;
  left: var(--sidebar-width);
  right: 0;
  width: calc(100% - var(--sidebar-width));
  height: var(--header-height);
  background: var(--brand-surface);
  border-bottom: 1px solid var(--brand-surface-border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  z-index: 99;
  box-shadow: var(--shadow);
}

.header-toggle {
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px;
  border-radius: 8px;
  color: var(--text-muted);
  transition: all 0.2s;
}

.header-toggle:hover { background: var(--brand-surface-hover); color: var(--text); }

.search-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 14px;
  flex: 1;
  max-width: 360px;
}

.search-bar input {
  border: none;
  background: none;
  outline: none;
  font-size: 13.5px;
  color: var(--text);
  width: 100%;
}

.search-bar input::placeholder { color: var(--text-muted); }

.search-bar .filter-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  padding: 2px;
  transition: color 0.2s;
}

.search-bar .filter-btn:hover { color: var(--primary); }

.header-spacer { flex: 1; }

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

.header-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
  border-radius: 10px;
  color: var(--text-muted);
  transition: all 0.2s;
  position: relative;
}

.header-btn:hover { background: var(--brand-surface-hover); color: var(--text); }

.header-btn .badge {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 8px;
  height: 8px;
  background: var(--danger);
  border-radius: 50%;
  border: 2px solid var(--brand-surface);
}

.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  overflow: hidden;
  cursor: pointer;
  border: 2px solid var(--border);
}

.avatar img { width: 100%; height: 100%; object-fit: cover; }

.avatar-placeholder {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #e85d24;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
}

/* ============================================================
   MAIN CONTENT
   ============================================================ */
.main {
  flex: 1;
  min-width: 0;
  margin-left: var(--sidebar-width);
  margin-top: var(--header-height);
  padding: 28px;
  min-height: calc(100vh - var(--header-height));
}

/* ============================================================
   PAGE HEADER
   ============================================================ */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.page-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
}

.page-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ============================================================
   FUEL PRICE CARDS
   ============================================================ */
.fuel-cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 20px;
}

.fuel-card {
  border-radius: var(--radius);
  padding: 20px;
  color: white;
  position: relative;
  overflow: hidden;
  min-height: 120px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

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

.fuel-card::after {
  content: '';
  position: absolute;
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: rgba(255,255,255,0.08);
  top: 20px;
  right: 50px;
}

.fuel-card-petrol { background: linear-gradient(135deg, #1a56db, #2563eb, #3b82f6); }
.fuel-card-gas { background: linear-gradient(135deg, #6d28d9, #7c3aed, #8b5cf6); }
.fuel-card-kerosene { background: linear-gradient(135deg, #0891b2, #06b6d4, #22d3ee); }
.fuel-card-diesel { background: linear-gradient(135deg, #059669, #10b981, #34d399); }

.fuel-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  position: relative;
  z-index: 1;
}

.fuel-card-icon {
  width: 38px;
  height: 38px;
  background: rgba(255,255,255,0.2);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}

.fuel-card-more {
  background: none;
  border: none;
  color: rgba(255,255,255,0.7);
  cursor: pointer;
  font-size: 16px;
  padding: 2px;
  letter-spacing: 2px;
}

.fuel-card-body { position: relative; z-index: 1; }

.fuel-price {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.fuel-price-badge {
  display: flex;
  align-items: center;
  gap: 3px;
  font-size: 11px;
  font-weight: 600;
  background: rgba(255,255,255,0.2);
  padding: 2px 7px;
  border-radius: 20px;
}

.fuel-name {
  font-size: 13px;
  font-weight: 500;
  opacity: 0.85;
  margin-top: 3px;
}

/* ADD PRICE BUTTON */
.add-price-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #1a56db;
  color: white;
  border: none;
  border-radius: 8px;
  padding: 10px 20px;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  margin-bottom: 24px;
}

.add-price-btn:hover { background: #1d4ed8; transform: translateY(-1px); box-shadow: 0 4px 12px rgba(26, 86, 219, 0.3); }

/* ============================================================
   DASHBOARD GRID
   ============================================================ */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 20px;
  align-items: start;
}

/* ============================================================
   CARDS
   ============================================================ */
.card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

/* En-têtes de cartes : même style que le bloc « Filtres » (fuel-deliveries / daily-receipts) */
.card > .card-header,
.table-card > .card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  /* Équivalent Bootstrap py-3 + padding horizontal (bloc Filtres) */
  padding: 1rem 1rem;
}

.card > .card-header:not([class*="bg-"]),
.table-card > .card-header:not([class*="bg-"]) {
  border-bottom: 1px solid var(--border);
}

.card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0;
}

/* Titres (h1–h6) dans les en-têtes : taille unique type « Filtres » */
.card > .card-header h1,
.card > .card-header h2,
.card > .card-header h3,
.card > .card-header h4,
.card > .card-header h5,
.card > .card-header h6,
.table-card > .card-header h1,
.table-card > .card-header h2,
.table-card > .card-header h3,
.table-card > .card-header h4,
.table-card > .card-header h5,
.table-card > .card-header h6 {
  margin-bottom: 0;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.35;
  color: var(--text);
}

.card > .card-header[class*="bg-"] .card-title,
.card > .card-header[class*="bg-"] h1,
.card > .card-header[class*="bg-"] h2,
.card > .card-header[class*="bg-"] h3,
.card > .card-header[class*="bg-"] h4,
.card > .card-header[class*="bg-"] h5,
.card > .card-header[class*="bg-"] h6,
.table-card > .card-header[class*="bg-"] .card-title,
.table-card > .card-header[class*="bg-"] h1,
.table-card > .card-header[class*="bg-"] h2,
.table-card > .card-header[class*="bg-"] h3,
.table-card > .card-header[class*="bg-"] h4,
.table-card > .card-header[class*="bg-"] h5,
.table-card > .card-header[class*="bg-"] h6 {
  color: inherit;
}

.card-subtitle {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  margin-top: 2px;
}

.card-body { padding: 16px 20px 20px; }

.card-actions { display: flex; align-items: center; gap: 8px; }

/* ============================================================
   PERIOD SELECT
   ============================================================ */
.period-select {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--white);
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  outline: none;
}

/* ============================================================
   CHART CONTAINER
   ============================================================ */
.chart-container {
  position: relative;
  padding: 0 20px 20px;
}

.chart-wrapper { height: 240px; }

/* ============================================================
   PUMP REPORT
   ============================================================ */
.pump-report-chart { padding: 8px 20px 0; }
.pump-report-chart canvas { height: 100px !important; }

.pump-list { padding: 8px 20px 16px; }

.pump-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.pump-item:last-child { border-bottom: none; }

.pump-name { font-size: 13.5px; font-weight: 600; color: var(--text); }

.pump-status {
  font-size: 11px;
  font-weight: 500;
  margin-top: 2px;
}

.pump-status.profit { color: var(--success); }
.pump-status.loss { color: var(--danger); }

.pump-amount {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.pump-trend {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  margin-left: 8px;
}

.pump-trend.up { background: #dcfce7; color: var(--success); }
.pump-trend.down { background: #fee2e2; color: var(--danger); }

.pump-right { display: flex; align-items: center; }

/* ============================================================
   STATS CARDS ROW
   ============================================================ */
.stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 20px;
}

.stat-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 18px 20px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.stat-label { font-size: 12px; color: var(--text-muted); font-weight: 500; margin-bottom: 8px; }
.stat-value { font-size: 22px; font-weight: 700; color: var(--text); }
.stat-change { display: flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 500; margin-top: 6px; }
.stat-change.up { color: var(--success); }
.stat-change.down { color: var(--danger); }
.stat-icon-box {
  width: 40px; height: 40px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
  margin-bottom: 12px;
}

/* ============================================================
   TABLE (style compact — séparateurs horizontaux uniquement)
   ============================================================ */
.table-card { background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid var(--border); overflow: hidden; }

table {
  width: 100%;
  border-collapse: collapse;
  border-spacing: 0;
}

thead th {
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  padding: 4px 10px;
  line-height: 1.25;
  background: #f8f9fa;
  border-bottom: 1px solid var(--border);
  border-left: none;
  border-right: none;
  vertical-align: middle;
}

tbody tr {
  transition: background 0.15s;
  border-bottom: 1px solid var(--border);
  background: var(--white);
}

tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--bg); }

tbody td {
  padding: 4px 10px;
  font-size: 12.5px;
  line-height: 1.3;
  color: var(--text);
  border-left: none;
  border-right: none;
  vertical-align: middle;
}

.badge-status {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
}

.badge-success { background: #dcfce7; color: #16a34a; }
.badge-warning { background: #fef9c3; color: #ca8a04; }
.badge-danger  { background: #fee2e2; color: #dc2626; }
.badge-info    { background: #dbeafe; color: #2563eb; }

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  /*padding: 9px 18px;*/
  border-radius: 8px;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  border: none;
  text-decoration: none;
}

.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: #3b55d4; box-shadow: 0 4px 12px rgba(79,106,245,0.3); }

.btn-outline { background: none; border: 1.5px solid var(--border); color: var(--text-muted); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-light); }

.btn-danger { background: var(--danger); color: white; }
.btn-success { background: var(--success); color: white; }
.btn-sm { padding: 6px 13px; font-size: 12px; }

/* ============================================================
   FORM ELEMENTS
   ============================================================ */
.form-group { margin-bottom: 18px; }

label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}

.form-control {
  width: 100%;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 13.5px;
  color: var(--text);
  background: var(--white);
  outline: none;
  transition: border-color 0.2s;
  font-family: inherit;
}

.form-control:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79,106,245,0.1); }

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

select.form-control { cursor: pointer; }

/* ============================================================
   MODAL
   ============================================================ */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(3px);
}

.modal-overlay.active { display: flex; }

.modal {
  background: var(--white);
  border-radius: 16px;
  padding: 28px;
  width: 100%;
  max-width: 480px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.15);
  animation: slideUp 0.25s ease;
}

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

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

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

.modal-close {
  background: var(--bg);
  border: none;
  width: 32px; height: 32px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 16px;
  color: var(--text-muted);
  display: flex; align-items: center; justify-content: center;
  transition: all 0.2s;
}

.modal-close:hover { background: var(--border); color: var(--text); }

.modal-footer { display: flex; gap: 10px; justify-content: flex-end; margin-top: 24px; }

/* ============================================================
   SIDEBAR SETTINGS FAB
   ============================================================ */
.settings-fab {
  position: fixed;
  right: 24px;
  bottom: 24px;
  width: 48px; height: 48px;
  background: linear-gradient(135deg, #6d28d9, #7c3aed);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: white;
  font-size: 20px;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(109,40,217,0.4);
  border: none;
  transition: transform 0.2s;
  z-index: 200;
}

.settings-fab:hover { transform: rotate(30deg); }

/* ============================================================
   EMPTY STATE
   ============================================================ */
.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-muted);
}

.empty-state i { font-size: 48px; margin-bottom: 12px; opacity: 0.3; }
.empty-state p { font-size: 14px; }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 1100px) {
  .dashboard-grid { grid-template-columns: 1fr; }
  .fuel-cards { grid-template-columns: repeat(2, 1fr); }
  .stats-row { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .header { left: 0; width: 100%; }
  .main { margin-left: 0; width: 100%; padding: 16px; }
  .fuel-cards { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 500px) {
  .fuel-cards { grid-template-columns: 1fr; }
  .stats-row { grid-template-columns: 1fr; }
}

/* ============================================================
   UTILITIES
   ============================================================ */
.d-flex { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.mt-4 { margin-top: 4px; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 12px; }
.fw-600 { font-weight: 600; }
.text-success { color: var(--success); }
.text-danger  { color: var(--danger); }
.w-100 { width: 100%; }
