/* ═══════════════════════════════════════════════════════════════
   DigiPark — Styles v1
   Palette : violet doux / bleu ardoise / blanc chaud
   ═══════════════════════════════════════════════════════════════ */

:root {
  --dp-primary:    #7b5ea7;
  --dp-primary-lt: #ede8f5;
  --dp-primary-dk: #5c4380;
  --dp-accent:     #4a90b8;
  --dp-bg:         #faf9fc;
  --dp-surface:    #ffffff;
  --dp-border:     #e2dcef;
  --dp-text:       #2d2536;
  --dp-text-muted: #7a6e88;
  --dp-success:    #3a9e6e;
  --dp-lea-bubble: #ede8f5;
  --dp-user-bubble:#7b5ea7;
  --dp-radius:     1rem;
  --dp-radius-sm:  0.5rem;
  --dp-shadow:     0 2px 12px rgba(123, 94, 167, 0.12);
  --dp-font:       system-ui, -apple-system, 'Segoe UI', sans-serif;
  --dp-font-size:  1.05rem;
  --dp-line:       1.6;
}

/* ── Reset & base ────────────────────────────────────────────── */
.dp-app *,
.dp-app *::before,
.dp-app *::after {
  box-sizing: border-box;
}

.dp-app {
  font-family: var(--dp-font);
  font-size: var(--dp-font-size);
  line-height: var(--dp-line);
  color: var(--dp-text);
  background: var(--dp-bg);
  min-height: 80vh;
  max-width: 720px;
  margin: 0 auto;
  padding: 1rem;
}

/* ── Screens (SPA) ───────────────────────────────────────────── */
.dp-screen {
  display: none;
  animation: dp-fade-in 0.25s ease;
}

.dp-screen--active {
  display: block;
}

@keyframes dp-fade-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Hero (accueil) ──────────────────────────────────────────── */
.dp-hero {
  text-align: center;
  padding: 2rem 1rem 1.5rem;
}

.dp-avatar {
  font-size: 3rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 4.5rem;
  height: 4.5rem;
  border-radius: 50%;
  background: var(--dp-primary-lt);
  margin-bottom: 0.75rem;
}

.dp-avatar--sm {
  font-size: 1.4rem;
  width: 2.4rem;
  height: 2.4rem;
}

.dp-app-title {
  font-size: 2rem;
  font-weight: 700;
  color: var(--dp-primary-dk);
  margin: 0 0 0.25rem;
}

.dp-app-subtitle {
  font-size: 1rem;
  color: var(--dp-text-muted);
  margin: 0;
}

/* ── Saisie prénom ───────────────────────────────────────────── */
.dp-name-section {
  background: var(--dp-surface);
  border: 1px solid var(--dp-border);
  border-radius: var(--dp-radius);
  padding: 1.25rem;
  margin-bottom: 1.25rem;
  box-shadow: var(--dp-shadow);
}

.dp-label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.5rem;
  color: var(--dp-primary-dk);
}

.dp-name-row {
  display: flex;
  gap: 0.5rem;
}

.dp-input {
  flex: 1;
  border: 1.5px solid var(--dp-border);
  border-radius: var(--dp-radius-sm);
  padding: 0.65rem 1rem;
  font-size: 1rem;
  font-family: var(--dp-font);
  color: var(--dp-text);
  background: var(--dp-bg);
  transition: border-color 0.2s;
  outline: none;
}

.dp-input:focus {
  border-color: var(--dp-primary);
}

/* ── Accueil message ─────────────────────────────────────────── */
.dp-welcome-msg {
  background: var(--dp-primary-lt);
  border-radius: var(--dp-radius);
  padding: 1rem 1.25rem;
  margin-bottom: 1.25rem;
  font-size: 1rem;
  color: var(--dp-primary-dk);
  font-style: italic;
}

.dp-welcome-msg p {
  margin: 0;
}

