/* Style pour TB GOF, identique à DI Corrective */
:root{
  --bg:#020617;        /* fond principal */
  --fg:#e2e8f0;        /* slate-200 */
  --muted:#94a3b8;     /* slate-400 */
  --acc:#22c55e;       /* green-500 */
  --accent:#2d77ff;    /* Bleu pour les éléments auth */
  --danger:#ef4444;    /* red-500 */
  --card:#020617;      /* navbar */
  --border:#1f2937;    /* gray-800 */
  --thead:#143453;     /* vert foncé (entête) */
}

*{ box-sizing: border-box; }
body{
  margin:0;
  background:var(--bg);
  color:var(--fg);
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell, Noto Sans, Arial, "Apple Color Emoji", "Segoe UI Emoji";
  line-height:1.45;
}

button{
  background:#020617; color:var(--fg); border:1px solid #2a394a; border-radius:12px;
  padding:.5rem .8rem; cursor:pointer; transition:transform .05s ease, background .2s, opacity .2s, box-shadow .2s;
  font-size: 1rem;
}
button:hover{ background:#1e2b3b; border-color: #3c5068; }
button:active{ transform:scale(.98) }
button:disabled{ opacity:.45; cursor:not-allowed }

.navbar{
  display:flex; align-items:center; justify-content:space-between;
  padding:8px 16px; border-bottom:1px solid var(--border); background:var(--card);
}
.brand{ font-weight:700; }
.tabs{ display:flex; gap:8px; }
.nav-btn{
  color:var(--fg); text-decoration:none; padding:8px 10px; border:1px solid var(--border); border-radius:10px;
}
.nav-btn.active{ background:#4c1d95; border-color:#5b21b6; }

main{ padding:16px; }
.section-head{ display:flex; align-items:center; justify-content:space-between; gap:12px; flex-wrap:wrap; }
.actions{ display:flex; gap:8px; }

/* ===== Toolbars / recherches ===== */
.toolbar{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  flex-wrap: wrap;
  margin:8px 0 12px;
}
.search-row{
  display:flex; align-items:center; gap:12px; flex-wrap:wrap;
}
.search{
  display:flex; gap:6px; align-items:center;
}
.search input[type="search"]{
  min-width: 320px;
  padding:8px 10px;
  border:1px solid var(--border);
  border-radius:10px;
  background:#020617; color:var(--fg);
}
.search-secondary input[type="search"]{
  min-width: 280px;
}
#search-clear, #search2-clear{
  padding:8px 10px; border-radius:8px; border:1px solid var(--border); background:#020617; color:#fca5a5; cursor:pointer;
}
#search-clear:hover, #search2-clear:hover{ background:#020617; }
#search-info{ flex:1 1 240px; text-align:right; }

.muted{ color:var(--muted); font-size:13px; }

/* ===== Pagination ===== */
.pager{
  display:flex; gap:8px; align-items:center; flex-wrap:wrap;
  margin-bottom: 8px;
}
.pager .btn,
.pager button{
  padding:6px 10px; border-radius:8px; border:1px solid var(--border); background:#020617; color:var(--fg); cursor:pointer;
}
.pager .btn:hover,
.pager button:hover{ background:#020617; }
.pager input[type="number"]{
  width:72px; padding:6px 8px; border:1px solid var(--border); border-radius:8px; background:#020617; color: var(--fg);
}
.pager select{
  padding:6px 8px; border:1px solid var(--border); border-radius:8px; background:#020617; color:var(--fg);
}

/* === Grille + scroll horizontal natif === */
.grid-wrapper{
  overflow: auto;               /* barres de scroll natives conservées */
  border:1px solid var(--border);
  border-radius:12px;
  background: #020617;
  max-height: calc(100vh - 200px); /* Hauteur maximale pour garder les en-têtes visibles */
}

/* Style de l'ascenseur vertical (vert comme l'horizontal) */
.grid-wrapper::-webkit-scrollbar {
  width: 14px;
  height: 14px;
}
.grid-wrapper::-webkit-scrollbar-track {
  background: transparent;
  border-radius: 12px;
  border: 1px solid transparent;
  transition: background 0.3s ease, border-color 0.3s ease;
}
.grid-wrapper::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, #a855f7, rgba(168,85,247,.9));
  border-radius: 10px;
  transition: background 0.3s ease, box-shadow 0.3s ease, opacity 0.3s ease;
  opacity: 0;
  box-shadow: 0 1px 0 rgba(255,255,255,.15), 0 6px 16px rgba(0,0,0,.45);
}
/* Afficher l'ascenseur complètement au survol du tableau */
.grid-wrapper:hover::-webkit-scrollbar-track {
  background: linear-gradient(180deg, rgba(17,24,39,.8), rgba(2,6,23,.75));
  border: 1px solid rgba(148,163,184,.35);
}
.grid-wrapper:hover::-webkit-scrollbar-thumb {
  opacity: 1;
}
/* Survol direct du thumb - violet plus intense */
.grid-wrapper::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, #9333ea, #7e22ce) !important;
  box-shadow: 0 1px 0 rgba(255,255,255,.2), 0 8px 22px rgba(0,0,0,.55) !important;
}
/* Clic/Active - reste violet */
.grid-wrapper::-webkit-scrollbar-thumb:active {
  background: linear-gradient(180deg, #9333ea, #7e22ce) !important;
  box-shadow: 0 0 0 3px rgba(168,85,247,.25), 0 10px 28px rgba(0,0,0,.6) !important;
}
.grid-wrapper::-webkit-scrollbar-corner {
  background: rgba(17,24,39,.8);
}
.grid-scroller{
  display: inline-block;        /* s'élargit à la taille du contenu du tableau */
  min-width: 100%;
}
.grid{
  width: auto;                  /* largeur selon contenu */
  min-width: 100%;
  border-collapse: collapse;
  font-size:14px;
  table-layout: auto;
}
#table-gof{ width: auto; min-width: 100%; }

/* Entête */
.grid thead tr:nth-child(1) th{
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--thead);
  text-align:left;
  padding:8px 10px;
  border-bottom:1px solid var(--border);
  font-weight:700;
  white-space: nowrap;
}

