/* ====== BASE PAGE STYLES ====== */
:root {
  --bg: #f6faf7;
  --card: #ffffff;
  --accent: #0ec27c;
  --accent-dark: #0a7d4e;
  --glass: rgba(255, 255, 255, 0.85);
  --shadow: 0 10px 28px rgba(7, 18, 14, 0.08);
  --radius: 16px;
}

body {
  font-family: 'Poppins', sans-serif;
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 15% 20%, rgba(14, 194, 124, 0.08), transparent 40%),
    radial-gradient(circle at 85% 10%, rgba(10, 125, 78, 0.08), transparent 35%),
    var(--bg);
}

.glass {
  background: var(--glass);
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow);
}

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.chip {
  background: rgba(14, 194, 124, 0.12);
  color: var(--accent-dark);
  padding: 4px 10px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.75rem;
}

.btn-retour {
  background-color: #0ec27c;
  color: #fff;
  padding: 6px 14px;
  border: none;
  border-radius: 999px;
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 600;
}

.btn-retour:hover {
  background-color: #0a7d4e;
}

.cta-compact {
  padding: 0;
  font-size: inherit;
  border-radius: inherit;
}

#fileDrop {
  cursor: pointer;
}

/* ====== LAYOUT GLOBAL DE LA DEMO ====== */

.demo-container {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
  gap: 32px;
  align-items: stretch;
  margin-top: 24px;
}

/* Carte générique (gauche & droite) */
.demo-card {
  background: var(--card, #ffffff);
  border-radius: 22px;
  box-shadow: var(--shadow, 0 18px 45px rgba(15, 23, 42, 0.08));
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* Bande verte en haut de la carte gauche */
.demo-card-main .card-accent {
  height: 10px;
  background: linear-gradient(90deg, #1ebe6d, #0ea86b);
}

/* Contenu interne des cartes */
.demo-card-body {
  padding: 32px 32px 26px 32px;
}

/* ====== CARTE GAUCHE : UPLOAD / CTA ====== */

.demo-left {
  display: flex;
  flex-direction: column;
}

.upload-card {
  border-radius: 22px;
  position: relative;
}

/* Titre & description */
.upload-title {
  margin: 12px 0 8px 0;
  font-size: clamp(1.8rem, 3vw, 2.2rem);
  font-weight: 700;
  letter-spacing: -0.01em;
}

.upload-desc {
  margin: 0 0 20px 0;
  max-width: 72%;
  margin-left: auto;
  margin-right: auto;
  color: rgba(15, 23, 42, 0.65);
  line-height: 1.5;
}

/* Zone de drop / input fichier */
.file-drop {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 110px;
  width: 80%;
  margin: 0 auto 22px auto;
  border-radius: 14px;
  border: 1px dashed rgba(15, 23, 42, 0.12);
  background: rgba(15, 23, 42, 0.01);
  padding: 12px;
  position: relative;
  overflow: hidden;
  cursor: pointer;
  transition: box-shadow 0.3s ease, transform 0.3s ease;
}

.file-drop:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 36px rgba(15, 23, 42, 0.15);
}

.demo-image input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
}

.demo-image .placeholder {
  text-align: center;
  max-width: 88%;
  margin: auto;
}

.demo-image img#preview {
  max-width: 100%;
  max-height: 220px;
  height: auto;
  border-radius: 10px;
  box-shadow: var(--shadow, 0 10px 35px rgba(15, 23, 42, 0.18));
  display: none;
  object-fit: contain;
}

/* état "une image est chargée" */
.file-drop.loaded .placeholder {
  display: none;
}
.file-drop.loaded img#preview {
  display: block;
}