/* ── Menu principal ──────────────────────────────────────────── */
.dp-main-menu {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.dp-menu-title {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--dp-text-muted);
  margin: 0 0 0.25rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 0.85rem;
}

.dp-menu-btn {
  display: grid;
  grid-template-columns: 3rem 1fr;
  grid-template-rows: auto auto;
  column-gap: 0.5rem;
  align-items: center;
  background: var(--dp-surface);
  border: 1.5px solid var(--dp-border);
  border-radius: var(--dp-radius);
  padding: 1rem 1.25rem;
  cursor: pointer;
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
  text-align: left;
  box-shadow: var(--dp-shadow);
}

.dp-menu-btn:hover,
.dp-menu-btn:focus-visible {
  border-color: var(--dp-primary);
  box-shadow: 0 4px 18px rgba(123, 94, 167, 0.2);
  outline: none;
}

.dp-menu-btn:active {
  background: var(--dp-primary-lt);
}

.dp-menu-btn--secondary {
  background: var(--dp-bg);
  border-style: dashed;
}

.dp-menu-icon {
  grid-row: 1 / 3;
  font-size: 1.8rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.dp-menu-label {
  font-weight: 600;
  font-size: 1rem;
  color: var(--dp-text);
}

.dp-menu-desc {
  font-size: 0.85rem;
  color: var(--dp-text-muted);
}

/* ── Boutons généraux ────────────────────────────────────────── */
.dp-btn {
  border: none;
  border-radius: var(--dp-radius-sm);
  padding: 0.65rem 1.25rem;
  font-size: 0.95rem;
  font-family: var(--dp-font);
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, opacity 0.2s;
  white-space: nowrap;
}

.dp-btn:disabled {
  opacity: 0.5;
  cursor: default;
}

.dp-btn--primary {
  background: var(--dp-primary);
  color: #fff;
}

.dp-btn--primary:hover:not(:disabled) {
  background: var(--dp-primary-dk);
}

.dp-btn--secondary {
  background: var(--dp-primary-lt);
  color: var(--dp-primary-dk);
}

.dp-btn--secondary:hover:not(:disabled) {
  background: var(--dp-border);
}

.dp-btn--ghost {
  background: transparent;
  color: var(--dp-text-muted);
  border: 1.5px solid var(--dp-border);
}

.dp-btn--ghost:hover:not(:disabled) {
  background: var(--dp-bg);
}

.dp-btn--lg {
  padding: 0.85rem 2rem;
  font-size: 1.05rem;
  border-radius: var(--dp-radius);
}

/* ── Chat header ─────────────────────────────────────────────── */
.dp-chat-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 0 0.75rem;
  border-bottom: 1px solid var(--dp-border);
  margin-bottom: 0.5rem;
}

.dp-btn-back {
  background: none;
  border: none;
  color: var(--dp-primary);
  font-size: 0.95rem;
  font-family: var(--dp-font);
  font-weight: 600;
  cursor: pointer;
  padding: 0.4rem 0.75rem;
  border-radius: var(--dp-radius-sm);
  white-space: nowrap;
  transition: background 0.2s;
}

.dp-btn-back:hover {
  background: var(--dp-primary-lt);
}

.dp-chat-agent {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex: 1;
}

.dp-chat-agent-name {
  font-weight: 700;
  font-size: 1rem;
  display: block;
  color: var(--dp-text);
}

.dp-chat-mode-label {
  font-size: 0.78rem;
  color: var(--dp-text-muted);
  display: block;
}

.dp-chat-header-right {
  margin-left: auto;
}

/* ── API status badge ────────────────────────────────────────── */
.dp-api-badge {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  letter-spacing: 0.03em;
}

