/* AlerteM Admin — shared stylesheet */
/* :root color vars are injected by the HTML shell */

* { box-sizing: border-box; }
html { font-size: 19px; }
body {
  margin: 0; min-height: 100vh;
  background: var(--bg); color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 1rem; line-height: 1.5;
}

/* ── SCREENS ── */
.screen { display: none; min-height: 100vh; }
.screen.active { display: block; }
#screen-login { display: flex; align-items: center; justify-content: center; }
#screen-login.active { display: flex; }

/* ── HEADER ── */
.admin-header {
  background: var(--primary); color: #fff;
  padding: 0 24px; height: 56px;
  display: flex; align-items: center; gap: 16px;
  box-shadow: 0 2px 8px rgba(0,0,0,.15);
}
.admin-header-logo { font-weight: 800; font-size: 1.1rem; letter-spacing: -.3px; }
.admin-header-sep { opacity: .4; }
.admin-header-title { font-weight: 500; font-size: .95rem; flex: 1; opacity: .9; }
.btn-header {
  background: rgba(255,255,255,.15); border: 1px solid rgba(255,255,255,.3);
  color: #fff; border-radius: 6px; padding: 5px 12px;
  font: inherit; font-size: .85rem; cursor: pointer;
}
.btn-header:hover { background: rgba(255,255,255,.25); }

/* ── CONTAINER ── */
.container { max-width: 1200px; margin: 0 auto; padding: 28px 24px; }

/* ── LOGIN ── */
.login-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 40px 36px;
  box-shadow: 0 4px 24px rgba(0,0,0,.08);
  width: 100%; max-width: 400px;
}
.login-logo {
  font-size: 1.6rem; font-weight: 800; color: var(--primary);
  margin: 0 0 4px; letter-spacing: -.5px;
}
.login-sub { color: var(--muted); font-size: .9rem; margin: 0 0 28px; }

/* ── PAGE TITLE ── */
.page-header { display: flex; align-items: center; gap: 14px; margin-bottom: 24px; }
.page-header h2 { margin: 0; font-size: 1.25rem; }
.btn-back {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 6px; padding: 6px 12px;
  font: inherit; font-size: .85rem; color: var(--muted); cursor: pointer;
}
.btn-back:hover { background: var(--bg); }

/* ── MUNICIPALITY GRID ── */
.muni-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.muni-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 22px 20px;
  box-shadow: var(--shadow); cursor: pointer;
  transition: border-color .15s, transform .1s;
  text-align: center;
}
.muni-card:hover { border-color: var(--primary); transform: translateY(-1px); }
.muni-card-name { font-weight: 700; font-size: 1.25rem; margin: 0 0 12px; }
.muni-card-count { font-size: 2.2rem; font-weight: 800; color: var(--primary); line-height: 1; }
.muni-card-label { font-size: .78rem; color: var(--muted); margin-top: 3px; }
.muni-empty { color: var(--muted); font-size: .9rem; padding: 16px 0; }

/* ── SEARCH ── */
.search-bar { display: flex; gap: 10px; align-items: center; margin-bottom: 16px; }
.search-input {
  flex: 1; padding: 10px 14px; border: 1px solid var(--border);
  border-radius: 8px; font: inherit; font-size: .9rem; background: var(--surface);
}
.search-input:focus { outline: 2px solid var(--primary); border-color: var(--primary); }
.result-count { font-size: .85rem; color: var(--subtle); white-space: nowrap; }

/* ── TABLE ── */
.table-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden;
}
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .875rem; }
thead th {
  text-align: left; padding: 11px 14px;
  background: #f8fafc; border-bottom: 1px solid var(--border);
  font-size: .72rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .5px; color: var(--subtle);
  white-space: nowrap;
}
tbody tr { border-bottom: 1px solid var(--border); }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: #f8fafc; }
td { padding: 11px 14px; vertical-align: middle; white-space: nowrap; }
td.muted { color: var(--muted); }

