/* =====================================================================
   SAV iMedia - Design system (sombre, premium, professionnel)
   Responsive : mobile / tablette / desktop
   ===================================================================== */

:root {
  --bg: #0a0e16;
  --bg-elevated: #0f1522;
  --bg-card: #141b2b;
  --bg-card-hover: #182238;
  --bg-input: #0d1320;
  --border: #232c40;
  --border-light: #2c374e;
  --text: #e8edf7;
  --text-muted: #8c98b3;
  --text-faint: #5b6782;

  --accent: #29c1ff;
  --accent-dark: #0e8fc9;
  --accent-soft: rgba(41, 193, 255, 0.12);

  --success: #22c55e;
  --success-soft: rgba(34, 197, 94, 0.14);
  --warning: #f5a524;
  --warning-soft: rgba(245, 165, 36, 0.14);
  --danger: #ef4a5f;
  --danger-soft: rgba(239, 74, 95, 0.14);
  --gray: #7d879c;
  --gray-soft: rgba(125, 135, 156, 0.14);

  --radius-sm: 8px;
  --radius: 14px;
  --radius-lg: 20px;

  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  --shadow-sm: 0 4px 14px rgba(0, 0, 0, 0.25);

  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  background: radial-gradient(circle at top right, #0d1526 0%, var(--bg) 45%);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  line-height: 1.55;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 { font-weight: 700; margin: 0 0 .5em; letter-spacing: -0.01em; }
p { margin: 0 0 1em; color: var(--text-muted); }

img { max-width: 100%; display: block; }

.container {
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 20px;
}

.container-narrow {
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  padding: 0 20px;
}

/* ---------------------------------------------------------------------
   Header public
   --------------------------------------------------------------------- */
.public-header {
  padding: 28px 0 10px;
  text-align: center;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  font-weight: 800;
  font-size: 1.4rem;
  letter-spacing: -0.02em;
}

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--accent), #6d5bff);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
  color: #04121c;
  box-shadow: 0 6px 18px rgba(41, 193, 255, 0.35);
}

.brand-sub {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin-top: 4px;
}

.public-footer {
  text-align: center;
  padding: 40px 20px 30px;
  color: var(--text-faint);
  font-size: 0.85rem;
}

/* ---------------------------------------------------------------------
   Cartes / panneaux
   --------------------------------------------------------------------- */
.panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 32px;
}

@media (max-width: 640px) {
  .panel { padding: 22px 18px; border-radius: var(--radius); }
}

.panel-header { margin-bottom: 22px; }
.panel-header h1 { font-size: 1.5rem; }
.panel-header h2 { font-size: 1.25rem; }

/* ---------------------------------------------------------------------
   Formulaires
   --------------------------------------------------------------------- */
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 18px 20px;
}

@media (max-width: 720px) {
  .form-grid { grid-template-columns: 1fr; }
}

.field { display: flex; flex-direction: column; gap: 6px; }
.field-full { grid-column: 1 / -1; }

label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
}

label .req { color: var(--danger); margin-left: 3px; }

input[type=text],
input[type=email],
input[type=tel],
input[type=password],
input[type=number],
input[type=date],
input[type=search],
select,
textarea {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  color: var(--text);
  font-family: var(--font);
  font-size: 0.95rem;
  transition: border-color .15s, box-shadow .15s;
}

textarea { resize: vertical; min-height: 110px; }

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

select {
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%238c98b3' stroke-width='2'><polyline points='6 9 12 15 18 9'/></svg>");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
}

fieldset { border: none; margin: 0; padding: 0; }

.help-text { font-size: 0.8rem; color: var(--text-faint); }

/* Toggle switch (urgent) */
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-input);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
}

.switch { position: relative; display: inline-block; width: 46px; height: 26px; flex: 0 0 auto; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch-track {
  position: absolute; inset: 0; background: var(--border-light); border-radius: 999px;
  transition: background .2s; cursor: pointer;
}
.switch-track::before {
  content: ""; position: absolute; height: 20px; width: 20px; left: 3px; top: 3px;
  background: #fff; border-radius: 50%; transition: transform .2s;
}
.switch input:checked + .switch-track { background: var(--danger); }
.switch input:checked + .switch-track::before { transform: translateX(20px); }

/* Captcha */
.captcha-row {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}
.captcha-img {
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-light);
  background: var(--bg-input);
}
.captcha-refresh {
  font-size: 0.8rem;
  color: var(--accent);
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
}
.captcha-input { max-width: 160px; }

/* Honeypot (piege anti-bot invisible) */
.hp-field { position: absolute; left: -9999px; top: -9999px; opacity: 0; height: 0; width: 0; }

