/* ===============================
   BASE APP — CHAT
================================ */
* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  height: 100%;
  font-family: "Optima", "Segoe UI", serif;
  background: #F3ECDD;
  color: #3f2a1b;
}

/* ===============================
   APP CONTAINER
================================ */
.app-container {
  position: absolute;
  top: 68px;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  flex-direction: column;
}

/* ===============================
   HEADER
================================ */
.app-header {
  position: relative;
  height: 68px;
  background: #F3ECDD;
  display: flex;
  align-items: center;
  justify-content: center;
}

.app-header::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: rgba(140, 90, 40, 0.25);
}

/* titolo */
.header-title {
  font-family: "Cormorant Garamond", serif;
  font-size: 32px;
  letter-spacing: 0.04em;
  color: #3f2a1b;
  display: flex;
  align-items: baseline;
  position: absolute; /* ← mancava questo */
  top: -10px;           /* ← la mezza via perfetta */
  left: 49%;
  transform: translateX(-50%);
}

.logo-a {
  font-family: "Vivaldi", "Zapfino", cursive;
  margin-right: 2px;
  transform: translateY(3px);
}

/* ===============================
   HEADER BUTTONS
================================ */
.header-btn {
  position: absolute;
  width: 70px;
  height: 40px;
  border-radius: 12px;
  border: 1px solid rgba(140, 90, 40, 0.18);
  background: #e2d2b8;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #000000; /* ← NERO COME IN ADMIN */
  font-weight: 600; /* leggermente più deciso */
  box-shadow:
    0 1px 3px rgba(140, 90, 40, 0.25);
}

#menu-btn {
  left: 12px;
  font-size: 22px;
}

#mode-btn {
  right: 12px;
  font-size: 17px;
}

.header-btn {
  transition: all 0.2s ease-in-out;
}

.header-btn:active {
  transform: translateY(1px);
  box-shadow:
    inset 0 1px 2px rgba(0,0,0,0.15),
    0 1px 2px rgba(0,0,0,0.25);
}

/* ===============================
   MESSAGES
================================ */
.message {
  margin-bottom: 16px;
  max-width: 90%;
}

.message.assistant {
  align-self: flex-start;
  text-align: left;
}

.message.user {
  align-self: flex-end;
  text-align: right;
}

.message .text {
  font-family: "Optima", sans-serif;
  font-size: 22px;
  line-height: 1.55;
  color: #2d241c;
  text-shadow:
    0 0 0.8px rgba(0,0,0,0.30),
    0 0 0.8px rgba(0,0,0,0.30); /* ispessimento ottico */
}

.message .line {
  margin: 6px 0 8px;
  width: 3.3cm;
  border-top: 1px solid rgba(63, 42, 27, 0.35);
}

.message.assistant .line {
  margin-right: auto;
}

.message.user .line {
  margin-left: auto;
}

.meta {
  font-size: 20px;
  opacity: 0.55;
  display: flex;
  gap: 6px;
}

.copy-icon {
  cursor: pointer;
}

/* ===============================
   INPUT AREA
================================ */
.input-area {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;

  display: flex;
  gap: 8px;
  padding: 8px;
  padding-top: 16px;
  padding-bottom: calc(2px + env(safe-area-inset-bottom));

  background: #F3ECDD;
  border-top: 1px solid rgba(140, 90, 40, 0.25);
  align-items: center;

  z-index: 999; /* sopra la chat */
}

textarea {
  flex: 1;
  min-height: 56px;
  max-height: 160px;
  resize: none;
  padding: 10px 14px;
  font-size: 16px;
  border-radius: 12px;
  border: 1px solid rgba(140, 90, 40, 0.3);
  background: #FAF6F0;
}

textarea::placeholder {
  font-style: italic;
  font-size: 20px;
  opacity: 0.6;
}

textarea:focus {
  outline: none;
  box-shadow: none;
  border-color: rgba(140, 90, 40, 0.28);
}

textarea {
  -webkit-tap-highlight-color: transparent;
}

#send-btn {
  height: 54px;                 /* come richiesto */
  padding: 0 14px;              /* proporzionato ai bottoni header */
  border: 1px solid rgba(140, 90, 40, 0.18);
  border-radius: 10px;          /* identico all’header */
  background: #e2d2b8;          /* stesso colore header */
  color: #3a281b;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  margin-right: 8px;

  display: flex;
  align-items: center;
  justify-content: center;

  box-shadow:
    0 0.5px 1px rgba(63, 42, 27, 0.18),
    0 3px 8px rgba(140, 90, 40, 0.12),
    0 4px 10px rgba(140, 90, 40, 0.18),
    0 -1px 1px rgba(255, 255, 255, 0.18); /* identico all’header */
}

#send-btn:hover {
  background: #d8c9b4;          /* stesso hover dell’header */
}

/* ===============================
   MOBILE
================================ */
@media (max-width: 768px) {
  #mic-btn {
    display: none !important;
  }
}

/* =========================
   OVERLAY MENU (SINISTRA)
   ========================= */