/* CTA principal (gros bouton vert) */
.big-cta {
  width: 100%;
  padding: 18px 26px;
  font-size: 1rem;
  font-weight: 600;
  border-radius: 34px;
  border: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: #fff;
  position: relative;
  overflow: hidden;
  background: linear-gradient(135deg, #0ba360, #3cba92);
  box-shadow: 0 16px 35px rgba(11, 163, 96, 0.25);
  letter-spacing: 0.02em;
}

.big-cta.secondary {
  background: linear-gradient(135deg, #0fb981, #2dd4bf);
  box-shadow: 0 16px 35px rgba(15, 185, 129, 0.22);
}

.big-cta.alt {
  background: linear-gradient(135deg, #3671ff, #00b4ff);
  box-shadow: 0 16px 35px rgba(40, 109, 255, 0.25);
}

.big-cta::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(120deg, rgba(255,255,255,0) 30%, rgba(255,255,255,0.35) 50%, rgba(255,255,255,0) 70%);
  opacity: 0;
  transition: opacity 0.25s ease;
}

.big-cta:hover::after {
  opacity: 1;
}

.big-cta i {
  font-size: 1rem;
}

.big-cta + .big-cta {
  margin-left: 0;
}

/* Petit texte sous le CTA */
.upload-footer {
  margin-top: 10px;
  font-size: 0.8rem;
  letter-spacing: 0.06em;
}

/* ====== CARTE DROITE : RESULTATS / ASSISTANT ====== */

.demo-right {
  display: flex;
  flex-direction: column;
}

.assistant-area {
  padding: 24px 22px 22px 22px;
  border-radius: 22px;
  background: var(--card, #ffffff);
  box-shadow: var(--shadow, 0 18px 45px rgba(15, 23, 42, 0.08));
  display: flex;
  flex-direction: column;
  position: relative;
  height: 100%;
}

.result-grid {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.result-card {
  background: #fff;
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 18px;
  box-shadow: 0 14px 30px rgba(15, 23, 42, 0.08);
  padding: 18px;
  display: flex;
  flex-direction: column;
}

.result-card.summary{
  background: linear-gradient(180deg,#f7fff9,#fff);
}

.placeholder-card{
  justify-content:center;
  text-align:center;
  color:rgba(15,23,42,0.55);
  border:1px dashed rgba(15,23,42,0.15);
}

.placeholder-card i{
  font-size:2rem;
  color:#22c55e;
  margin-bottom:12px;
}

.placeholder-card ul{
  text-align:left;
  list-style:disc;
  margin:0 auto;
  padding-left:20px;
  color:rgba(15,23,42,0.65);
}

/* Header assistant */
.assistant-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid rgba(15, 23, 42, 0.04);
  padding-bottom: 10px;
  margin-bottom: 8px;
}

.assistant-title {
  font-weight: 700;
  font-size: 1rem;
}

.assistant-meta .muted {
  font-size: 0.78rem;
}

/* Placeholder "les résultats s'afficheront…" */
.empty-result {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(15, 23, 42, 0.42);
  font-size: 1.05rem;
  text-align: center;
  padding: 0 18px;
}

/* Zone messages */
.messages {
  list-style: none;
  margin: 0;
  padding: 12px 0 0 0;
  overflow: auto;
  max-height: 50vh;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Barre de confiance */
.confidence {
  display: none;
}

/* Loader rond dans la carte résultat */
.demo-spinner {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 4px solid rgba(15, 23, 42, 0.08);
  border-top-color: var(--accent, #16a34a);
  animation: spin 0.9s linear infinite;
  position: absolute;
  right: 18px;
  top: 18px;
  display: none;
}

.demo-spinner[hidden] {
  display: none;
}

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

/* ====== AMÉLIORATIONS CSS ====== */

/* Ajout d'animations pour les interactions utilisateur */
.file-drop {
  transition: box-shadow 0.3s ease, transform 0.3s ease;
}

.file-drop:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 36px rgba(15, 23, 42, 0.15);
}

/* Bulles de conversation */
.messages {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  background: #f9f9f9;
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.scrollable-response {
  flex: 1;
  overflow-y: auto;
  padding-right: 4px;
}

.scrollable-response::-webkit-scrollbar {
  width: 6px;
}

.scrollable-response::-webkit-scrollbar-track {
  background: rgba(14, 194, 124, 0.08);
  border-radius: 999px;
  margin: 4px 0;
}

.scrollable-response::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, #0ec27c, #0a7d4e);
  border-radius: 999px;
  transition: background 0.3s ease;
}

.scrollable-response::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, #0a7d4e, #085d3a);
  box-shadow: 0 0 6px rgba(14, 194, 124, 0.3);
}

.messages .msg {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.messages .msg.user {
  justify-content: flex-end;
}

.messages .msg.assistant {
  justify-content: flex-start;
}

.messages .msg .bubble {
  max-width: 70%;
  padding: 12px 16px;
  border-radius: 16px;
  background: #ffffff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.messages .msg.user .bubble {
  background: #e0f7fa;
  color: #00796b;
}

.messages .msg.assistant .bubble {
  background: #f1f8e9;
  color: #33691e;
}

/* Animation pour le loader (typing) */
.typing .dots {
  display: flex;
  gap: 4px;
}

.typing .dot {
  width: 8px;
  height: 8px;
  background: #ccc;
  border-radius: 50%;
  animation: blink 1.2s infinite;
}

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

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

@keyframes blink {
  0%, 100% {
    opacity: 0.3;
  }
  50% {
    opacity: 1;
  }
}

/* Amélioration de la responsivité */
@media (max-width: 600px) {
  .demo-container {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .demo-card-body {
    padding: 20px;
  }

  .messages {
    padding: 12px;
  }
}

@media (max-width: 900px) {
  .demo-container {
    grid-template-columns: 1fr;
    gap: 20px;
  }

  .demo-card-body {
    padding: 24px 18px 20px 18px;
  }

  .upload-desc {
    max-width: 100%;
  }

  .file-drop {
    width: 100%;
  }

  .messages {
    max-height: 260px;
  }

  .demo-spinner {
    position: static;
    margin-left: auto;
    margin-top: 10px;
  }
}

/* Petit helper visuel quand on drag un fichier */
.file-drop.dragover {
  outline: 3px dashed rgba(14, 194, 124, 0.25);
  border-color: rgba(14, 194, 124, 0.55);
  transform: translateY(-2px);
}