/* ---------------------------------------------------------------------
   Boutons
   --------------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 22px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.95rem;
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform .1s, filter .15s, background .15s;
  text-decoration: none;
}
.btn:hover { text-decoration: none; filter: brightness(1.08); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; filter: none; }

.btn-primary { background: linear-gradient(135deg, var(--accent), var(--accent-dark)); color: #04121c; box-shadow: 0 8px 20px rgba(41,193,255,.25); }
.btn-secondary { background: var(--bg-card-hover); color: var(--text); border-color: var(--border-light); }
.btn-ghost { background: transparent; color: var(--text-muted); border-color: var(--border-light); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-sm { padding: 8px 14px; font-size: 0.83rem; }
.btn-block { width: 100%; }

/* ---------------------------------------------------------------------
   Alertes / messages flash
   --------------------------------------------------------------------- */
.alert {
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  margin-bottom: 18px;
  font-size: 0.9rem;
  border: 1px solid transparent;
}
.alert-success { background: var(--success-soft); color: #7ee7a8; border-color: rgba(34,197,94,.35); }
.alert-error   { background: var(--danger-soft); color: #ff9aa8; border-color: rgba(239,74,95,.35); }
.alert-warning { background: var(--warning-soft); color: #ffcf8a; border-color: rgba(245,165,36,.35); }
.alert-info    { background: var(--accent-soft); color: #8fe0ff; border-color: rgba(41,193,255,.35); }

/* ---------------------------------------------------------------------
   LEDs & etats equipements
   --------------------------------------------------------------------- */
.led {
  width: 12px; height: 12px; border-radius: 50%;
  display: inline-block; flex: 0 0 auto;
  box-shadow: 0 0 0 3px rgba(255,255,255,0.03);
}
.led-green  { background: var(--success); box-shadow: 0 0 10px 2px rgba(34,197,94,.65); }
.led-red    { background: var(--danger); box-shadow: 0 0 10px 2px rgba(239,74,95,.65); }
.led-orange { background: var(--warning); box-shadow: 0 0 10px 2px rgba(245,165,36,.65); }
.led-gray   { background: var(--gray); }
.led-testing {
  background: var(--accent);
  animation: pulse 1s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 4px 1px rgba(41,193,255,.5); opacity: 1; }
  50% { box-shadow: 0 0 14px 5px rgba(41,193,255,.75); opacity: .6; }
}

.equip-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 18px;
  margin-top: 10px;
}

.equip-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: border-color .15s, transform .15s;
}
.equip-card:hover { border-color: var(--border-light); }

.equip-card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.equip-type-badge {
  font-size: 0.72rem; text-transform: uppercase; letter-spacing: .04em;
  color: var(--accent); background: var(--accent-soft);
  padding: 3px 9px; border-radius: 999px; font-weight: 700;
}
.equip-name { font-size: 1.05rem; font-weight: 700; margin: 2px 0 0; }
.equip-desc { font-size: 0.85rem; color: var(--text-muted); margin: 0; }

.equip-status {
  display: flex; align-items: center; gap: 10px;
  background: var(--bg-input); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 10px 12px;
}
.equip-status-text { display: flex; flex-direction: column; }
.equip-status-title { font-weight: 700; font-size: 0.9rem; }
.equip-status-detail { font-size: 0.78rem; color: var(--text-faint); }

.equip-footer { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }

/* Badges garantie */
.badge { font-size: 0.75rem; font-weight: 700; padding: 4px 10px; border-radius: 999px; }
.badge.ok { background: var(--success-soft); color: #7ee7a8; }
.badge.warning { background: var(--warning-soft); color: #ffcf8a; }
.badge.expired { background: var(--danger-soft); color: #ff9aa8; }
.badge.muted { background: var(--gray-soft); color: var(--text-muted); }

/* Badges statut ticket */
.pill { font-size: 0.72rem; font-weight: 700; padding: 4px 11px; border-radius: 999px; text-transform: uppercase; letter-spacing: .03em; }
.pill-nouveau { background: var(--accent-soft); color: var(--accent); }
.pill-en_cours { background: var(--warning-soft); color: var(--warning); }
.pill-resolu { background: var(--success-soft); color: var(--success); }
.pill-ferme { background: var(--gray-soft); color: var(--gray); }
.pill-urgent { background: var(--danger-soft); color: var(--danger); }

/* ---------------------------------------------------------------------
   Spinner
   --------------------------------------------------------------------- */
.spinner {
  width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,.25); border-top-color: currentColor;
  animation: spin .7s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------------------------------------------------------------------
   Confirmation / ecran de succes
   --------------------------------------------------------------------- */
.success-box { text-align: center; padding: 20px 0; }
.success-icon {
  width: 74px; height: 74px; border-radius: 50%;
  background: var(--success-soft); color: var(--success);
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 20px; font-size: 2.2rem;
}
.ticket-number {
  display: inline-block; font-family: 'SFMono-Regular', Consolas, Menlo, monospace;
  background: var(--bg-input); border: 1px dashed var(--border-light);
  padding: 8px 16px; border-radius: var(--radius-sm); font-weight: 700; letter-spacing: .04em;
  color: var(--accent); margin: 8px 0 18px;
}

/* =====================================================================
   BACK-OFFICE
   ===================================================================== */
.admin-shell { display: flex; min-height: 100vh; }

.admin-sidebar {
  width: 240px; flex: 0 0 auto;
  background: var(--bg-elevated);
  border-right: 1px solid var(--border);
  padding: 22px 16px;
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: 4px;
}

.admin-sidebar .brand { font-size: 1.1rem; padding: 0 8px 18px; }
.admin-sidebar .brand-mark { width: 34px; height: 34px; border-radius: 9px; font-size: .95rem; }

.nav-link {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: var(--radius-sm);
  color: var(--text-muted); font-weight: 600; font-size: 0.9rem;
}
.nav-link:hover { background: var(--bg-card-hover); color: var(--text); text-decoration: none; }
.nav-link.active { background: var(--accent-soft); color: var(--accent); }
.nav-section-title { font-size: 0.72rem; text-transform: uppercase; color: var(--text-faint); margin: 16px 12px 6px; letter-spacing: .06em; }

.admin-main { flex: 1 1 auto; min-width: 0; }

.admin-topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 28px; border-bottom: 1px solid var(--border);
  background: rgba(15,21,34,.7); backdrop-filter: blur(6px);
  position: sticky; top: 0; z-index: 5;
}
.admin-topbar h1 { font-size: 1.15rem; margin: 0; }
.admin-user { display: flex; align-items: center; gap: 12px; font-size: 0.85rem; color: var(--text-muted); }
.admin-user strong { color: var(--text); }

.admin-content { padding: 26px 28px 60px; }

.mobile-toggle { display: none; }

@media (max-width: 900px) {
  .admin-sidebar {
    position: fixed; left: 0; top: 0; z-index: 50;
    transform: translateX(-100%);
    transition: transform .2s; box-shadow: var(--shadow);
  }
  .admin-sidebar.open { transform: translateX(0); }
  .admin-content { padding: 20px 16px 50px; }
  .admin-topbar { padding: 14px 16px; }
  .mobile-toggle {
    display: inline-flex; background: var(--bg-card-hover); border: 1px solid var(--border-light);
    color: var(--text); border-radius: var(--radius-sm); padding: 8px 12px; cursor: pointer;
  }
}

/* Grille de statistiques dashboard */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 26px;
}
.stat-tile {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px;
}
.stat-tile .value { font-size: 1.8rem; font-weight: 800; }
.stat-tile .label { color: var(--text-muted); font-size: 0.85rem; margin-top: 4px; }
.stat-tile.accent-green .value { color: var(--success); }
.stat-tile.accent-red .value { color: var(--danger); }
.stat-tile.accent-blue .value { color: var(--accent); }
.stat-tile.accent-orange .value { color: var(--warning); }

/* Tables */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: 0.88rem; min-width: 640px; }
thead th {
  text-align: left; padding: 12px 16px; background: var(--bg-elevated);
  color: var(--text-muted); font-size: 0.78rem; text-transform: uppercase; letter-spacing: .04em;
  border-bottom: 1px solid var(--border);
}
tbody td { padding: 13px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--bg-card-hover); }
.table-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 18px; flex-wrap: wrap; }
.toolbar-filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.search-input { min-width: 220px; }

