/**
 * SONABEL Incident Collector - Feuille de styles principale
 * Couleurs officielles SONABEL : Vert (#008751), Jaune/Or (#FCD116), Rouge (#EF2B2D), Marine (#0F233A)
 */

:root {
  --sonabel-green: #008751;
  --sonabel-green-dark: #00663d;
  --sonabel-green-light: #e8f5ee;
  --sonabel-yellow: #fcd116;
  --sonabel-yellow-dark: #d4ac0d;
  --sonabel-yellow-light: #fef9e7;
  --sonabel-red: #ef2b2d;
  --sonabel-navy: #0f233a;
  --sonabel-navy-light: #1b3b5f;
  
  --bg-main: #f8fafc;
  --bg-card: #ffffff;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --border-color: #e2e8f0;
  --border-focus: #008751;
  
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-full: 9999px;

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.04);
}

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

body {
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background-color: var(--bg-main);
  color: var(--text-main);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* --- HEADER & NAVIGATION PRINCIPALE --- */
.header-top {
  background: linear-gradient(135deg, var(--sonabel-navy) 0%, #17385c 100%);
  color: #ffffff;
  padding: 12px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 3px solid var(--sonabel-green);
  box-shadow: var(--shadow-md);
  position: sticky;
  top: 0;
  z-index: 50;
}

.brand-wrapper {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-logo-badge {
  background: var(--sonabel-green);
  color: var(--sonabel-yellow);
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  font-size: 20px;
  border: 2px solid var(--sonabel-yellow);
  box-shadow: 0 2px 8px rgba(0, 135, 81, 0.4);
}

.brand-text h1 {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 0.5px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand-text h1 span.tag-stage {
  background: var(--sonabel-yellow);
  color: #1e293b;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-weight: 700;
  letter-spacing: 0.2px;
}

.brand-text p {
  font-size: 11px;
  color: #94a3b8;
  font-weight: 500;
}

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

.btn-header {
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.2);
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-header:hover {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.4);
}

.btn-header.btn-lock {
  border-color: #f87171;
  color: #fca5a5;
}
.btn-header.btn-lock:hover {
  background: rgba(239, 43, 45, 0.2);
  color: #fee2e2;
}

/* Barre de navigation des onglets */
.nav-tabs-bar {
  background: #ffffff;
  border-bottom: 1px solid var(--border-color);
  padding: 0 24px;
  display: flex;
  gap: 8px;
  overflow-x: auto;
  box-shadow: var(--shadow-sm);
}

.nav-tab-btn {
  background: transparent;
  border: none;
  border-bottom: 3px solid transparent;
  padding: 14px 16px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s ease;
}

.nav-tab-btn:hover {
  color: var(--sonabel-green);
  background: #f8fafc;
}

.nav-tab-btn.active {
  color: var(--sonabel-green);
  border-bottom-color: var(--sonabel-green);
  background: transparent;
}

.nav-tab-btn .badge-pill {
  background: #e2e8f0;
  color: #475569;
  font-size: 11px;
  padding: 1px 7px;
  border-radius: var(--radius-full);
}

.nav-tab-btn.active .badge-pill {
  background: var(--sonabel-green-light);
  color: var(--sonabel-green);
}

/* --- CONTENEUR PRINCIPAL --- */
.main-content {
  flex: 1;
  padding: 24px;
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
}

.tab-pane {
  display: none;
}
.tab-pane.active {
  display: block;
  animation: fadeIn 0.25s ease-in-out;
}

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

/* --- CARTES ET BLOCS --- */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 20px;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-color);
}

.card-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Grille des KPI Stat Cards */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.kpi-card {
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 18px;
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  gap: 16px;
  transition: transform 0.2s, box-shadow 0.2s;
}

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

.kpi-icon-wrap {
  width: 50px;
  height: 50px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}

.kpi-info .kpi-label {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.kpi-info .kpi-val {
  font-size: 26px;
  font-weight: 800;
  color: var(--text-main);
  line-height: 1.2;
}

.kpi-info .kpi-sub {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Grilles pour graphiques */
.charts-grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(420px, 1fr));
  gap: 20px;
  margin-bottom: 24px;
}

.chart-container {
  position: relative;
  height: 280px;
  width: 100%;
}

/* --- BARRE DE RECHERCHE ET FILTRES --- */
.filters-bar {
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 20px;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
}

.search-input-wrap {
  flex: 1;
  min-width: 250px;
  position: relative;
}

.search-input-wrap input {
  width: 100%;
  padding: 9px 12px 9px 36px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
}

.search-input-wrap input:focus {
  border-color: var(--sonabel-green);
  box-shadow: 0 0 0 3px rgba(0, 135, 81, 0.1);
}

.search-icon-svg {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  color: #94a3b8;
  pointer-events: none;
}

.filter-select {
  padding: 9px 12px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: inherit;
  background: #ffffff;
  color: var(--text-main);
  outline: none;
  cursor: pointer;
}

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

/* --- BOUTONS --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 16px;
  font-size: 13px;
  font-weight: 600;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
}

.btn-primary {
  background: var(--sonabel-green);
  color: #ffffff;
}
.btn-primary:hover {
  background: var(--sonabel-green-dark);
}

.btn-secondary {
  background: #f1f5f9;
  color: #334155;
  border-color: #cbd5e1;
}
.btn-secondary:hover {
  background: #e2e8f0;
}

.btn-yellow {
  background: var(--sonabel-yellow);
  color: #1e293b;
}
.btn-yellow:hover {
  background: var(--sonabel-yellow-dark);
}

.btn-danger {
  background: #ef4444;
  color: #ffffff;
}
.btn-danger:hover {
  background: #dc2626;
}

.btn-sm {
  padding: 5px 10px;
  font-size: 12px;
}

.btn-icon-only {
  padding: 6px;
  border-radius: var(--radius-sm);
  line-height: 1;
}

/* --- TABLEAU DES INCIDENTS --- */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: #ffffff;
}

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

