/* =========================================================
   PROBITUS_IA DOC DGTCP-CI
   Système de design institutionnel — autonome, sans framework
   ========================================================= */

:root {
  --green:        #1F6B34;
  --green-dark:   #16542A;
  --green-soft:   #EAF3EA;
  --gold:         #E08A1E;
  --gold-dark:    #B86F12;

  --bg:           #F5F8F3;
  --surface:      #FFFFFF;
  --border:       #DCE5DA;
  --text:         #1E2A1E;
  --muted:        #5C6B5E;

  --success:      #1F7A33;
  --success-bg:   #E6F5E8;
  --success-br:   #A9D8AD;
  --danger:       #9A2C18;
  --danger-bg:    #FCE9E3;
  --danger-br:    #F0B5A4;

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-doc: Georgia, "Times New Roman", serif;
  --radius:    14px;
  --radius-lg: 18px;
  --shadow-sm: 0 4px 14px rgba(0,0,0,.05);
  --shadow:    0 6px 22px rgba(0,0,0,.07);
  --focus:     0 0 0 3px rgba(224,138,30,.35);
}

* { box-sizing: border-box; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); background: var(--bg); color: var(--text); line-height: 1.55; }
a { color: var(--green); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- En-tête / Topbar ---------- */
.topbar {
  display: flex; justify-content: space-between; align-items: center; gap: 1rem;
  padding: .9rem 2rem; background: var(--surface); border-bottom: 4px solid var(--green);
  box-shadow: 0 2px 8px rgba(0,0,0,.06); position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; align-items: center; gap: .75rem; }
.brand strong { font-size: 1.05rem; line-height: 1.15; color: var(--text); }
.brand small { display: block; color: var(--muted); margin-top: .15rem; font-size: .8rem; }
.emblem {
  display: inline-flex; align-items: center; justify-content: center; width: 46px; height: 46px;
  border-radius: 50%; background: linear-gradient(135deg, var(--green), var(--gold));
  color: #fff; font-weight: 800; letter-spacing: .5px; flex-shrink: 0;
}
.brand-logo { height: 50px; width: auto; display: block; flex-shrink: 0; }

/* ---------- Navigation ---------- */
nav { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; }
nav a { font-weight: 700; font-size: .95rem; color: var(--text); padding: .5rem .7rem; border-radius: 8px; border-bottom: 3px solid transparent; transition: background .15s, border-color .15s; }
nav a:hover { background: var(--green-soft); text-decoration: none; }
nav a.active, nav a[aria-current="page"] { color: var(--green-dark); border-bottom-color: var(--gold); }
nav a.logout { color: var(--danger); }
.nav-toggle { display: none; background: none; border: 1px solid var(--border); border-radius: 8px; padding: .5rem .7rem; cursor: pointer; color: var(--green-dark); font-size: 1.2rem; line-height: 1; }
.nav-group { position: relative; }
.nav-group-btn { background: none; border: 0; font: inherit; font-weight: 700; font-size: .95rem; color: var(--text); padding: .5rem .7rem; border-radius: 8px; cursor: pointer; min-height: 0; }
.nav-group-btn:hover { background: var(--green-soft); }
.nav-sub { display: none; position: absolute; top: 100%; left: 0; min-width: 230px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow); padding: .3rem; z-index: 30; }
.nav-group:hover .nav-sub, .nav-group:focus-within .nav-sub, .nav-group.open .nav-sub { display: block; }
.nav-sub a { display: block; border-bottom: 0; border-radius: 6px; }
.nav-account { margin-left: auto; }
.nav-account .nav-sub { left: auto; right: 0; }

/* ---------- Layout ---------- */
.container { max-width: 1180px; margin: 0 auto; padding: 2rem; }
.footer { text-align: center; color: var(--muted); padding: 2rem 1.5rem; font-size: .85rem; }
.footer .copyright { margin: 0 0 .3rem; font-weight: 700; color: var(--green-dark); }
.footer .legal { margin: 0; font-size: .78rem; max-width: 760px; margin-left: auto; margin-right: auto; line-height: 1.45; }
h1 { color: var(--green-dark); font-size: 1.8rem; font-weight: 800; margin: 0 0 .75rem; }
h2 { color: var(--green); font-size: 1.3rem; margin: 0 0 .5rem; }
.muted { color: var(--muted); }
.page-title { margin-bottom: 1rem; }

/* ---------- Cartes ---------- */
.cards, .admin-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 1rem; }
.card { background: var(--surface); border-radius: var(--radius-lg); padding: 1.25rem; box-shadow: var(--shadow); border: 1px solid var(--border); }
.card--action { border-top: 4px solid var(--gold); }

