/* Metris — style sobre BTP : bleu/gris + accent orange */
:root {
  --bleu: #1d3557;
  --bleu-clair: #457b9d;
  --gris-fond: #f4f5f7;
  --gris-bord: #dfe3e8;
  --gris-texte: #3d4451;
  --orange: #f77f00;
  --orange-fonce: #d96a00;
  --vert: #2a9d5c;
  --rouge: #d62828;
  --blanc: #fff;
  --radius: 8px;
  --ombre: 0 1px 3px rgba(0, 0, 0, 0.08);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  color: var(--gris-texte);
  background: var(--gris-fond);
  font-size: 15px;
  line-height: 1.5;
}

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

h1, h2, h3, h4 { color: var(--bleu); margin: 0 0 .5em; }

button, .btn {
  display: inline-block;
  border: none;
  border-radius: var(--radius);
  padding: .6em 1.2em;
  font-size: 1em;
  cursor: pointer;
  font-weight: 600;
  transition: opacity .15s ease;
}
button:disabled { opacity: .5; cursor: not-allowed; }

.btn-primary, button.btn-primary { background: var(--orange); color: #fff; }
.btn-primary:hover { background: var(--orange-fonce); }
.btn-secondary, button.btn-secondary { background: var(--bleu); color: #fff; }
.btn-secondary:hover { opacity: .9; }
.btn-outline { background: transparent; border: 1px solid var(--gris-bord); color: var(--gris-texte); }
.btn-outline:hover { background: var(--gris-fond); }
.btn-danger { background: var(--rouge); color: #fff; }
.btn-sm { padding: .35em .8em; font-size: .85em; }

input, select, textarea {
  width: 100%;
  padding: .55em .7em;
  border: 1px solid var(--gris-bord);
  border-radius: var(--radius);
  font-size: 1em;
  font-family: inherit;
  background: #fff;
  color: var(--gris-texte);
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--bleu-clair);
}
label { display: block; margin: .8em 0 .3em; font-weight: 600; font-size: .9em; }
form .field { margin-bottom: .5em; }
.hint { font-size: .82em; color: #6b7280; margin-top: .25em; }

.container { max-width: 1120px; margin: 0 auto; padding: 0 20px; }

/* ---------- Landing ---------- */
.landing-header {
  background: var(--bleu);
  color: #fff;
  padding: 18px 0;
}
.landing-header .container { display: flex; align-items: center; justify-content: space-between; }
.logo { font-size: 1.4em; font-weight: 800; color: #fff; letter-spacing: .5px; }
.logo span { color: var(--orange); }
.landing-header nav a { color: #dbe4ee; margin-left: 20px; font-weight: 600; }

.hero {
  background: linear-gradient(135deg, var(--bleu) 0%, #14263c 100%);
  color: #fff;
  padding: 70px 0 90px;
  text-align: center;
}
.hero h1 { color: #fff; font-size: 2.4em; margin-bottom: .3em; }
.hero p.sub { font-size: 1.2em; color: #cbd8e6; max-width: 640px; margin: 0 auto 1.6em; }
.hero .badge-prix {
  display: inline-block;
  background: var(--orange);
  color: #fff;
  padding: .4em 1em;
  border-radius: 999px;
  font-weight: 700;
  margin-bottom: 1.6em;
}

/* ---------- Scène de chantier animée (hero) ---------- */
.chantier-scene {
  position: relative;
  height: 90px;
  margin-top: 2.4em;
  overflow: hidden;
}
.dozer-wrap {
  position: absolute;
  bottom: 8px;
  left: -180px;
  animation: dozer-drive 14s linear infinite;
}
@keyframes dozer-drive {
  0%   { left: -180px; }
  60%  { left: calc(50% - 75px); }
  75%  { left: calc(50% - 75px); }
  100% { left: calc(100% + 20px); }
}
.dozer-blade {
  transform-origin: 138px 66px;
  animation: dozer-blade-work 14s linear infinite;
}
@keyframes dozer-blade-work {
  0%, 55% { transform: rotate(0deg); }
  60%, 63%, 66%, 69%, 72% { transform: rotate(-4deg) translateX(-2px); }
  61%, 64%, 67%, 70%, 73% { transform: rotate(2deg) translateX(1px); }
  75%, 100% { transform: rotate(0deg); }
}
.dozer-dust { opacity: 0; }
.chantier-scene .dozer-wrap .dozer-dust { animation: dozer-dust-show 14s linear infinite; }
@keyframes dozer-dust-show {
  0%, 58% { opacity: 0; }
  60%, 72% { opacity: .9; }
  75%, 100% { opacity: 0; }
}
.dust { animation: dust-puff 1.1s ease-in-out infinite; }
.dust.d2 { animation-delay: .2s; }
.dust.d3 { animation-delay: .4s; }
@keyframes dust-puff {
  0% { transform: translateY(0) scale(.7); opacity: .5; }
  50% { transform: translateY(-6px) scale(1.1); opacity: .95; }
  100% { transform: translateY(-10px) scale(.6); opacity: 0; }
}
@media (max-width: 700px) {
  .chantier-scene { display: none; }
}

.features {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 22px;
  padding: 60px 0;
}
.feature-card {
  background: #fff;
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--ombre);
  border-top: 3px solid var(--orange);
}
.feature-card h3 { font-size: 1.05em; }
.feature-card p { color: #5b6472; font-size: .93em; margin: 0; }

.ia-highlight {
  background: #fff4e8;
  border: 1px solid #ffd9a8;
  border-radius: var(--radius);
  padding: 30px;
  margin: 40px 0;
  display: flex;
  gap: 24px;
  align-items: center;
  flex-wrap: wrap;
}
.ia-highlight .badge-ia {
  background: var(--orange);
  color: #fff;
  font-weight: 700;
  padding: .3em .8em;
  border-radius: 6px;
  font-size: .8em;
  letter-spacing: .5px;
}
.ia-highlight h2 { margin-top: .3em; }

.auth-panels {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  padding: 40px 0 80px;
}
@media (max-width: 780px) {
  .auth-panels { grid-template-columns: 1fr; }
  .hero h1 { font-size: 1.8em; }
}
.panel {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--ombre);
  padding: 26px;
}
.panel h2 { font-size: 1.15em; }

.msg { padding: 10px 14px; border-radius: var(--radius); margin: 10px 0; font-size: .92em; }
.msg-success { background: #e6f5ec; color: var(--vert); border: 1px solid #b8e6cb; }
.msg-error { background: #fbe7e7; color: var(--rouge); border: 1px solid #f3bcbc; }
.msg-info { background: #e8f1f8; color: var(--bleu-clair); border: 1px solid #bcdcf3; }

footer.landing-footer {
  background: #14263c;
  color: #93a3b8;
  text-align: center;
  padding: 24px 0;
  font-size: .85em;
}

/* ---------- Auth pages (connexion/abonnement) ---------- */
.center-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--gris-fond);
}
.center-box {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--ombre);
  padding: 40px;
  max-width: 420px;
  width: 92%;
  text-align: center;
}
.center-box .logo { color: var(--bleu); display: block; margin-bottom: 12px; }
.spinner {
  width: 34px; height: 34px;
  border: 3px solid var(--gris-bord);
  border-top-color: var(--orange);
  border-radius: 50%;
  margin: 20px auto;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- App shell ---------- */
.app-shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 220px;
  background: var(--bleu);
  color: #fff;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}
.sidebar .logo { padding: 20px 18px; border-bottom: 1px solid rgba(255,255,255,.12); }
.sidebar nav { flex: 1; overflow-y: auto; padding: 10px 0; }
.sidebar nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 20px;
  color: #cfdbe9;
  font-weight: 600;
  font-size: .93em;
  border-left: 3px solid transparent;
}
.sidebar nav a:hover { background: rgba(255,255,255,.06); text-decoration: none; }
.sidebar nav a.active { color: #fff; border-left-color: var(--orange); background: rgba(255,255,255,.08); }
.nav-icon { color: var(--orange); flex-shrink: 0; }
.nav-icon-slot { display: inline-flex; }
.sidebar .user-box {
  padding: 14px 18px;
  border-top: 1px solid rgba(255,255,255,.12);
  font-size: .82em;
  color: #b7c6d9;
}
.sidebar .user-box .role { color: var(--orange); font-weight: 700; }
.sidebar .logout { display: block; margin-top: 8px; color: #f0b8b8; font-weight: 600; cursor: pointer; }

.app-main { flex: 1; min-width: 0; padding: 26px 32px; }
.app-main h1 { font-size: 1.5em; }
.topbar-row { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; margin-bottom: 18px; }

@media (max-width: 860px) {
  .app-shell { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; flex-direction: row; flex-wrap: wrap; }
  .sidebar .logo { width: 100%; }
  .sidebar nav { display: flex; flex-wrap: wrap; padding: 4px; }
  .sidebar nav a { border-left: none; border-bottom: 3px solid transparent; padding: 8px 12px; }
  .sidebar nav a.active { border-left: none; border-bottom-color: var(--orange); }
  .sidebar .user-box { width: 100%; }
  .app-main { padding: 18px; }
}

.card { background: #fff; border-radius: var(--radius); box-shadow: var(--ombre); padding: 20px; margin-bottom: 20px; }
.card h2, .card h3 { margin-top: 0; }

table { width: 100%; border-collapse: collapse; font-size: .92em; }
table th, table td { padding: 9px 10px; text-align: left; border-bottom: 1px solid var(--gris-bord); }
table th { color: #6b7280; font-size: .82em; text-transform: uppercase; letter-spacing: .03em; }
table tr:hover td { background: #fafbfc; }
table.clickable tr { cursor: pointer; }

.badge {
  display: inline-block;
  padding: .2em .7em;
  border-radius: 999px;
  font-size: .78em;
  font-weight: 700;
}
.badge-gris { background: #eceff2; color: #6b7280; }
.badge-bleu { background: #e0ecf5; color: var(--bleu-clair); }
.badge-vert { background: #e0f4e6; color: var(--vert); }
.badge-orange { background: #fdecd8; color: var(--orange-fonce); }
.badge-rouge { background: #fbe1e1; color: var(--rouge); }

.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.toolbar select, .toolbar input { width: auto; min-width: 160px; }

.tabs { display: flex; gap: 4px; border-bottom: 2px solid var(--gris-bord); margin-bottom: 18px; flex-wrap: wrap; }
.tabs button {
  background: none; color: #6b7280; border-radius: 0;
  padding: 8px 16px; font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -2px;
}
.tabs button.active { color: var(--bleu); border-bottom-color: var(--orange); }

.modal-overlay {
  position: fixed; inset: 0; background: rgba(20,38,60,.55);
  display: flex; align-items: flex-start; justify-content: center;
  overflow-y: auto; padding: 40px 16px; z-index: 200;
}
.modal-box {
  background: #fff; border-radius: var(--radius); padding: 26px;
  max-width: 560px; width: 100%; box-shadow: 0 8px 30px rgba(0,0,0,.25);
}
.modal-box .modal-header { display: flex; justify-content: space-between; align-items: center; }
.modal-box .modal-close { cursor: pointer; font-size: 1.4em; color: #9aa3ad; line-height: 1; background: none; border: none; padding: 0; }

.alert-box {
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 10px;
  font-size: .92em;
  border: 1px solid transparent;
}
.alert-rouge { background: #fbe1e1; border-color: #f3bcbc; color: #8a1f1f; }
.alert-orange { background: #fdecd8; border-color: #ffd9a8; color: #8a4b00; }

.empty-state { text-align: center; color: #9aa3ad; padding: 40px 0; }
.loading { text-align: center; color: #9aa3ad; padding: 30px 0; }

.ligne-row { display: grid; grid-template-columns: 3fr 1fr 1fr 1.2fr auto; gap: 8px; align-items: center; margin-bottom: 8px; }
@media (max-width: 700px) { .ligne-row { grid-template-columns: 1fr 1fr; } }

.kpi-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 16px; margin-bottom: 20px; }
.kpi { background: #fff; border-radius: var(--radius); box-shadow: var(--ombre); padding: 16px 18px; }
.kpi .val { font-size: 1.5em; font-weight: 800; color: var(--bleu); }
.kpi .lbl { font-size: .82em; color: #6b7280; }

.ia-box {
  background: #fff4e8; border: 1px solid #ffd9a8; border-radius: var(--radius);
  padding: 18px; margin-bottom: 18px;
}
.ia-box textarea { min-height: 90px; }

pre.markdown-ia { white-space: pre-wrap; font-family: inherit; background: #fafbfc; padding: 14px; border-radius: var(--radius); border: 1px solid var(--gris-bord); }

/* ---------- Notes d'aide ---------- */
.help-note {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: #eaf2f8;
  border: 1px solid #bcdcf3;
  border-radius: var(--radius);
  padding: 10px 14px;
  margin-bottom: 16px;
  font-size: .88em;
  color: var(--bleu);
}
.help-note .help-icon { flex-shrink: 0; font-size: 1.05em; line-height: 1.4; }
.help-note .help-text { flex: 1; line-height: 1.45; }
.help-note .help-close {
  flex-shrink: 0;
  background: none;
  border: none;
  padding: 0 2px;
  margin: 0;
  color: var(--bleu-clair);
  font-size: 1.2em;
  line-height: 1;
  cursor: pointer;
  font-weight: 400;
}
.help-note .help-close:hover { color: var(--bleu); }

.help-reset-link {
  display: block;
  margin-top: 8px;
  color: #8fa8c2;
  font-size: .92em;
  cursor: pointer;
  text-decoration: underline;
}
.help-reset-link:hover { color: #fff; }

@media (max-width: 860px) {
  .help-note { font-size: .85em; }
}
@media (max-width: 700px) {
  .help-note { padding: 8px 10px; gap: 8px; }
}