table.data-table th {
  background: #f8fafc;
  color: #475569;
  font-weight: 700;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
}

table.data-table td {
  padding: 12px 14px;
  border-bottom: 1px solid #f1f5f9;
  color: #334155;
  vertical-align: middle;
}

table.data-table tr:hover td {
  background-color: #f8fafc;
}

.incident-ref-badge {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 700;
  color: var(--sonabel-navy);
  background: #f1f5f9;
  padding: 3px 7px;
  border-radius: 4px;
  font-size: 12px;
  display: inline-block;
}

/* Badges de statut */
.badge-status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.badge-status.badge-success {
  background: #d1fae5;
  color: #065f46;
  border: 1px solid #a7f3d0;
}

.badge-status.badge-warning {
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #fde68a;
}

.badge-status.badge-danger {
  background: #fee2e2;
  color: #991b1b;
  border: 1px solid #fecaca;
}

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

/* Badges de catégorie */
.badge-category {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
}

/* Actions de ligne */
.table-actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
}

/* --- FORMULAIRE D'INCIDENT --- */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}

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

.form-group.col-span-full {
  grid-column: 1 / -1;
}

.form-label {
  font-size: 12px;
  font-weight: 700;
  color: #334155;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.form-label span.required {
  color: #ef4444;
}

.form-control {
  padding: 9px 12px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: inherit;
  outline: none;
  background: #ffffff;
  color: var(--text-main);
  transition: all 0.2s;
}

.form-control:focus {
  border-color: var(--sonabel-green);
  box-shadow: 0 0 0 3px rgba(0, 135, 81, 0.1);
}

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

.form-hint {
  font-size: 11px;
  color: var(--text-muted);
}

/* --- MODALES --- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
  animation: modalFadeIn 0.2s ease;
}

.modal-backdrop.open {
  display: flex;
}

@keyframes modalFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-dialog {
  background: #ffffff;
  border-radius: var(--radius-lg);
  max-width: 750px;
  width: 100%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.15);
  overflow: hidden;
}

.modal-header {
  padding: 16px 22px;
  background: #f8fafc;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-title {
  font-size: 16px;
  font-weight: 800;
  color: var(--sonabel-navy);
}

.modal-close-btn {
  background: transparent;
  border: none;
  font-size: 20px;
  color: #94a3b8;
  cursor: pointer;
  padding: 4px;
}
.modal-close-btn:hover {
  color: #0f172a;
}

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

.modal-footer {
  padding: 14px 22px;
  background: #f8fafc;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* Écran de verrouillage / Authentification */
.lock-screen-modal {
  position: fixed;
  inset: 0;
  background: linear-gradient(135deg, var(--sonabel-navy) 0%, #061526 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 20px;
}

.lock-box {
  background: #ffffff;
  border-radius: var(--radius-lg);
  padding: 36px;
  max-width: 420px;
  width: 100%;
  text-align: center;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

.lock-logo {
  width: 60px;
  height: 60px;
  background: var(--sonabel-green);
  color: var(--sonabel-yellow);
  border-radius: var(--radius-md);
  margin: 0 auto 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  font-weight: 900;
  border: 3px solid var(--sonabel-yellow);
}

.lock-title {
  font-size: 18px;
  font-weight: 800;
  color: var(--sonabel-navy);
  margin-bottom: 6px;
}

.lock-subtitle {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 24px;
}

/* --- TOAST NOTIFICATIONS --- */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 150;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast {
  background: #ffffff;
  border-left: 4px solid var(--sonabel-green);
  border-radius: var(--radius-sm);
  padding: 12px 18px;
  box-shadow: var(--shadow-lg);
  font-size: 13px;
  font-weight: 600;
  color: #1e293b;
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 280px;
  animation: slideInRight 0.3s ease;
}

.toast.toast-error {
  border-left-color: #ef4444;
}

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

/* --- VUE ANALYTIQUE BTS --- */
.bts-banner {
  background: linear-gradient(135deg, #008751 0%, #00663d 100%);
  color: #ffffff;
  border-radius: var(--radius-md);
  padding: 24px;
  margin-bottom: 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  box-shadow: var(--shadow-md);
}

.bts-banner h2 {
  font-size: 20px;
  font-weight: 800;
  margin-bottom: 6px;
}

.bts-banner p {
  font-size: 13px;
  color: #e2e8f0;
  max-width: 750px;
}

.bts-stat-table th {
  background: #f1f5f9;
}

/* --- MEDIA PRINT (IMPRESSION PDF) --- */
@media print {
  .header-top, .nav-tabs-bar, .filters-bar, .btn-header, .table-actions, .toast-container {
    display: none !important;
  }
  body, .main-content {
    background: #ffffff !important;
    padding: 0 !important;
  }
  .card {
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
  }
}

/* Responsive mobiles & tablettes */
@media (max-width: 768px) {
  .header-top {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }
  .header-actions {
    width: 100%;
    justify-content: space-between;
  }
  .charts-grid-2 {
    grid-template-columns: 1fr;
  }
  .filters-bar {
    flex-direction: column;
    align-items: stretch;
  }
  .bts-banner {
    flex-direction: column;
    align-items: flex-start;
  }
}

