/* =========================================================================
   AG-Prévention — styles.css
   Design mobile first. Palette : bleu #2E5B8A, orange #E8701A.
   ========================================================================= */

:root {
  --blue: #2E5B8A;
  --blue-dark: #234766;
  --blue-light: #e8f0f8;
  --orange: #E8701A;
  --orange-dark: #c75d0f;
  --ink: #1f2933;
  --muted: #6b7785;
  --line: #e2e8f0;
  --bg: #f4f6f9;
  --white: #ffffff;
  --success: #2f8f5b;
  --error: #c0392b;
  --radius: 14px;
  --shadow: 0 2px 10px rgba(35, 71, 102, 0.10);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  line-height: 1.45;
}

/* ---------------------------------------------------------------- Boutons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  border-radius: var(--radius);
  padding: 14px 18px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color .15s ease, transform .05s ease;
  text-decoration: none;
}
.btn:active { transform: scale(0.985); }
.btn-block { width: 100%; }

.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:hover { background: var(--blue-dark); }
.btn-primary:disabled { background: #9fb3c8; cursor: not-allowed; }

.btn-ghost {
  background: transparent;
  color: var(--blue);
  border: 1px solid var(--line);
  padding: 10px 14px;
  font-size: 14px;
}
.btn-ghost:hover { background: var(--blue-light); }

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: none;
  background: transparent;
  color: #fff;
  font-size: 22px;
  line-height: 1;
  border-radius: 50%;
  cursor: pointer;
  text-decoration: none;
}
.btn-icon:hover { background: rgba(255, 255, 255, 0.15); }

.ms-logo { flex: 0 0 auto; }

/* ---------------------------------------------------------- Page connexion */
.login-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: linear-gradient(160deg, var(--blue) 0%, var(--blue-dark) 55%, #16314a 100%);
  padding: 24px;
}
.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--white);
  border-radius: 20px;
  padding: 32px 24px 28px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.28);
}
.brand { text-align: center; margin-bottom: 26px; }
.brand-logo {
  width: 72px;
  height: 72px;
  margin: 0 auto 14px;
  border-radius: 18px;
  background: var(--orange);
  color: #fff;
  font-weight: 800;
  font-size: 30px;
  letter-spacing: 1px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 16px rgba(232, 112, 26, 0.4);
}
.brand-title { margin: 0; font-size: 24px; color: var(--blue); }
.brand-subtitle { margin: 6px 0 0; font-size: 14px; color: var(--muted); }
.login-hint { text-align: center; font-size: 13px; color: var(--muted); margin: 16px 0 0; }
.login-footer {
  position: fixed;
  bottom: calc(16px + var(--safe-bottom));
  display: flex;
  align-items: center;
  gap: 8px;
  color: rgba(255, 255, 255, 0.85);
}
.dot-blue, .dot-orange { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.dot-blue { background: #fff; }
.dot-orange { background: var(--orange); }
.offline-banner {
  margin-top: 16px;
  padding: 10px 12px;
  border-radius: 10px;
  background: #fff4e8;
  color: var(--orange-dark);
  font-size: 13px;
  text-align: center;
  border: 1px solid #f6d6b3;
}

/* -------------------------------------------------------------- En-tête app */
.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--blue);
  color: #fff;
  padding-top: var(--safe-top);
  box-shadow: var(--shadow);
}
.app-header-inner {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
}
.app-logo {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: var(--orange);
  color: #fff;
  font-weight: 800;
  font-size: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}
.app-title { font-size: 18px; margin: 0; flex: 1; font-weight: 600; }

.sync-bar {
  background: var(--orange);
  color: #fff;
  font-size: 13px;
  text-align: center;
  padding: 7px 12px;
}

/* ------------------------------------------------------------ Corps de page */
.app-main {
  padding: 14px 14px calc(86px + var(--safe-bottom));
  max-width: 720px;
  margin: 0 auto;
}

.toolbar {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}
.search-input {
  flex: 1;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: 16px;
  background: #fff;
}
.search-input:focus, .field-input:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(46, 91, 138, 0.15);
}

.state-msg {
  padding: 14px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
}
.state-msg.error { color: var(--error); }
.state-msg.info { color: var(--blue); }

