/**
 * Atlas V3 — style.css (Frontend)
 * Rôle dans la chaîne Atlas V3 :
 * - Style UI du projet
 * - Inclut les styles pour l'en-tête avec authentification
 */

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  background: #f4f9ff;
  height: 100vh;
  display: flex;
  flex-direction: column;
}

header {
  background: #4a90e2;
  color: #fff;
  padding: 12px 14px;
  font-size: 1.2rem;
  font-weight: 700;
  position: fixed;
  top: 0;
  width: 100%;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.header-left {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.header-right {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.header-auth {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(255,255,255,0.92);
  border: 1px solid rgba(225,232,237,0.9);
  border-radius: 999px;
  padding: 6px 10px;
  box-shadow: 0 1px 3px rgba(0,0,0,.08);
  max-width: 58vw;
}

.atlas-auth-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #bbb;
  flex: 0 0 auto;
}
.atlas-auth-dot.on { background: #2ecc71; }

.atlas-auth-text {
  color: #1a1a1a;
  font-size: 0.88rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.atlas-auth-open {
  border: 1px solid rgba(255,255,255,0.85);
  background: rgba(255,255,255,0.15);
  color: #fff;
  border-radius: 12px;
  padding: 6px 10px;
  cursor: pointer;
  font-weight: 700;
  font-size: 0.85rem;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

main#app {
  flex: 1;
  padding: 76px 15px 86px 15px; /* Ajusté pour la hauteur du header */
}

#chat {
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
  max-height: calc(100vh - 76px - 86px);
  padding-right: 4px;
}

.bubble {
  padding: 12px 16px;
  border-radius: 18px;
  max-width: 85%;
  font-size: 1rem;
  box-shadow: 0 1px 3px rgba(0,0,0,.1);
  white-space: pre-wrap;
}

.bubble.ai {
  background: #fff;
  color: #333;
  border: 1px solid #e1e8ed;
  align-self: flex-start;
}

.bubble.user {
  background: #4a90e2;
  color: #fff;
  align-self: flex-end;
}

/* GEO — Rich HTML rendering foundation
 * Prépare l'UI à afficher des réponses structurées :
 * - cartes de lieux
 * - images Brave / Google
 * - liens externes
 * - badges provider / distance / ouverture
 *
 * Important :
 * .bubble reste compatible texte simple.
 * .bubble.ai.rich sera utilisé plus tard par ui.module.js.
 */
.bubble.ai.rich {
  white-space: normal;
  width: min(100%, 760px);
  max-width: 96%;
  padding: 12px;
}

.bubble.ai.rich .bubble-content {
  display: grid;
  gap: 12px;
  line-height: 1.45;
}

.bubble.ai.rich p {
  margin: 0 0 8px 0;
}

.bubble.ai.rich ul,
.bubble.ai.rich ol {
  margin: 6px 0 8px 20px;
  padding: 0;
}

.bubble.ai.rich a {
  color: #246bb3;
  font-weight: 700;
  text-decoration: none;
}

.bubble.ai.rich a:hover {
  text-decoration: underline;
}

.geo-card-list {
  display: grid;
  gap: 12px;
  margin-top: 6px;
}

.geo-place-card {
  display: grid;
  grid-template-columns: 96px 1fr;
  gap: 12px;
  background: #f8fbff;
  border: 1px solid #dce9f8;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
}

.geo-card-media {
  width: 96px;
  min-height: 96px;
  background: #eaf2fb;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.geo-card-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.geo-card-media .geo-card-placeholder {
  font-size: 1.8rem;
  opacity: .72;
}

.geo-card-body {
  padding: 10px 10px 10px 0;
  min-width: 0;
}

.geo-card-title {
  font-weight: 800;
  color: #1f2d3d;
  margin: 0 0 4px 0;
  overflow-wrap: anywhere;
}

.geo-card-meta {
  color: #4f5f70;
  font-size: .92rem;
  margin: 0 0 6px 0;
  overflow-wrap: anywhere;
}

.geo-card-summary {
  color: #2d3742;
  font-size: .94rem;
  margin: 0 0 8px 0;
}

.geo-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.geo-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid #c7dbf3;
  background: #fff;
  color: #246bb3;
  border-radius: 999px;
  padding: 7px 10px;
  font-size: .88rem;
  font-weight: 800;
  text-decoration: none;
}

.geo-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 6px 0;
}

.geo-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border-radius: 999px;
  padding: 4px 8px;
  font-size: .78rem;
  font-weight: 800;
  background: #eef5ff;
  color: #285b91;
  border: 1px solid #d3e6fb;
}