.dp-api-unknown { background: #e5e5e5; color: #888; }
.dp-api-ok      { background: #d4f0e3; color: #1f7a4e; }
.dp-api-error   { background: #fde8e8; color: #b03030; }

/* ── Chat messages area ──────────────────────────────────────── */
.dp-chat-messages {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  padding: 0.5rem 0 1rem;
  min-height: 300px;
  max-height: 58vh;
  overflow-y: auto;
  scroll-behavior: smooth;
}

/* ── Chat bubbles ────────────────────────────────────────────── */
.dp-msg {
  display: flex;
  gap: 0.5rem;
  max-width: 88%;
  animation: dp-fade-in 0.2s ease;
}

.dp-msg--agent {
  align-self: flex-start;
}

.dp-msg--user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.dp-msg-avatar {
  font-size: 1.2rem;
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  background: var(--dp-primary-lt);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.dp-msg-bubble {
  padding: 0.75rem 1rem;
  border-radius: 1rem;
  font-size: 0.97rem;
  line-height: 1.55;
  white-space: pre-wrap;
}

.dp-msg--agent .dp-msg-bubble {
  background: var(--dp-lea-bubble);
  color: var(--dp-text);
  border-bottom-left-radius: 0.2rem;
}

.dp-msg--user .dp-msg-bubble {
  background: var(--dp-user-bubble);
  color: #fff;
  border-bottom-right-radius: 0.2rem;
}

/* Typing indicator */
.dp-msg--typing .dp-msg-bubble {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  min-width: 3rem;
}

.dp-typing-dot {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: var(--dp-primary);
  animation: dp-typing 1.2s infinite;
}

.dp-typing-dot:nth-child(2) { animation-delay: 0.2s; }
.dp-typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes dp-typing {
  0%, 80%, 100% { transform: scale(1); opacity: 0.4; }
  40%           { transform: scale(1.3); opacity: 1; }
}

/* ── Chat input area ─────────────────────────────────────────── */
.dp-chat-input-area {
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
  border-top: 1px solid var(--dp-border);
  padding-top: 0.75rem;
}

.dp-chat-textarea {
  flex: 1;
  border: 1.5px solid var(--dp-border);
  border-radius: var(--dp-radius);
  padding: 0.7rem 1rem;
  font-size: 1rem;
  font-family: var(--dp-font);
  color: var(--dp-text);
  background: var(--dp-bg);
  resize: none;
  outline: none;
  transition: border-color 0.2s;
  line-height: 1.5;
}

.dp-chat-textarea:focus {
  border-color: var(--dp-primary);
}

.dp-btn--send {
  background: var(--dp-primary);
  color: #fff;
  border-radius: 50%;
  width: 2.8rem;
  height: 2.8rem;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  font-size: 1.1rem;
  flex-shrink: 0;
  transition: background 0.2s, transform 0.1s;
}

.dp-btn--send:hover:not(:disabled) {
  background: var(--dp-primary-dk);
}

.dp-btn--send:active:not(:disabled) {
  transform: scale(0.93);
}

/* ── Rapport screen ──────────────────────────────────────────── */
.dp-rapport-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--dp-border);
  margin-bottom: 1.25rem;
}

.dp-rapport-title {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--dp-primary-dk);
  margin: 0;
}

.dp-rapport-body {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  align-items: center;
  text-align: center;
}

.dp-rapport-empty {
  background: var(--dp-primary-lt);
  border-radius: var(--dp-radius);
  padding: 2rem;
  color: var(--dp-primary-dk);
  max-width: 480px;
  width: 100%;
}

.dp-rapport-empty p {
  margin: 0 0 0.5rem;
}

.dp-rapport-actions {
  width: 100%;
  max-width: 360px;
}

.dp-rapport-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  padding: 2rem 0;
  color: var(--dp-text-muted);
}

/* Spinner */
.dp-spinner {
  width: 2.5rem;
  height: 2.5rem;
  border: 3px solid var(--dp-border);
  border-top-color: var(--dp-primary);
  border-radius: 50%;
  animation: dp-spin 0.8s linear infinite;
}

@keyframes dp-spin {
  to { transform: rotate(360deg); }
}

