: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; align-items:center; }
.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;
  margin-bottom: 1rem;
}
.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;
  position:relative;
  background:#020617; border:1px solid var(--border); border-radius:8px; padding:4px 8px;
}
.search input{
  background:transparent; border:none; outline:none; color:var(--fg); padding:4px; min-width:200px;
}
.search button{
  background:transparent; border:none; color:var(--muted); cursor:pointer; padding:2px 4px; font-size:16px;
}
.search button:hover{ color:var(--fg); }
.muted{ color:var(--muted); font-size:0.9rem; }

/* ===== Grille de contacts ===== */
.grid-wrapper{
  border:1px solid var(--border);
  border-radius:8px;
  background:var(--card);
  overflow:hidden;
}
.grid-scroller{
  overflow-x:auto; overflow-y:auto; max-height:calc(100vh - 250px);
}
.contacts-table{
  width:100%;
  border-collapse:collapse;
  color:var(--fg);
}
.contacts-table thead{
  background:var(--thead);
  position:sticky;
  top:0;
  z-index:10;
}
.contacts-table th{
  padding:12px;
  text-align:left;
  font-weight:600;
  border-bottom:2px solid var(--border);
  white-space:nowrap;
}
.contacts-table td{
  padding:12px;
  border-bottom:1px solid var(--border);
}
.contacts-table tbody tr{
  cursor:move;
  transition:background 0.2s;
}
.contacts-table tbody tr:hover{
  background:rgba(45, 119, 255, 0.05);
}
.contacts-table tbody tr.dragging{
  opacity:0.5;
  background:rgba(45, 119, 255, 0.2);
}
.contacts-table tbody tr.drag-over{
  border-top:3px solid var(--accent);
}

/* Boutons d'action dans le tableau */
.action-btn{
  padding:0.4rem 0.75rem;
  font-size:0.85rem;
  border-radius:6px;
  margin-right:0.5rem;
}
.btn-edit{
  background:rgba(45, 119, 255, 0.1);
  border-color:rgba(45, 119, 255, 0.3);
  color:#64b5f6;
}
.btn-edit:hover{
  background:rgba(45, 119, 255, 0.2);
}
.btn-delete{
  background:rgba(220, 53, 69, 0.1);
  border-color:rgba(220, 53, 69, 0.3);
  color:#ff6b6b;
}
.btn-delete:hover{
  background:rgba(220, 53, 69, 0.2);
}

/* ===== Dialogues modaux ===== */
.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:600px;
  position:relative;
}

.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-content h2{
  margin:0 0 1.5rem 0;
  color:var(--fg);
  font-size:1.5rem;
}

.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,
.form-group textarea{
  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;
  font-family:inherit;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus{
  outline:none;
  border-color:var(--accent);
  box-shadow:0 0 0 3px rgba(45, 119, 255, 0.1);
}
.form-group textarea{
  resize:vertical;
  min-height:80px;
}

.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;
}

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

.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;
}

/* Boutons d'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;
}

/* Boutons Excel - l'icône a déjà le fond vert */
#export-contacts-btn,
#import-contacts-btn {
  background: transparent;
  border-color: #217346;
}

#export-contacts-btn:hover,
#import-contacts-btn:hover {
  background: rgba(33, 115, 70, 0.1);
  border-color: #1a5c37;
}

.auth-btn{
  position:relative;
}
.auth-btn.logged-in{
  background:linear-gradient(135deg, #2d77ff, #1e5ecc);
  border-color:#1e5ecc;
  color:white;
  width:auto;
  min-width:38px;
  height:38px;
  padding:0 12px;
  gap:8px;
  white-space:nowrap;
  font-size:1rem;
  display:inline-flex;
  align-items:center;
  justify-content:center;
}
.auth-btn.logged-in i{
  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;
}

/* Dialogues d'authentification */
#login-dialog,
#user-management-dialog{
  z-index:9999 !important;
}

.login-content{
  max-width:400px;
  width:90%;
}

/* Styles pour la gestion des utilisateurs */
.flotte-list-content{
  width:98%;
  max-width:1800px;
  height:85vh;
  display:flex;
  flex-direction:column;
  overflow:hidden;
}

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

.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;
  text-align:left !important;
}

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

.users-table *,
.users-table *::before,
.users-table *::after{
  border-left:none !important;
  border-right:none !important;
  border-top:none !important;
  box-shadow:none !important;
}

.users-table input,
.users-table select{
  width:100%;
  padding:0.5rem;
  border:1px solid #2a394a !important;
  border-radius:6px;
  background:#020617 !important;
  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);
}

.delete-user-btn{
  padding:0.4rem 0.75rem;
  font-size:0.85rem;
  border-radius:6px;
  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;
}

.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;
}

/* Notification temporaire */
.auth-notification{
  position:fixed;
  bottom:20px;
  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);
  pointer-events:none;
}

.auth-notification.show{
  opacity:1;
  transform:translateY(0);
  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);
}