/* (si une 2e ligne d'entête est ajoutée un jour) */
.grid thead tr:nth-child(2) th{
  position: sticky;
  top: 36px;
  z-index: 1;
  background: #123f24;
  border-bottom:1px solid var(--border);
  padding:6px 10px;
}
.col-filter{
  width: 200px;
  max-width: 40vw;
  padding:6px 8px;
  border:1px solid var(--border);
  border-radius:8px;
  background:#020617; color:var(--fg);
}
.col-filter::placeholder{ color:#64748b; }

/* Cellules */
.grid td{
  padding:8px 10px;
  border-bottom:1px solid #d0d0d0;
  white-space: nowrap;
  overflow: visible;
  text-overflow: clip;
  word-break: normal;
  overflow-wrap: normal;
  color: #000;
}

.grid tbody tr:nth-child(odd)  td { background: #f2f2f2; }
.grid tbody tr:nth-child(even) td { background: #ffffff; }
.grid tbody tr:hover td { background: #e8e8e8; }

/* ===== Tri : label + icône (SVG) ===== */
.th-sort-hit{
  display:inline-flex;
  align-items:center;
  gap:6px;
  cursor:pointer;
  user-select:none;
  background:transparent;
  border:0;
  padding:0;
  color:var(--fg);
}
.th-sort-hit:focus{ outline:2px solid #334155; outline-offset:2px; }
.th-label{ display:inline-block; }
.th-icon-wrap{ display:inline-flex; align-items:center; }
.sort-icon{
  width:14px; height:14px;
  fill: currentColor;
  opacity:.6;
  transition: opacity .15s ease, color .15s ease, transform .15s ease;
}
.th-sort-hit:hover .sort-icon{ opacity:.9; }

/* Icône rouge sur colonnes triées (asc/desc) */
.grid thead th[aria-sort="ascending"] .sort-icon,
.grid thead th[aria-sort="descending"] .sort-icon{
  color: var(--danger);
  opacity: 1;
}

/* ===== Ascenseur horizontal flottant (overlay) ===== */
#hscroll-overlay{
  position: fixed;
  left: 16px;                 /* réajusté dynamiquement en JS pour coller au tableau */
  right: 16px;
  bottom: 16px;
  z-index: 60;
  opacity: 0;
  pointer-events: none;       /* inactif tant qu'il est masqué */
  transition: opacity .18s ease;
}
#hscroll-overlay.visible{
  opacity: 1;
  pointer-events: auto;
}
.hscroll-track{
  position: relative;
  height: 20px;
  border-radius: 12px;
  border: 1px solid rgba(148,163,184,.35);              /* slate-400 */
  background:
    linear-gradient(180deg, rgba(17,24,39,.8), rgba(2,6,23,.75)); /* glass/dark */
  box-shadow:
    0 2px 10px rgba(0,0,0,.35),
    inset 0 1px 0 rgba(255,255,255,.06);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  overflow: hidden;
}
.hscroll-thumb{
  position: absolute;
  top: 2px;
  left: 0;
  height: 16px;
  min-width: 40px;
  border-radius: 10px;
  background: linear-gradient(180deg, rgba(168,85,247,.95), rgba(168,85,247,.75)); /* --acc */
  box-shadow:
    0 1px 0 rgba(255,255,255,.15),
    0 6px 16px rgba(0,0,0,.45);
  transition: background .12s ease, box-shadow .12s ease, transform .06s linear;
}
#hscroll-overlay:hover .hscroll-thumb{
  box-shadow:
    0 1px 0 rgba(255,255,255,.2),
    0 8px 22px rgba(0,0,0,.55);
}
#hscroll-overlay.dragging .hscroll-thumb{
  background: linear-gradient(180deg, #9333ea, #7e22ce); /* violet foncé */
  box-shadow:
    0 0 0 3px rgba(168,85,247,.25),
    0 10px 28px rgba(0,0,0,.6);
}

/* Divers */
.file-btn{
  display:inline-flex; gap:8px; align-items:center; cursor:pointer;
  padding:10px 14px; background:#083b23; border:1px solid #134e4a; border-radius:10px; font-weight:600;
}
.file-btn input{ display:none; }
.danger{
  padding:10px 14px; border-radius:10px; border:1px solid #7f1d1d; background:#3f1d1d; color:#fecaca; cursor:pointer;
}
.danger:hover{ background:#4a1f1f; }

/* ===== Styles pour l'authentification ===== */

/* Boîte de dialogue modale */
.modal-dialog {
  position: fixed;
  top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 3000;
}

.modal-content {
  background: #020617;
  border: 1px solid #2a394a;
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0,0,0,.5);
  padding: 1.5rem;
  width: 100%;
  max-width: 800px;
  position: relative;
}

.flotte-list-content {
  width: 98%;
  max-width: 1800px;
  height: 85vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-content h2 {
  margin: 0 0 1.5rem 0;
  color: var(--fg);
  font-size: 1.5rem;
}

.flotte-list-content h2 {
  margin: 0.5rem 0 1.5rem 0;
}

.modal-close-btn {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: transparent;
  border: none;
  font-size: 1.5rem;
  color: var(--muted);
  cursor: pointer;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  transition: background 0.2s, color 0.2s;
}

.modal-close-btn:hover {
  background: rgba(255,255,255,0.1);
  color: var(--fg);
}

.modal-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
  margin-top: 1.5rem;
}

.modal-actions button {
  padding: 0.75rem 1.5rem;
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  border: 1px solid transparent;
}

/* Boutons icône pour l'authentification */
.icon-btn{
  width:38px; height:38px; display:inline-grid; place-items:center;
  border-radius:12px; padding:0; border:1px solid var(--border); background:transparent; color:var(--fg); cursor:pointer;
}

.auth-btn {
  position: relative;
}

.auth-btn.logged-in {
  background: linear-gradient(135deg, #2d77ff, #1e5ecc);
  border-color: #1e5ecc;
  color: white;
  /* Adapter la largeur au contenu quand un utilisateur est connecté */
  width: auto;
  min-width: 38px;
  height: 38px;
  padding: 0 12px;
  gap: 8px;
  white-space: nowrap;
  font-size: 1rem;
  /* Utiliser flexbox pour un meilleur alignement de l'icône et du texte */
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.auth-btn.logged-in i {
  /* Ajuster légèrement l'icône pour qu'elle soit bien centrée verticalement */
  margin-top: 1px;
}

.auth-btn.logged-in:hover {
  background: linear-gradient(135deg, #1e5ecc, #1650b3);
}/* Overlay pour les dialogues */
.dialog-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  z-index: 9998;
  backdrop-filter: blur(4px);
}

/* Dialogues d'authentification - doivent être au-dessus de l'overlay */
#login-dialog,
#user-management-dialog {
  z-index: 9999 !important;
}

/* Boîte de dialogue de connexion */
.login-content {
  max-width: 400px;
  width: 90%;
}

.form-group {
  margin-bottom: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.form-group label {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--muted);
}

.form-group input,
.form-group select {
  padding: 0.75rem;
  border: 1px solid #2a394a;
  border-radius: 8px;
  background: #020617;
  color: var(--fg);
  font-size: 1rem;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(45, 119, 255, 0.1);
}

.error-message {
  background: rgba(220, 53, 69, 0.1);
  border: 1px solid rgba(220, 53, 69, 0.3);
  color: #ff6b6b;
  padding: 0.75rem;
  border-radius: 8px;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

.btn-primary {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
  font-weight: 600;
}

.btn-primary:hover {
  background: #1e5ecc;
  border-color: #1e5ecc;
}

.btn-secondary {
  background: #2a394a;
  color: var(--fg);
  border-color: #3c5068;
}

.btn-secondary:hover {
  background: #3c5068;
}

/* Boîte de dialogue de gestion des utilisateurs */
.users-table-wrapper {
  margin: 1rem 0;
  max-height: 400px;
  overflow-y: auto;
  border: 1px solid #2a394a;
  border-radius: 8px;
  background: #020617;
}

.users-table {
  width: 100%;
  border-collapse: separate !important;
  border-spacing: 0 !important;
  color: var(--fg);
  background: transparent !important;
  border: none !important;
}

.users-table thead {
  position: sticky;
  top: 0;
  background: #020617 !important;
  z-index: 10;
}

.users-table thead tr {
  background: #020617 !important;
  border: none !important;
}

.users-table th {
  padding: 0.75rem;
  text-align: left;
  font-weight: 600;
  border: none !important;
  border-bottom: 2px solid #2a394a !important;
  font-size: 0.9rem;
  color: var(--muted);
  background: #020617 !important;
}

.users-table tbody {
  background: transparent !important;
}

.users-table tbody tr {
  background: transparent !important;
  border: none !important;
}

.users-table td {
  padding: 0.75rem;
  border: none !important;
  border-bottom: 1px solid #1b2530 !important;
  background: transparent !important;
}

.users-table tr:hover {
  background: rgba(45, 119, 255, 0.05) !important;
}

.users-table input,
.users-table select {
  width: 100%;
  padding: 0.5rem;
  border: 1px solid #2a394a;
  border-radius: 6px;
  background: #020617;
  color: var(--fg);
  font-size: 0.9rem;
}

.users-table input:focus,
.users-table select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(45, 119, 255, 0.1);
}

.change-password-btn,
.delete-user-btn {
  padding: 0.4rem 0.75rem;
  font-size: 0.85rem;
  border-radius: 6px;
}

.delete-user-btn {
  background: rgba(220, 53, 69, 0.1);
  border-color: rgba(220, 53, 69, 0.3);
  color: #ff6b6b;
}

.delete-user-btn:hover {
  background: rgba(220, 53, 69, 0.2);
}

.user-role {
  cursor: pointer;
}

/* Section d'ajout d'utilisateur */
.add-user-section {
  margin-top: 2rem;
  padding: 1.5rem;
  background: #020617;
  border: 1px solid #2a394a;
  border-radius: 8px;
}

.add-user-section h3 {
  margin-top: 0;
  margin-bottom: 1rem;
  color: var(--fg);
  font-size: 1.1rem;
}

.form-row {
  display: flex;
  gap: 1rem;
  align-items: flex-end;
  flex-wrap: wrap;
}

.form-row .form-group {
  flex: 1;
  min-width: 150px;
}

.form-row button {
  height: fit-content;
  padding: 0.75rem 1.5rem;
}

/* Indicateur de mode lecture seule dans la toolbar */
.readonly-indicator-inline {
  background: rgba(255, 152, 0, 0.2);
  border: 1px solid rgba(255, 152, 0, 0.5);
  color: #ffa726;
  padding: 0.5rem 1rem;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  white-space: nowrap;
}

/* Notification temporaire */
.auth-notification {
  position: fixed;
  top: 80px;
  right: 20px;
  padding: 1rem 1.5rem;
  border-radius: 8px;
  font-weight: 600;
  z-index: 10000;
  opacity: 0;
  transform: translateY(-20px);
  transition: opacity 0.3s, transform 0.3s;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  /* Empêcher les interactions quand invisible */
  pointer-events: none;
}

.auth-notification.show {
  opacity: 1;
  transform: translateY(0);
  /* Permettre les interactions quand visible */
  pointer-events: auto;
}

.auth-notification.success {
  background: rgba(76, 175, 80, 0.2);
  border: 1px solid rgba(76, 175, 80, 0.4);
  color: #81c784;
}

.auth-notification.error {
  background: rgba(220, 53, 69, 0.2);
  border: 1px solid rgba(220, 53, 69, 0.4);
  color: #ff6b6b;
}

.auth-notification.info {
  background: rgba(33, 150, 243, 0.2);
  border: 1px solid rgba(33, 150, 243, 0.4);
  color: #64b5f6;
}

/* Boîte de dialogue de confirmation personnalisée */
.custom-dialog {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  animation: fadeIn 0.2s ease;
}

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

.custom-dialog-content {
  background: #020617;
  border: 1px solid #2a394a;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  max-width: 450px;
  width: 90%;
  animation: slideIn 0.3s ease;
}

@keyframes slideIn {
  from {
    transform: scale(0.9) translateY(-20px);
    opacity: 0;
  }
  to {
    transform: scale(1) translateY(0);
    opacity: 1;
  }
}

.custom-dialog-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1.5rem 1.5rem 1rem 1.5rem;
  border-bottom: 1px solid #2a394a;
}

.custom-dialog-header i {
  color: #ffa726;
  font-size: 1.5rem;
}

.custom-dialog-header h3 {
  margin: 0;
  font-size: 1.2rem;
  color: var(--fg);
  font-weight: 600;
}

.custom-dialog-body {
  padding: 1.5rem;
}

.custom-dialog-body p {
  margin: 0;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.5;
}

.custom-dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  padding: 1rem 1.5rem 1.5rem 1.5rem;
  border-top: 1px solid #2a394a;
}

.custom-dialog-actions .btn {
  padding: 0.75rem 1.5rem;
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  border: 1px solid transparent;
}

.custom-dialog-actions .btn-secondary {
  background: #2a394a;
  color: var(--fg);
  border-color: #3c5068;
}

.custom-dialog-actions .btn-secondary:hover {
  background: #3c5068;
}

.custom-dialog-actions .btn-danger {
  background: rgba(220, 53, 69, 0.2);
  border-color: rgba(220, 53, 69, 0.4);
  color: #ff6b6b;
}

.custom-dialog-actions .btn-danger:hover {
  background: rgba(220, 53, 69, 0.3);
  border-color: rgba(220, 53, 69, 0.5);
}