/* ── BADGES ── */
.badge {
  display: inline-block; padding: 2px 9px; border-radius: 999px;
  font-size: .72rem; font-weight: 600;
}
.badge-green { background: #dcfce7; color: #15803d; }
.badge-gray  { background: #f1f5f9; color: #64748b; }

/* ── BUTTONS ── */
.btn {
  appearance: none; cursor: pointer; font: inherit;
  font-size: .875rem; font-weight: 600;
  padding: 9px 18px; border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface); color: var(--text);
  transition: background .15s;
}
.btn:hover { background: var(--bg); }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary-dark); }
.btn-primary:hover { background: var(--primary-dark); }
.btn-danger { background: var(--danger); color: #fff; border-color: #b91c1c; }
.btn-danger:hover { background: #b91c1c; }
.btn-sm { padding: 5px 12px; font-size: .8rem; }
.btn-full { width: 100%; }

/* ── FORM ── */
.field { display: flex; flex-direction: column; margin-bottom: 14px; }
.field label { font-weight: 600; font-size: .875rem; margin-bottom: 5px; }
.field input:not([type="checkbox"]):not([type="radio"]), .field select {
  padding: 9px 12px; border: 1px solid var(--border);
  border-radius: 8px; font: inherit; font-size: .9rem;
  background: #fff; color: inherit; appearance: none;
}
.field input:not([type="checkbox"]):not([type="radio"]):focus, .field select:focus {
  outline: 2px solid var(--primary); border-color: var(--primary);
}
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.section-label {
  font-size: .72rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .5px;
  color: var(--subtle); margin: 20px 0 10px; padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}
.check-row {
  display: flex; align-items: center; gap: 9px;
  padding: 5px 0; cursor: pointer; font-size: .875rem;
}
.check-row input { width: auto; accent-color: var(--primary); transform: scale(1.2); cursor: pointer; }
.checks-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 2px; }

/* ── DRAWER ── */
.drawer-overlay {
  position: fixed; inset: 0; background: rgba(15,23,42,.35);
  z-index: 100; opacity: 0; pointer-events: none;
  transition: opacity .2s;
}
.drawer-overlay.open { opacity: 1; pointer-events: auto; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0;
  width: 500px; max-width: 100vw;
  background: var(--surface);
  box-shadow: -6px 0 32px rgba(0,0,0,.12);
  display: flex; flex-direction: column;
  transform: translateX(100%);
  transition: transform .25s ease;
  z-index: 101;
}
.drawer-overlay.open .drawer { transform: translateX(0); }
.drawer-header {
  padding: 18px 24px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px; flex-shrink: 0;
}
.drawer-header h3 { margin: 0; font-size: 1rem; flex: 1; }
.drawer-body { flex: 1; overflow-y: auto; padding: 20px 24px; }
.drawer-footer {
  padding: 16px 24px; border-top: 1px solid var(--border);
  display: flex; gap: 10px; flex-shrink: 0;
}

/* ── TOAST ── */
#toast {
  position: fixed; bottom: 28px; left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: #1e293b; color: #fff;
  padding: 13px 22px; border-radius: 10px;
  font-size: .95rem; font-weight: 500; line-height: 1.45;
  max-width: min(480px, 90vw); text-align: center;
  box-shadow: 0 4px 24px rgba(0,0,0,.22);
  opacity: 0; transition: opacity .25s, transform .25s;
  pointer-events: none; z-index: 9999;
}
#toast.toast-error   { background: #dc2626; }
#toast.toast-success { background: #16a34a; }
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); pointer-events: auto; }

/* ── ALERT TYPE BADGES ── */
.badge-evac    { background: #fee2e2; color: #b91c1c; }
.badge-incendie { background: #ffedd5; color: #c2410c; }
.badge-inondation { background: #dbeafe; color: #1d4ed8; }
.badge-chimique { background: #fef9c3; color: #854d0e; }
.badge-meteo   { background: #e0f2fe; color: #0369a1; }
.badge-recherche { background: #f3e8ff; color: #7e22ce; }
.badge-infrastructure { background: #f1f5f9; color: #475569; }
.badge-red  { background: #fee2e2; color: #b91c1c; }

/* ── REGION TABS ── */
.region-tabs { display: flex; gap: 4px; margin-bottom: 12px; flex-wrap: wrap; }
.region-tab {
  padding: 6px 14px; border-radius: 6px; border: 1px solid var(--border);
  font-size: .8rem; font-weight: 600; cursor: pointer;
  background: var(--surface); color: var(--muted); transition: all .15s;
}
.region-tab.active { background: var(--primary); color: #fff; border-color: var(--primary-dark); }

/* ── ALERT MAP ── */
.alert-map { height: 380px; border-radius: 8px; border: 1px solid var(--border); margin-bottom: 12px; }

/* ── ALERT FORM PANEL ── */
.alert-form-panel {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 24px; margin-bottom: 20px;
}
.alert-form-title { font-size: 1rem; font-weight: 700; margin: 0 0 16px; }
.preview-count {
  font-size: .9rem; font-weight: 600; color: var(--primary);
  padding: 10px 14px; background: #eff6ff; border-radius: 8px;
  border: 1px solid #bfdbfe; margin-bottom: 14px;
}

/* ── TEMPLATES ── */
.template-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border: 1px solid var(--border);
  border-radius: 8px; margin-bottom: 8px; background: var(--surface);
}
.template-item-name { font-weight: 600; font-size: .875rem; flex: 1; }
.template-item-type { font-size: .75rem; color: var(--subtle); }
.template-textarea {
  width: 100%; padding: 9px 12px; border: 1px solid var(--border);
  border-radius: 8px; font: inherit; font-size: .875rem;
  resize: vertical; min-height: 80px;
}
.template-textarea:focus { outline: 2px solid var(--primary); border-color: var(--primary); }

@media (max-width: 640px) {
  .field-row { grid-template-columns: 1fr; }
  .drawer { width: 100vw; }
  .muni-grid { grid-template-columns: 1fr; }
}
