:root {
  --bg: #f0f2f5;
  --surface: #ffffff;
  --surface2: #f5f7fa;
  --border: #e2e8f0;
  --accent: #cc0000;
  --text: #1a2235;
  --text-muted: #7a8fa6;
  --ok: #00b37a;
  --warning: #d97706;
  --error: #dc2626;
  --offline: #94a3b8;
}

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

/* Inputs et boutons héritent de la police globale */
input, button, select, textarea { font-family: inherit; }

body {
  font-family: 'Roboto', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}

/* LOGIN */
#loginPage {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  background: var(--bg);
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 40px;
  width: 380px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.08);
  animation: fadeUp 0.5s ease both;
}

.login-logo {
  display: flex;
  justify-content: center;
  margin-bottom: 32px;
}

.login-logo img { height: 60px; width: auto; }

.login-title {
  font-size: 1.1rem;
  font-weight: 700;
  text-align: center;
  margin-bottom: 24px;
}

.login-field { margin-bottom: 16px; }

.login-field label {
  display: block;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.login-field input {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 0.85rem;
  color: var(--text);
  outline: none;
  transition: border-color 0.2s;
}

.login-field input:focus { border-color: var(--accent); }

.login-btn {
  width: 100%;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 8px;
  padding: 12px;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  margin-top: 8px;
  transition: opacity 0.2s;
}

.login-btn:hover { opacity: 0.88; }
.login-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.login-error {
  margin-top: 12px;
  font-size: 0.75rem;
  color: var(--error);
  text-align: center;
  display: none;
}

.login-success {
  margin-top: 12px;
  font-size: 0.75rem;
  color: var(--ok);
  text-align: center;
  display: none;
}

.forgot-btn {
  width: 100%;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.78rem;
  cursor: pointer;
  margin-top: 12px;
  padding: 4px 0;
  text-decoration: underline;
  text-underline-offset: 3px;
  font-family: inherit;
  transition: color 0.2s;
}

.forgot-btn:hover { color: var(--accent); }

/* Modal mot de passe oublié */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 200;
  align-items: center;
  justify-content: center;
}

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

.modal-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 32px;
  width: 370px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.15);
  animation: fadeUp 0.3s ease both;
}

.modal-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 8px;
}

.modal-sub {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-bottom: 20px;
  line-height: 1.5;
}

.modal-captcha { margin-bottom: 16px; }

.modal-msg {
  font-size: 0.75rem;
  margin-bottom: 12px;
  display: none;
}

.modal-msg.error   { color: var(--error); }
.modal-msg.success { color: var(--ok); }

.modal-actions { display: flex; gap: 10px; }

.modal-actions .btn-secondary {
  flex: 1;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: 8px;
  padding: 10px;
  font-size: 0.85rem;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.2s;
}

.modal-actions .btn-secondary:hover { background: var(--border); }

.modal-actions .btn-primary {
  flex: 1;
  background: var(--accent);
  border: none;
  color: white;
  border-radius: 8px;
  padding: 10px;
  font-size: 0.85rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: opacity 0.2s;
}

.modal-actions .btn-primary:hover    { opacity: 0.88; }
.modal-actions .btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

/* DASHBOARD */
#dashboardPage { display: none; }

.wrapper {
  max-width: 1300px;
  margin: 0 auto;
  padding: 40px 32px;
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 48px;
  animation: fadeDown 0.6s ease both;
}

.header-left img { height: 60px; width: auto; }

.header-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.user-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 8px 16px;
  border-radius: 100px;
  font-size: 0.78rem;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

.user-label { color: var(--text-muted); }
.user-name { font-weight: 500; }

.logout-btn {
  font-size: 0.75rem;
  color: var(--text-muted);
  cursor: pointer;
  background: none;
  border: none;
  transition: color 0.2s;
}
.logout-btn:hover { color: var(--error); }

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

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px 24px;
  position: relative;
  overflow: hidden;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
  animation: fadeUp 0.6s ease both;
}

.stat-card::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
}