/* menu chiuso = display:none (gestito da .hidden) */
#menu-overlay {
  position: fixed;
  top: 64px;
  bottom: 100px;
  left: 0;
  width: 280px;

  background: #F3ECDD;
  border-right: 1px solid rgba(140, 90, 40, 0.18);
  z-index: 20;

  overflow: hidden;
}

/* quando NON è hidden → diventa flex */
#menu-overlay:not(.hidden) {
  display: flex;
  flex-direction: column;
}

/* pannello scrollabile */
.menu-overlay-panel {
  flex: 1 1 auto;
  overflow-y: auto;
  overscroll-behavior: contain;

  padding: 28px 22px;
  box-sizing: border-box;
}

/* lista */
.menu-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* voci */
.menu-item {
  color: #3f2a1b;
  text-decoration: none;
  font-size: 22px;
  padding-left: 12px;
}

/* separatore */
.menu-sep {
  height: 1px;
  margin: 10px 0;
  background: rgba(63, 42, 27, 0.18);
}

/* stato nascosto */
.hidden {
  display: none;
}

/* ===============================
   INPUT FOCUS — STILE ADMIN
================================ */

textarea:focus,
input:focus {
  border-color: rgba(140, 90, 40, 0.55);
  box-shadow:
    0 0 0 1px rgba(140, 90, 40, 0.25),
    0 4px 12px rgba(140, 90, 40, 0.18);
  background: #FFF9F1;
}

#message-input {
  padding: 10px 16px;          /* 🔥 prima 14px → ora molto più basso */
  margin-left: 4px;
  margin-right: 4px;

  background: #FAF6F0;
  border: 1px solid rgba(140, 90, 40, 0.28);
  border-radius: 13px;        /* leggermente più compatto */
  font-family: "Optima", sans-serif;

  font-size: 18px;            /* 🔥 prima 24px → enorme */
  line-height: 1.35;          /* 🔥 prima 1.55 → altissima */

  color: #000000;
  text-shadow:
    0 0 0.8px rgba(0,0,0,0.35),
    0 0 0.8px rgba(0,0,0,0.35);

  box-shadow:
    inset 0 0.5px 1px rgba(140, 90, 40, 0.10),
    0 1px 9px rgba(140, 90, 40, 0.18);

  resize: none;
}

/* focus identico ad admin */
#message-input:focus {
  background: #FFF9F4; /* un filo più chiaro e morbido */
  border-color: rgba(140, 90, 40, 0.45); /* meno intenso */
  box-shadow:
    inset 0 0.5px 1px rgba(140, 90, 40, 0.06), /* più leggero */
    0 0 0 1px rgba(140, 90, 40, 0.18),        /* contorno più soft */
    0 3px 10px rgba(140, 90, 40, 0.12);       /* ombra più diffusa */
  outline: none;
}

/* ===============================
   MENU ATTIVO — VERDE ADMIN
================================ */

.menu-item.active,
.menu-item:active {
  background: #7fdc8d;              /* verde admin */
  color: #000000;
  font-weight: 600;
  border-left: 4px solid #000000;
  padding-left: 10px;
}

/* ===============================
CHAT — STILE UNIFICATO ARKANIS
=============================== */

.chat-window {
  flex: 1;
  min-height: 0;
  overflow-y: auto;

  padding: 14px;
  padding-bottom: 140px;

  background: #FDFBF6;
  font-family: "Optima", "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  font-size: 18px;
  line-height: 1.45;
  font-weight: 400;
}

.message {
  max-width: 100%;
  margin-bottom: 4px;
  display: flex;
  flex-direction: column;
}

.message.assistant {
  align-self: flex-start;
  text-align: left;
}

.message.user {
  align-self: flex-end;
  text-align: right;
}

/* TESTO */

.text {
  padding: 12px 16px;
  border-radius: 12px;
  background: transparent;
  color: #3f3a2b;
}

/* LINEETTA */

.line {
  margin-top: 6px;
  margin-bottom: 8px;
  width: 1.8cm;
  border-top: 1px solid rgba(63, 42, 27, 0.35);
  opacity: 0.6;
}

.message.assistant .line {
  margin-left: 0;
  margin-right: auto;
}

.message.user .line {
  margin-left: auto;
  margin-right: 0;
}

/* META (ORA + COPIA) */

.meta {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 15px;
  font-weight: 600;
  opacity: 0.55;
  overflow: visible;
}

.message.assistant .meta {
  justify-content: flex-start;
  text-align: left;
}

.message.user .meta {
  justify-content: flex-end;
  text-align: right;
}

/* ICONA COPIA */

.copy-icon {
  cursor: pointer;
  font-size: 11px;
  line-height: 1;
  opacity: 1;
  transition: opacity 0.2s ease;
}

.copy-icon:hover {
  opacity: 1;
}

.user-message,
.bot-message {
  font-size: 20px;
  line-height: 1.55;
}

.speak-icon {
  cursor: pointer;
  font-size: 13px;
}

.meta .speak-icon {
  margin-left: 4px;   /* spazio tra ora e altoparlante */
}

.meta .copy-icon {
  margin-left: 2px;   /* spazio tra altoparlante e copia */
}