.dp-rapport-result {
  background: var(--dp-surface);
  border: 1px solid var(--dp-border);
  border-radius: var(--dp-radius);
  padding: 1.5rem;
  font-family: var(--dp-font);
  font-size: 0.92rem;
  line-height: 1.65;
  color: var(--dp-text);
  white-space: pre-wrap;
  text-align: left;
  width: 100%;
  overflow-x: auto;
  box-shadow: var(--dp-shadow);
}

.dp-rapport-copy-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  justify-content: center;
  width: 100%;
}

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 480px) {
  .dp-app {
    padding: 0.5rem;
  }

  .dp-app-title {
    font-size: 1.6rem;
  }

  .dp-avatar {
    width: 3.5rem;
    height: 3.5rem;
    font-size: 2.2rem;
  }

  .dp-menu-btn {
    padding: 0.85rem 1rem;
  }

  .dp-chat-messages {
    max-height: 52vh;
  }

  .dp-msg {
    max-width: 95%;
  }
}

/* ── Consentement RGPD ───────────────────────────────────────── */

.dp-consent-overlay {
  position: fixed;
  inset: 0;
  background: rgba(30, 20, 45, 0.75);
  backdrop-filter: blur(4px);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  animation: dp-fade-in 0.3s ease;
}

/* override hidden — l'overlay utilise display:flex */
.dp-consent-overlay[hidden] {
  display: none !important;
}

.dp-consent-box {
  background: var(--dp-surface);
  border-radius: var(--dp-radius);
  box-shadow: 0 8px 40px rgba(0,0,0,0.35);
  padding: 2rem 1.75rem;
  max-width: 560px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
}

.dp-consent-icon {
  font-size: 2.5rem;
  text-align: center;
  margin-bottom: 0.5rem;
}

.dp-consent-title {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--dp-primary-dk);
  text-align: center;
  margin: 0 0 1rem;
}

.dp-consent-intro {
  text-align: center;
  color: var(--dp-text);
  margin-bottom: 1.25rem;
}

.dp-consent-details {
  background: var(--dp-primary-lt);
  border-radius: var(--dp-radius-sm);
  padding: 1rem;
  margin-bottom: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.dp-consent-item {
  display: flex;
  gap: 0.75rem;
  font-size: 0.92rem;
  color: var(--dp-text);
  line-height: 1.5;
}

.dp-consent-item-icon {
  font-size: 1.1rem;
  flex-shrink: 0;
  padding-top: 0.1rem;
}

.dp-consent-warning {
  background: #fff8e1;
  border-left: 3px solid #f9a825;
  border-radius: 0 var(--dp-radius-sm) var(--dp-radius-sm) 0;
  padding: 0.75rem 1rem;
  font-size: 0.9rem;
  color: #5d4037;
  margin-bottom: 1.5rem;
}

.dp-consent-actions {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  align-items: center;
}

.dp-consent-refused {
  margin-top: 1rem;
  text-align: center;
  color: #b03030;
  font-size: 0.92rem;
}

/* ── Purge button ────────────────────────────────────────────── */

.dp-btn--danger-ghost {
  background: transparent;
  border: 1px solid #e0c0c0;
  color: #a04040;
  font-size: 0.82rem;
}

.dp-btn--danger-ghost:hover {
  background: #fde8e8;
  border-color: #c07070;
}

.dp-purge-btn {
  display: block;
  margin: 1.5rem auto 0;
  padding: 0.45rem 1rem;
}

/* ── Footer RGPD ─────────────────────────────────────────────── */

.dp-footer {
  margin-top: 2rem;
  padding: 1rem;
  border-top: 1px solid var(--dp-border);
  text-align: center;
  font-size: 0.8rem;
  color: var(--dp-text-muted);
  line-height: 1.5;
}

.dp-footer-link {
  background: none;
  border: none;
  padding: 0;
  color: var(--dp-accent);
  cursor: pointer;
  text-decoration: underline;
  font-size: inherit;
  font-family: inherit;
}