.stat-card:nth-child(1)::after { background: var(--text-muted); }
.stat-card:nth-child(2)::after { background: var(--ok); }
.stat-card:nth-child(3)::after { background: #0088cc; }
.stat-card:nth-child(4)::after { background: var(--error); }

.stat-label {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.stat-value {
  font-size: 2rem;
  font-weight: 900;
  line-height: 1;
}

.stat-value.green { color: var(--ok); }
.stat-sub { margin-top: 6px; font-size: 0.7rem; color: var(--text-muted); }

/* TOOLBAR */
.toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 24px;
  animation: fadeUp 0.6s 0.3s ease both;
  flex-wrap: wrap;
}

.search-box { flex: 1; position: relative; min-width: 200px; }

.search-box input {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 16px 10px 42px;
  color: var(--text);
  font-size: 0.82rem;
  outline: none;
  transition: border-color 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.search-box input:focus { border-color: var(--accent); }
.search-box input::placeholder { color: var(--text-muted); }
.search-icon { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--text-muted); }

.filter-select {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 0.82rem;
  padding: 10px 36px 10px 16px;
  border-radius: 8px;
  cursor: pointer;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%237a8fa6' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  min-width: 180px;
}

.filter-select:focus, .filter-select:hover {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(204,0,0,0.08);
}

/* TABLE */
.table-container {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow-x: auto;
  animation: fadeUp 0.6s 0.35s ease both;
  box-shadow: 0 1px 6px rgba(0,0,0,0.07);
}

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

thead tr {
  background: var(--surface2);
  border-bottom: 1px solid var(--border);
}

th {
  font-size: 0.65rem;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 14px 24px;
  text-align: left;
}

th:last-child { text-align: center; }

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

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

td { padding: 18px 24px; font-size: 0.82rem; vertical-align: middle; }

.serial {
  font-weight: 500;
  letter-spacing: 0.04em;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 12px;
  border-radius: 100px;
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.status-badge.available        { background: rgba(0,179,122,0.1);   border: 1px solid rgba(0,179,122,0.3);   color: var(--ok); }
.status-badge.vehicle_connected{ background: rgba(0,136,204,0.1);   border: 1px solid rgba(0,136,204,0.3);   color: #0088cc; }
.status-badge.preparing        { background: rgba(0,136,204,0.1);   border: 1px solid rgba(0,136,204,0.3);   color: #0088cc; }
.status-badge.charging         { background: rgba(0,136,204,0.1);   border: 1px solid rgba(0,136,204,0.3);   color: #0088cc; }
.status-badge.finished         { background: rgba(0,136,204,0.1);   border: 1px solid rgba(0,136,204,0.3);   color: #0088cc; }
.status-badge.faulted          { background: rgba(220,38,38,0.1);   border: 1px solid rgba(220,38,38,0.3);   color: var(--error); }
.status-badge.unavailable      { background: rgba(220,38,38,0.1);   border: 1px solid rgba(220,38,38,0.3);   color: var(--error); }
.status-badge.offline          { background: rgba(148,163,184,0.1); border: 1px solid rgba(148,163,184,0.3); color: var(--offline); }

/* Tooltip sur le badge charging */
.status-badge { position: relative; }
.status-tooltip {
  display: none;
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: #1a2435;
  color: #e6edf3;
  border-radius: 8px;
  padding: 7px 12px;
  font-size: 0.72rem;
  white-space: nowrap;
  z-index: 50;
  pointer-events: none;
  box-shadow: 0 4px 20px rgba(0,0,0,0.25);
}
.status-tooltip::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: #1a2435;
}
.status-badge:hover .status-tooltip { display: block; }

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

td.action-cell { text-align: center; }

.config-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 16px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-muted);
  font-size: 0.72rem;
  text-decoration: none;
  transition: all 0.2s;
}

.config-btn:hover { border-color: var(--accent); color: var(--accent); background: rgba(204,0,0,0.05); }
.config-btn svg { width: 13px; height: 13px; transition: transform 0.2s; }
.config-btn:hover svg { transform: rotate(45deg); }

/* FOOTER */
footer {
  margin-top: 32px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.68rem;
  color: var(--text-muted);
  letter-spacing: 0.06em;
}

.footer-brand { color: var(--accent); }

.charging-info {
  margin-top: 6px;
  font-size: 0.72rem;
  color: #0088cc;
  letter-spacing: 0.04em;
}

.desc-edit-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
}

.desc-input {
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 5px 8px;
  font-size: 0.82rem;
  color: var(--text);
  outline: none;
  width: 100%;
  transition: border-color 0.2s, background 0.2s;
}

.desc-input:hover { border-color: var(--border); background: var(--surface2); }
.desc-input:focus { border-color: var(--accent); background: var(--surface2); }

.desc-save-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 0.9rem;
  padding: 4px 6px;
  border-radius: 4px;
  opacity: 0;
  transition: opacity 0.2s, color 0.2s;
}

.desc-edit-wrap:focus-within .desc-save-btn { opacity: 1; }
.desc-save-btn:hover { color: var(--ok); }

/* ANIMATIONS */
@keyframes fadeDown { from { opacity:0; transform:translateY(-18px); } to { opacity:1; transform:translateY(0); } }
@keyframes fadeUp   { from { opacity:0; transform:translateY(18px);  } to { opacity:1; transform:translateY(0); } }
@keyframes pulse    { 0%,100% { opacity:1; } 50% { opacity:0.5; } }
@keyframes blink    { 0%,100% { opacity:1; } 50% { opacity:0; } }

@media (max-width: 900px) {
  .stats-row { grid-template-columns: repeat(2,1fr); }
  .wrapper { padding: 24px 16px; }
  th, td { padding: 12px 14px; }
  .filter-select { font-size: 0.75rem; min-width: 140px; }
}

@media (max-width: 600px) {
  .stats-row { grid-template-columns: 1fr 1fr; }
  header { flex-direction: column; gap: 16px; align-items: flex-start; }
  .header-right { width: 100%; justify-content: space-between; }
  table { min-width: 600px; }
}