/* ---------- Boutons ---------- */
button, .button-link { display: inline-block; border: 0; border-radius: 10px; padding: .8rem 1.1rem; background: var(--green); color: #fff; font: inherit; font-weight: 700; font-size: .95rem; cursor: pointer; transition: background .15s; text-align: center; min-height: 44px; }
button:hover, .button-link:hover { background: var(--green-dark); color: #fff; text-decoration: none; }
button:focus-visible, .button-link:focus-visible, input:focus, select:focus, textarea:focus { outline: none; box-shadow: var(--focus); }
.btn-accent { background: var(--gold); }
.btn-accent:hover { background: var(--gold-dark); }
.btn-ghost { background: transparent; color: var(--green-dark); border: 1.5px solid var(--green); }
.btn-ghost:hover { background: var(--green-soft); color: var(--green-dark); }
.btn-danger { background: var(--danger); }
button.small { padding: .45rem .65rem; font-size: .9rem; min-height: 0; }

/* ---------- Formulaires ---------- */
.form { display: grid; gap: .8rem; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem 1rem; }
.form-grid .full { grid-column: 1 / -1; }
.form label, .form-grid label { font-weight: 700; font-size: .9rem; }
input, select, textarea { width: 100%; padding: .8rem 1rem; font: inherit; border: 1px solid #C9D6C9; border-radius: 10px; background: #fff; color: var(--text); }
.checkbox { display: flex; gap: .6rem; align-items: center; }
.checkbox input { width: auto; }

/* ---------- Cartes d'authentification ---------- */
.login-card { max-width: 460px; margin: 5vh auto; background: var(--surface); padding: 2rem; border-radius: var(--radius-lg); box-shadow: 0 12px 34px rgba(0,0,0,.09); border-top: 5px solid var(--gold); }
.auth-card { max-width: 640px; }
.auth-head { text-align: center; margin-bottom: 1rem; }
.auth-head .brand-logo, .auth-head .emblem { margin: 0 auto .5rem; }
.auth-foot { margin-top: 1rem; font-size: .9rem; color: var(--muted); text-align: center; }

/* ---------- Alertes ---------- */
.alert, .success { padding: .9rem 1rem; border-radius: 12px; margin: 1rem 0; font-size: .95rem; }
.alert { background: var(--danger-bg); border: 1px solid var(--danger-br); color: var(--danger); }
.success { background: var(--success-bg); border: 1px solid var(--success-br); color: var(--success); }

/* ---------- Recherche ---------- */
.inline-form, .searchbar { display: flex; gap: .7rem; align-items: center; }
.searchbar { margin: 1rem 0 1.5rem; }
.searchbar input { flex: 1; }

/* ---------- Listes ---------- */
.list { display: grid; gap: .75rem; }
.list-item { display: grid; gap: .4rem; background: var(--surface); padding: 1rem; border: 1px solid var(--border); border-left: 5px solid var(--green); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.list-item span { color: var(--muted); line-height: 1.45; }
.back { display: inline-block; margin-bottom: 1rem; font-weight: 700; }

/* ---------- Documents & PDF ---------- */
.document-page { background: var(--surface); border-radius: var(--radius-lg); padding: 1.5rem; box-shadow: var(--shadow); }
.document-page pre { white-space: pre-wrap; word-wrap: break-word; font-family: var(--font-doc); line-height: 1.6; font-size: 1.02rem; }
.pdf-frame { background: var(--surface); border-radius: var(--radius); padding: .5rem; box-shadow: var(--shadow); border: 1px solid var(--border); margin: 1rem 0; }
.pdf-frame iframe { width: 100%; height: 80vh; border: 0; border-radius: 8px; display: block; }

/* ---------- Bandeau PROBITUS (hero) ---------- */
.probitus-hero {
  position: relative; overflow: hidden;
  background: linear-gradient(135deg, #1F6B34 0%, #2C8C46 55%, #E08A1E 100%);
  color: #fff; border-radius: var(--radius-lg); padding: 1.6rem 1.7rem; margin-bottom: 1.2rem;
  display: flex; gap: 1.3rem; align-items: center; box-shadow: var(--shadow);
}
.probitus-hero::after {
  content: ""; position: absolute; right: -40px; top: -40px; width: 180px; height: 180px;
  background: rgba(255,255,255,.08); border-radius: 50%;
}
.probitus-hero > * { position: relative; z-index: 1; }
.probitus-hero .avatar, .probitus-hero .avatar-img {
  width: 76px; height: 76px; border-radius: 50%; flex-shrink: 0;
  background: #fff; box-shadow: 0 4px 12px rgba(0,0,0,.18);
  display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 2rem; color: var(--green);
}
.avatar-wrap { position: relative; display: inline-flex; flex-shrink: 0; }
.avatar-wrap::after {
  content: ""; position: absolute; inset: 0; border-radius: 50%; pointer-events: none;
  animation: probitus-pulse 2.6s ease-out infinite;
}
.avatar-wrap::after { animation: probitus-pulse 1.6s ease-out infinite; }
.probitus-avatar-svg { animation: probitus-float 1.9s ease-in-out infinite; transform-origin: 50% 60%; }
.probitus-check { stroke-dasharray: 64; animation: probitus-draw 1.9s ease-in-out infinite; }
@keyframes probitus-float {
  0%, 100% { transform: translateY(0) scale(1) rotate(0deg); }
  30% { transform: translateY(-9px) scale(1.06) rotate(-4deg); }
  60% { transform: translateY(-2px) scale(1.02) rotate(4deg); }
}
@keyframes probitus-pulse {
  0% { box-shadow: 0 0 0 0 rgba(224,138,30,.6); }
  70% { box-shadow: 0 0 0 20px rgba(224,138,30,0); }
  100% { box-shadow: 0 0 0 0 rgba(224,138,30,0); }
}
@keyframes probitus-draw { 0% { stroke-dashoffset: 64; } 30% { stroke-dashoffset: 0; } 80% { stroke-dashoffset: 0; } 100% { stroke-dashoffset: 64; } }
@media (prefers-reduced-motion: reduce) {
  .probitus-avatar-svg, .avatar-wrap::after, .probitus-check { animation: none; }
}
.probitus-hero h1 { color: #fff; margin: 0 0 .2rem; font-size: 1.7rem; letter-spacing: .5px; }
.probitus-hero .slogan { font-style: italic; font-weight: 700; margin: 0 0 .5rem; opacity: .97; }
.probitus-hero .desc { font-size: .92rem; line-height: 1.5; margin: 0; opacity: .96; }
@media (max-width: 600px) { .probitus-hero { flex-direction: column; text-align: center; padding: 1.2rem; } }

/* ---------- Chat PROBITUS ---------- */
.chat { display: flex; flex-direction: column; gap: .8rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; min-height: 320px; max-height: 60vh; overflow-y: auto; margin: 1rem 0; }
.chat-msg { display: flex; }
.chat-msg.user { justify-content: flex-end; }
.chat-msg .bubble { max-width: 80%; padding: .75rem 1rem; border-radius: var(--radius); line-height: 1.5; }
.chat-msg.assistant .bubble { background: var(--green-soft); color: var(--text); border-top-left-radius: 4px; }
.chat-msg.user .bubble { background: var(--green); color: #fff; border-top-right-radius: 4px; }
.chat-msg .sources { margin-top: .5rem; font-size: .85rem; color: var(--green-dark); }
.chat-msg.assistant .sources a { font-weight: 700; }

/* ---------- Tableaux admin ---------- */
table { width: 100%; border-collapse: collapse; background: var(--surface); border-radius: var(--radius); overflow: hidden; }
th, td { padding: .75rem; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
th { background: var(--green-soft); color: var(--green-dark); font-size: .9rem; }
tbody tr:nth-child(even) { background: #FAFCF9; }
tbody tr:hover { background: var(--green-soft); }
.badge { display: inline-block; background: var(--gold); color: #fff; border-radius: 999px; padding: .25rem .6rem; font-size: .82rem; font-weight: 700; }
.badge--ok { background: var(--success); }
.badge--wait { background: var(--gold); }

/* ---------- Responsive / mobile (PWA) ---------- */
@media (max-width: 760px) {
  .topbar { padding: .8rem 1rem; }
  .nav-toggle { display: inline-block; }
  nav { display: none; flex-direction: column; align-items: stretch; position: absolute; top: 100%; left: 0; right: 0; background: var(--surface); border-bottom: 4px solid var(--green); box-shadow: var(--shadow); padding: .5rem; gap: .25rem; }
  nav.open { display: flex; }
  nav a { padding: .85rem 1rem; border-bottom: 1px solid var(--border); border-radius: 8px; }
  nav a.active, nav a[aria-current="page"] { background: var(--green-soft); border-bottom-color: var(--green-soft); }
  .nav-group { width: 100%; }
  .nav-group-btn { width: 100%; text-align: left; padding: .85rem 1rem; }
  .nav-sub { position: static; box-shadow: none; border: 0; border-radius: 0; padding: 0 0 .3rem 1rem; }
  .nav-account { margin-left: 0; }
  .nav-account .nav-sub { right: auto; }
  .container { padding: 1rem; }
  .form-grid { grid-template-columns: 1fr; }
  .inline-form, .searchbar { flex-direction: column; align-items: stretch; }
  .searchbar button, .searchbar .button-link { width: 100%; }
  .chat-msg .bubble { max-width: 92%; }
  table, thead, tbody, th, td, tr { display: block; }
  thead { display: none; }
  tbody tr { margin-bottom: .8rem; border: 1px solid var(--border); border-radius: var(--radius); padding: .5rem; }
  td { border: 0; padding: .4rem .5rem; }
  td::before { content: attr(data-label); display: block; font-weight: 700; color: var(--green-dark); font-size: .8rem; }
}