.geo-badge.ok {
  background: #eefaf1;
  color: #247a3c;
  border-color: #cdeed5;
}

.geo-badge.warn {
  background: #fff8e7;
  color: #946500;
  border-color: #f4dfaa;
}

.geo-source-list {
  display: grid;
  gap: 8px;
  margin-top: 8px;
}

.geo-source-item {
  border-left: 4px solid #4a90e2;
  background: #f8fbff;
  padding: 8px 10px;
  border-radius: 10px;
}

.geo-source-title {
  font-weight: 800;
  color: #1f2d3d;
  margin: 0 0 2px 0;
}

.geo-source-url {
  font-size: .82rem;
  color: #6a7a8a;
  overflow-wrap: anywhere;
}

.geo-rich-note {
  color: #607080;
  font-size: .9rem;
}

@media (max-width: 560px) {
  .bubble.ai.rich {
    width: 100%;
    max-width: 100%;
    border-radius: 16px;
  }

  .geo-place-card {
    grid-template-columns: 82px 1fr;
  }

  .geo-card-media {
    width: 82px;
    min-height: 82px;
  }

  .geo-card-body {
    padding: 9px 9px 9px 0;
  }

  .geo-card-actions {
    gap: 6px;
  }

  .geo-link {
    font-size: .82rem;
    padding: 6px 9px;
  }
}

footer {
  background: #fff;
  padding: 10px;
  display: flex;
  gap: 8px;
  border-top: 1px solid #ddd;
  position: fixed;
  bottom: 0;
  width: 100%;
  z-index: 100;
}

#msg {
  flex: 1;
  padding: 12px;
  border: 1px solid #ccc;
  border-radius: 20px;
  outline: none;
  font-size: 16px;
}

#btn-send {
  background: #4a90e2;
  color: #fff;
  border: none;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  font-size: 1.2rem;
  cursor: pointer;
}

/* CONTACT MODAL (conservé si nécessaire) */
.atlas-modal.hidden { display: none; }
.atlas-modal { position: fixed; inset: 0; z-index: 1000; }
.atlas-modal-overlay { position: absolute; inset: 0; background: rgba(0,0,0,0.5); }
.atlas-modal-content {
  position: relative;
  background: white;
  width: 92%;
  max-width: 460px;
  margin: 12vh auto;
  padding: 18px;
  border-radius: 14px;
}
.atlas-modal-close {
  position: absolute;
  top: 10px;
  right: 10px;
  border: none;
  background: none;
  font-size: 1.2rem;
  cursor: pointer;
}

/* AUTH — bar + modal (alignement mobile) */
.atlas-authbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 10px 0 0 0;
}

.atlas-auth-status {
  font-size: 0.95rem;
  color: #333;
  display: flex;
  align-items: center;
  gap: 8px;
}

.atlas-auth-dot {
  width: 10px;
  height: 10px;
  border-radius: 99px;
  background: #bbb;
  flex: 0 0 auto;
}

.atlas-auth-dot.on { background: #2ecc71; }

.atlas-authbar button {
  border: 2px solid #222;
  background: #fff;
  border-radius: 12px;
  padding: 10px 14px;
  font-weight: 700;
  cursor: pointer;
}

/* Auth modal form */
.atlas-auth-form {
  display: grid;
  gap: 12px;
}

.atlas-auth-form label {
  font-size: 0.95rem;
  font-weight: 700;
  color: #111;
}

.atlas-auth-form input,
.atlas-auth-form textarea,
.atlas-auth-form select {
  width: 100%;
  padding: 12px 12px;
  border: 1px solid #ccc;
  border-radius: 12px;
  font-size: 16px;
  outline: none;
}

.atlas-auth-form textarea {
  min-height: 90px;
  resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

.atlas-auth-help {
  font-size: 0.92rem;
  color: #444;
  line-height: 1.25rem;
}

.atlas-auth-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: flex-start;
}

.atlas-auth-actions button {
  background: #4a90e2;
  color: #fff;
  border: none;
  border-radius: 12px;
  padding: 12px 14px;
  font-weight: 800;
  cursor: pointer;
}

.atlas-auth-actions button.secondary {
  background: #eef3fb;
  color: #111;
  border: 1px solid #cdd9ee;
}

.atlas-auth-feedback {
  font-size: 0.95rem;
  color: #333;
}