.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }

/* Login */
.login-shell { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card { width: 100%; max-width: 400px; }

/* Map */
.map-container { width: 100%; height: 320px; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border); }

/* Timeline interventions */
.timeline { display: flex; flex-direction: column; gap: 0; }
.timeline-item { position: relative; padding: 0 0 22px 26px; border-left: 2px solid var(--border); }
.timeline-item:last-child { border-color: transparent; padding-bottom: 0; }
.timeline-item::before {
  content: ""; position: absolute; left: -7px; top: 2px;
  width: 12px; height: 12px; border-radius: 50%; background: var(--accent);
  box-shadow: 0 0 0 4px var(--bg-card);
}
.timeline-date { font-size: 0.78rem; color: var(--text-faint); }
.timeline-title { font-weight: 700; margin: 3px 0; }

/* File list */
.file-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 14px; background: var(--bg-input); border: 1px solid var(--border);
  border-radius: var(--radius-sm); margin-bottom: 8px; font-size: 0.87rem;
}

/* Utilitaires */
.mt-0 { margin-top: 0; } .mb-0 { margin-bottom: 0; }
.mt-1 { margin-top: 10px; } .mb-1 { margin-bottom: 10px; }
.mt-2 { margin-top: 20px; } .mb-2 { margin-bottom: 20px; }
.text-muted { color: var(--text-muted); }
.text-center { text-align: center; }
.flex { display: flex; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-1 { gap: 10px; }
.gap-2 { gap: 18px; }
.hidden { display: none !important; }

/* Impression QR code */
@media print {
  .no-print { display: none !important; }
  body { background: #fff; color: #000; }
}
