/* ========================================
   PALETTE PERSTIL
   #17467c  bleu marine (primaire)
   #00aeef  bleu cyan (accent)
   #f17d26  orange (action / chaud)
   #ffffff  blanc
   ======================================== */

:root {
  --perstil-marine: #17467c;
  --perstil-marine-dark: #0f3158;
  --perstil-marine-light: #2563a8;
  --perstil-cyan: #00aeef;
  --perstil-cyan-dark: #0090c8;
  --perstil-orange: #f17d26;
  --perstil-orange-dark: #d96514;
  --perstil-orange-light: #ff9d56;

  --bg: #f8fafc;
  --bg-soft: #ffffff;
  --bg-card: #ffffff;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --text: #0f172a;
  --text-soft: #475569;
  --text-mute: #94a3b8;

  --success: #16a34a;
  --success-soft: #dcfce7;
  --danger: #dc2626;
  --danger-soft: #fee2e2;
  --warning: #f59e0b;
  --warning-soft: #fef3c7;
}

html, body { -webkit-tap-highlight-color: transparent; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, sans-serif;
  background: var(--bg);
  color: var(--text);
}

/* ===== Header / branding ===== */
.perstil-header {
  background: linear-gradient(135deg, var(--perstil-marine) 0%, var(--perstil-marine-dark) 100%);
  color: white;
  box-shadow: 0 2px 12px rgba(23, 70, 124, .15);
}
.perstil-header .perstil-sub { color: rgba(255,255,255,.7); }
.perstil-logo { height: 44px; width: auto; }
.perstil-logo-lg { height: 90px; width: auto; }

/* ===== Onglets ===== */
.tab-active {
  background: white;
  color: var(--perstil-marine);
  border: 2px solid white;
  font-weight: 700;
  box-shadow: 0 4px 12px rgba(0,0,0,.1);
}
.tab-inactive {
  background: rgba(255,255,255,.1);
  color: rgba(255,255,255,.8);
  border: 2px solid rgba(255,255,255,.2);
}
.tab-inactive:hover { background: rgba(255,255,255,.2); }

/* ===== Badges ===== */
.badge-prio {
  background: linear-gradient(135deg, var(--perstil-orange), var(--perstil-orange-dark));
  color: white;
}
.badge-alerte {
  background: var(--danger);
  animation: pulse 2s infinite;
}
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .5; } }

/* ===== Boutons ===== */
.btn {
  padding: .55rem 1.05rem;
  border-radius: .65rem;
  font-weight: 500;
  font-size: .92rem;
  transition: all .15s;
  cursor: pointer;
  border: 1px solid transparent;
  display: inline-flex; align-items: center; gap: .35rem;
}
.btn-primary {
  background: var(--perstil-marine);
  color: white;
}
.btn-primary:hover { background: var(--perstil-marine-dark); transform: translateY(-1px); }

.btn-accent {
  background: var(--perstil-orange);
  color: white;
}
.btn-accent:hover { background: var(--perstil-orange-dark); transform: translateY(-1px); }

.btn-danger {
  background: var(--danger);
  color: white;
}
.btn-danger:hover { background: #b91c1c; }

.btn-ghost {
  background: white;
  color: var(--perstil-marine);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: #f1f5f9; border-color: var(--perstil-marine); }

.btn-success {
  background: var(--success);
  color: white;
}
.btn-success:hover { background: #15803d; }

/* ===== Inputs ===== */
input, select, textarea {
  background: white !important;
  border: 1px solid var(--border-strong) !important;
  color: var(--text) !important;
  border-radius: .65rem;
  padding: .625rem .875rem;
  outline: none;
  width: 100%;
  font-size: .95rem;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--perstil-marine) !important;
  box-shadow: 0 0 0 3px rgba(23, 70, 124, .15);
}
input::placeholder, textarea::placeholder { color: var(--text-mute); }

/* ===== Cards ===== */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: .9rem;
  padding: 1.25rem;
  box-shadow: 0 1px 3px rgba(15, 23, 42, .04);
  transition: box-shadow .15s, border-color .15s;
}
.card:hover { box-shadow: 0 4px 16px rgba(15, 23, 42, .08); }

.stat-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: .9rem;
  padding: 1rem 1.25rem;
  position: relative;
  overflow: hidden;
}
.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; bottom: 0;
  width: 4px;
  background: var(--perstil-marine);
}
.stat-card.accent::before { background: var(--perstil-orange); }
.stat-card.cyan::before { background: var(--perstil-cyan); }
.stat-card.danger::before { background: var(--danger); }

/* ===== Tables ===== */
table { width: 100%; border-collapse: collapse; }
th {
  text-align: left; padding: .75rem;
  font-weight: 600;
  color: var(--text-soft);
  font-size: .82rem;
  text-transform: uppercase;
  letter-spacing: .03em;
  border-bottom: 2px solid var(--border);
  background: #f8fafc;
}
td {
  padding: .85rem .75rem;
  border-bottom: 1px solid var(--border);
  font-size: .92rem;
}
tr:hover td { background: rgba(23, 70, 124, .03); }