/* ------------------------------------------------------- Liste de chantiers */
.card-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.card {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  border-left: 4px solid var(--orange);
}
.card-body { padding: 14px 16px 12px; }
.card-title { font-size: 17px; margin: 0 0 6px; color: var(--blue-dark); }
.card-line { margin: 2px 0; font-size: 14px; color: var(--muted); }
.card-action {
  display: block;
  text-align: right;
  padding: 11px 16px;
  background: var(--blue-light);
  color: var(--blue);
  font-weight: 600;
  font-size: 14px;
  text-decoration: none;
}
.card-action:hover { background: #dbe8f5; }

.badge {
  display: inline-block;
  margin-top: 8px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}
.badge-active { background: #e6f4ec; color: var(--success); }
.badge-done { background: #eef1f4; color: var(--muted); }

/* ---------------------------------------------------------------- Formulaire */
.form { display: flex; flex-direction: column; gap: 16px; }
.form-section {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
}
.form-section-title {
  margin: 0 0 12px;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--orange-dark);
}
.field { display: block; margin-bottom: 14px; }
.field:last-child { margin-bottom: 0; }
.field-label { display: block; font-size: 14px; font-weight: 600; margin-bottom: 6px; color: var(--ink); }
.field-input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 16px;
  background: #fff;
  font-family: inherit;
}
textarea.field-input { resize: vertical; }

.checks { border: none; padding: 0; margin: 0 0 14px; display: flex; flex-direction: column; gap: 10px; }
.check { display: flex; align-items: center; gap: 10px; font-size: 15px; }
.check input { width: 20px; height: 20px; accent-color: var(--blue); }

.form-actions { margin-top: 4px; }

/* ---------------------------------------------------------------- Statut/msg */
.status {
  padding: 12px 14px;
  border-radius: 10px;
  font-size: 14px;
  text-align: center;
}
.status.info { background: var(--blue-light); color: var(--blue-dark); }
.status.success { background: #e6f4ec; color: var(--success); }
.status.error { background: #fdecea; color: var(--error); }

/* ----------------------------------------------------- Navigation inférieure */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  display: flex;
  background: #fff;
  border-top: 1px solid var(--line);
  padding-bottom: var(--safe-bottom);
  z-index: 10;
}
.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 9px 0;
  font-size: 11px;
  color: var(--muted);
  text-decoration: none;
}
.nav-item span { font-size: 11px; }
.nav-item.active { color: var(--blue); font-weight: 700; }
.nav-item.active span { color: var(--blue); }

/* ------------------------------------------------------------ Tableau de bord */
.kpi-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 16px;
}
.kpi {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border-left: 4px solid var(--blue);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.kpi-value { font-size: 26px; font-weight: 800; color: var(--blue-dark); line-height: 1.1; }
.kpi-label { font-size: 13px; color: var(--muted); }

.dash-card {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 16px 16px;
  margin-bottom: 16px;
}
.dash-card-title {
  margin: 0 0 12px;
  font-size: 14px;
  color: var(--blue-dark);
  font-weight: 700;
}

.tile-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}
.tile {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: #fff;
  border: 1px solid var(--line);
  border-left: 4px solid var(--orange);
  border-radius: 10px;
  padding: 10px 14px;
  text-decoration: none;
  color: inherit;
}
a.tile:active { transform: scale(0.99); }
a.tile:hover { background: var(--blue-light); border-left-color: var(--blue); }
.tile-label { font-size: 14px; color: var(--ink); font-weight: 600; }
.tile-fig { display: flex; align-items: baseline; gap: 8px; white-space: nowrap; }
.tile-fig strong { font-size: 20px; color: var(--blue-dark); }
.tile-sub { font-size: 13px; color: var(--muted); }

.dash-updated { text-align: center; font-size: 12px; color: var(--muted); margin: 4px 0 0; }

@media (min-width: 600px) {
  .tile-grid { grid-template-columns: 1fr 1fr; }
}

/* ---------------------------------------------------------------- Utilitaires */
.hidden { display: none !important; }

@media (min-width: 600px) {
  .card-list { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
}
