/* Télésurveillance SARL Afellay — charte : bleus circuit du logo Afellay */
:root {
  --navy: #0d1b4b;
  --navy-2: #123a6e;
  --blue: #1b74b8;
  --blue-light: #3aa0d8;
  --bg: #f2f5f9;
  --card: #ffffff;
  --text: #16233b;
  --muted: #64748b;
  --border: #dbe3ee;
  --green: #1e9e5a;
  --yellow: #e0a800;
  --red: #d23b3b;
  --gray: #9aa5b1;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(13, 27, 75, .08), 0 4px 14px rgba(13, 27, 75, .06);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Segoe UI", system-ui, -apple-system, Tahoma, Arial, sans-serif;
  background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.5;
  min-height: 100vh; display: flex; flex-direction: column;
}
[dir="rtl"] body, [dir="rtl"] { font-family: Tahoma, "Segoe UI", Arial, sans-serif; }

/* ---------- entête ---------- */
.topbar { background: linear-gradient(90deg, var(--navy) 0%, var(--navy-2) 55%, var(--blue) 130%); color: #fff; box-shadow: var(--shadow); }
.topbar-inner { max-width: 1200px; margin: 0 auto; padding: 10px 20px; display: flex; align-items: center; gap: 22px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; }
.brand-icon { height: 40px; width: auto; background: #fff; border-radius: 8px; padding: 3px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text strong { font-size: 15px; letter-spacing: .4px; }
.brand-text small { opacity: .85; font-size: 12px; }
.mainnav { display: flex; gap: 4px; flex: 1; }
.mainnav a { color: #dfe9f5; text-decoration: none; padding: 8px 14px; border-radius: 8px; font-weight: 500; }
.mainnav a:hover { background: rgba(255,255,255,.12); color: #fff; }
.mainnav a.active { background: rgba(255,255,255,.18); color: #fff; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.userchip { background: rgba(255,255,255,.15); padding: 5px 12px; border-radius: 999px; font-size: 13px; }
.langform select { background: rgba(255,255,255,.15); color: #fff; border: 1px solid rgba(255,255,255,.3); border-radius: 8px; padding: 5px 8px; font-size: 13px; }
.langform select option { color: var(--text); }

/* ---------- structure ---------- */
.container { max-width: 1200px; margin: 0 auto; padding: 24px 20px 40px; width: 100%; flex: 1; }
.footer { text-align: center; color: var(--muted); font-size: 12.5px; padding: 18px; }
h1 { font-size: 22px; margin: 0 0 4px; color: var(--navy); }
h2 { font-size: 17px; margin: 26px 0 10px; color: var(--navy-2); }
.page-sub { color: var(--muted); margin: 0 0 20px; }
.flash { background: #e5f5ec; border: 1px solid #bfe5d0; color: #14683c; border-radius: 10px; padding: 10px 14px; margin: 0 0 16px; }
.error { background: #fdeaea; border: 1px solid #f3c4c4; color: #8f1f1f; border-radius: 10px; padding: 10px 14px; margin: 0 0 16px; }

/* ---------- cartes puits ---------- */
.wellgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 18px; }
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.wellcard { display: block; color: inherit; text-decoration: none; padding: 18px; transition: transform .08s ease, box-shadow .08s ease; }
.wellcard:hover { transform: translateY(-2px); box-shadow: 0 4px 10px rgba(13,27,75,.12), 0 8px 24px rgba(13,27,75,.10); }
.wellcard-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 4px; }
.wellcard-head h3 { margin: 0; font-size: 18px; color: var(--navy); }
.statepill { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; font-weight: 600; padding: 4px 11px; border-radius: 999px; background: #eef2f7; white-space: nowrap; }
.statepill.green  { background: #e5f5ec; color: #14683c; }
.statepill.red    { background: #fdeaea; color: #8f1f1f; }
.statepill.yellow { background: #fcf3d7; color: #7a5c00; }
.statepill.gray   { background: #eef0f3; color: #566270; }
.wellcard .meta { color: var(--muted); font-size: 13px; margin-bottom: 12px; }
.kv { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 16px; }
.kv .k { color: var(--muted); font-size: 12.5px; }
.kv .v { font-weight: 600; font-variant-numeric: tabular-nums; }
.alarmnote { margin-top: 12px; font-size: 13px; color: var(--red); font-weight: 600; }

/* ---------- pastilles ---------- */
.dot { display: inline-block; width: 11px; height: 11px; border-radius: 50%; vertical-align: middle; }
.dot-green  { background: var(--green);  box-shadow: 0 0 0 3px #1e9e5a22; }
.dot-yellow { background: var(--yellow); box-shadow: 0 0 0 3px #e0a80022; }
.dot-red    { background: var(--red);    box-shadow: 0 0 0 3px #d23b3b22; }
.dot-gray   { background: var(--gray);   box-shadow: 0 0 0 3px #9aa5b122; }

/* ---------- tableaux ---------- */
.tablewrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
table.data th { background: #f6f8fb; text-align: start; font-size: 12.5px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); padding: 10px 14px; border-bottom: 1px solid var(--border); }
table.data td { padding: 10px 14px; border-bottom: 1px solid #edf1f7; font-variant-numeric: tabular-nums; }
table.data tr:last-child td { border-bottom: none; }
table.data tr:hover td { background: #f8fafd; }

/* ---------- formulaires & boutons ---------- */
label { display: block; font-size: 13px; color: var(--muted); margin: 12px 0 4px; }
input[type=text], input[type=password], input[type=email], input[type=number],
input[type=date], input[type=datetime-local], select, textarea {
  width: 100%; max-width: 420px; padding: 9px 12px; border: 1px solid var(--border);
  border-radius: 9px; font-size: 14.5px; background: #fff; color: var(--text);
}
textarea { max-width: 620px; min-height: 80px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--blue-light); border-color: var(--blue); }
.btn { display: inline-block; background: var(--blue); color: #fff; border: none; cursor: pointer;
  padding: 9px 18px; border-radius: 9px; font-size: 14.5px; font-weight: 600; text-decoration: none; }
.btn:hover { background: var(--navy-2); }
.btn-ghost { background: rgba(255,255,255,.14); color: #fff; padding: 7px 14px; font-size: 13.5px; }
.btn-ghost:hover { background: rgba(255,255,255,.26); }
.btn-small { padding: 5px 12px; font-size: 13px; }
.btn-danger { background: var(--red); }
.btn-danger:hover { background: #a62626; }
.btn-secondary { background: #e7edf5; color: var(--navy-2); }
.btn-secondary:hover { background: #d8e2ef; }
.formcard { padding: 20px 22px; max-width: 720px; }
.inline-form { display: inline; }

/* ---------- page connexion ---------- */
.loginwrap { min-height: calc(100vh - 60px); display: flex; align-items: center; justify-content: center; padding: 30px 16px; }
.loginbox { width: 100%; max-width: 400px; padding: 34px 32px 30px; text-align: center; }
.loginbox img.loginlogo { width: 230px; max-width: 80%; margin-bottom: 6px; }
.loginbox h1 { font-size: 19px; margin: 10px 0 20px; }
.loginbox input { max-width: 100%; margin-bottom: 4px; text-align: start; }
.loginbox .btn { width: 100%; margin-top: 16px; }
.loginlangs { margin-top: 18px; display: flex; justify-content: center; gap: 12px; }
.loginlangs button { background: none; border: none; color: var(--blue); cursor: pointer; font-size: 13.5px; }
.loginlangs button.cur { font-weight: 700; text-decoration: underline; }

/* ---------- fiche puits ---------- */
.wellhead { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; margin-bottom: 16px; }
.wellhead .left { display: flex; align-items: center; gap: 14px; }
.wellactions { display: flex; gap: 8px; flex-wrap: wrap; }
.sensorgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; }
.sensorcard { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 13px 16px; }
.sensorcard .name { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 8px; }
.sensorcard .val { font-size: 17px; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ---------- courbes ---------- */
.chartbar { display: flex; gap: 14px; align-items: flex-end; flex-wrap: wrap; padding: 16px 18px; margin-bottom: 16px; }
.chartbar label { margin: 0 0 4px; }
.chartbar .grp { display: flex; flex-direction: column; }
.sensorpicks { display: flex; flex-wrap: wrap; gap: 6px 14px; padding: 12px 18px 16px; }
.sensorpicks label { display: inline-flex; align-items: center; gap: 6px; margin: 0; font-size: 13.5px; color: var(--text); cursor: pointer; }
.chartbox { padding: 16px; }
.chartbox canvas { width: 100% !important; }

/* ---------- onglets ---------- */
.tabs { display: flex; gap: 4px; margin-bottom: 16px; border-bottom: 2px solid var(--border); }
.tabs a { padding: 9px 18px; text-decoration: none; color: var(--muted); font-weight: 600; border-radius: 9px 9px 0 0; }
.tabs a.active { color: var(--navy); background: var(--card); border: 1px solid var(--border); border-bottom: 2px solid var(--card); margin-bottom: -2px; }

/* ---------- admin ---------- */
.adminnav { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 22px; }
.adminnav a { background: var(--card); border: 1px solid var(--border); padding: 8px 16px; border-radius: 999px; text-decoration: none; color: var(--navy-2); font-weight: 600; font-size: 13.5px; }
.adminnav a.active, .adminnav a:hover { background: var(--navy-2); color: #fff; border-color: var(--navy-2); }
.gridcols { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 18px; }
.checkrow { display: flex; align-items: center; gap: 8px; margin: 6px 0; }
.checkrow input { width: auto; }
.hint { color: var(--muted); font-size: 13px; }
.badge { display: inline-block; font-size: 12px; font-weight: 700; padding: 2px 10px; border-radius: 999px; background: #e7edf5; color: var(--navy-2); }
.badge.red { background: #fdeaea; color: #8f1f1f; }
.badge.green { background: #e5f5ec; color: #14683c; }

@media (max-width: 720px) {
  .topbar-inner { gap: 10px; }
  .mainnav { order: 3; width: 100%; }
  .kv { grid-template-columns: 1fr; }
}