/* ===== Toasts ===== */
.toast {
  position: fixed; bottom: 1.5rem; left: 50%; transform: translateX(-50%);
  background: var(--perstil-marine); color: white;
  padding: .875rem 1.5rem;
  border-radius: .75rem;
  z-index: 1000;
  box-shadow: 0 10px 25px rgba(15, 23, 42, .25);
  max-width: 90vw;
  font-weight: 500;
}
.toast-success { background: var(--success); }
.toast-error { background: var(--danger); }

/* ===== Modal ===== */
.modal-bg {
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, .55);
  backdrop-filter: blur(2px);
  z-index: 100;
  display: flex; align-items: center; justify-content: center;
  padding: 1rem;
}
.modal {
  background: white;
  border-radius: 1rem;
  max-width: 32rem;
  width: 100%;
  max-height: 90vh;
  overflow: auto;
  padding: 1.5rem;
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
}

/* ===== Resultat OK / KO ===== */
.result-ok {
  background: var(--success-soft);
  border: 1px solid #86efac;
  color: #166534;
  padding: .85rem 1rem;
  border-radius: .75rem;
}
.result-ko {
  background: var(--danger-soft);
  border: 1px solid #fca5a5;
  color: #991b1b;
  padding: .85rem 1rem;
  border-radius: .75rem;
}
.result-warn {
  background: var(--warning-soft);
  border: 1px solid #fcd34d;
  color: #92400e;
  padding: .85rem 1rem;
  border-radius: .75rem;
}

/* ===== Responsive table → cartes sur mobile ===== */
@media (max-width: 640px) {
  table thead { display: none; }
  table, tbody, tr, td { display: block; width: 100%; }
  tr {
    background: white;
    border: 1px solid var(--border);
    border-radius: .75rem;
    margin-bottom: .75rem;
    padding: .5rem;
    box-shadow: 0 1px 3px rgba(0,0,0,.04);
  }
  td { border: none; padding: .4rem .5rem; }
  td::before {
    content: attr(data-label) " : ";
    font-weight: 600;
    color: var(--text-soft);
  }
}

.empty {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-mute);
}

.spinner {
  display: inline-block;
  width: 1rem; height: 1rem;
  border: 2px solid rgba(23, 70, 124, .2);
  border-top-color: var(--perstil-marine);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== Type pill DTF ===== */
.pill-coeur { background: #fce7f3; color: #be185d; padding: .15rem .55rem; border-radius: .4rem; font-size: .78rem; font-weight: 600; }
.pill-dos { background: #dbeafe; color: var(--perstil-marine); padding: .15rem .55rem; border-radius: .4rem; font-size: .78rem; font-weight: 600; }
.pill-autre { background: #f1f5f9; color: #475569; padding: .15rem .55rem; border-radius: .4rem; font-size: .78rem; font-weight: 600; }

/* ===== Chat principal ===== */
.chat-main {
  padding: 1.5rem;
  box-shadow: 0 4px 24px rgba(23, 70, 124, .08);
  border: 1px solid #dbeafe;
}
.chat-messages {
  min-height: 280px;
  max-height: 60vh;
  overflow-y: auto;
  padding: .5rem .25rem;
  background: linear-gradient(180deg, #fafbfc 0%, #ffffff 100%);
  border-radius: .75rem;
  border: 1px solid var(--border);
}
.chat-main input {
  font-size: 1rem;
  padding: .8rem 1rem;
}
.chat-main form .btn {
  padding: .8rem 1.4rem;
  font-weight: 600;
}

/* ===== Chat assistant ===== */
.chat-row {
  display: flex;
  flex-direction: column;
  margin-bottom: .4rem;
}
.chat-row-user { align-items: flex-end; }
.chat-row-bot { align-items: flex-start; }
.chat-author {
  font-size: .72rem;
  font-weight: 600;
  color: var(--perstil-marine);
  background: rgba(23, 70, 124, .08);
  padding: .1rem .55rem;
  border-radius: .65rem;
  margin-bottom: .15rem;
  letter-spacing: .02em;
}
.chat-bubble {
  padding: .7rem 1rem;
  border-radius: 1rem;
  max-width: 85%;
  font-size: .95rem;
  line-height: 1.4;
  word-wrap: break-word;
  animation: bubblePop .2s ease-out;
}
@keyframes bubblePop {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}
.chat-user {
  background: var(--perstil-marine);
  color: white;
  margin-left: auto;
  border-bottom-right-radius: .35rem;
}
.chat-bot {
  background: #f1f5f9;
  color: var(--text);
  margin-right: auto;
  border-bottom-left-radius: .35rem;
  border-left: 3px solid var(--perstil-orange);
}
.chat-bot strong { color: var(--perstil-marine); }
.chat-loading { opacity: .7; }
.chat-actions {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
  margin: .35rem 0 .35rem 0;
  padding-left: .5rem;
}
.chat-actions .btn { padding: .35rem .75rem; }

/* ===== Footer Perstil ===== */
.perstil-footer {
  margin-top: 3rem;
  padding: 1.5rem 0;
  border-top: 1px solid var(--border);
  text-align: center;
  color: var(--text-mute);
  font-size: .85rem;
}
