:root {
  --primary-blue: #2b7eb5;
  --primary-gray-light: #f7f9fc;
  --primary-gray: #d1d9e6;
  --primary-gray-dark: #6b7280;
  --text-color: #1f2937;
  --text-color-light: #64748b;
  --athena: #005756;
  --bg-white: #ffffff;
  --border-color: #e2e8f0;
  --input-bg: #f9fafb;
  --input-border: #cbd5e1;
  --button-bg: #2a4d69;
  --button-hover-bg: #1f3a57;
  --accent-color: #238c8c;
  --button-color: #ffffff;
}

body {
  margin: 0;
  padding: 0;
  font-family: "Inter", "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  color: var(--text-color);
  background-color: var(--primary-gray-light);
  display: flex;
  flex-direction: row;
  height: 100vh;
  overflow: hidden;
  font-size: 14px; /* testo globale più compatto */
}
/*copy_botton */
.bubble {
  position: relative;
  display: block;
  max-width: 75%;
  padding: 8px 12px;
  border-radius: 10px;
  background-color: var(--primary-gray-light);
  color: var(--text-color);
  font-size: 14px;
  white-space: pre-wrap;
  word-wrap: break-word;
  overflow-wrap: break-word;
  margin: 0;
  line-height: 1.3;
  border: 1px solid var(--border-color);
  box-shadow: none;
}

.copy-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 14px;
  color: var(--text-color-light);
  user-select: none;
  padding-left: 10px;
  transition: color 0.3s ease;
}

.copy-btn:hover {
  color: var(--button-bg);
}

.copy-btn:focus {
  outline: none;
}
.bubble .copy-btn i {
  color: var(--text-color-light); /* colore icona su bubble grigia */
  transition: color 0.3s ease;
}

.bubble.user .copy-btn i {
  color: var(--bg-white); /* colore icona su bubble blu (utente) */
}
/* Sidebar */
.sidebar {
  width: 240px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--bg-white);
  border-right: 1px solid var(--border-color);
  height: 100vh;
  overflow-y: auto;
  flex-shrink: 0;
  box-shadow: none;
  position: relative;
  z-index: 1100;
  border-radius: 0 8px 8px 0;
}

.sidebar img {
  /* max-width: 30%; logo più piccolo */
  margin-bottom: 16px;
  /* margin-left: 40px; margine da sinistra */
}

.sidebar button,
.sidebar select {
  background-color: var(--primary-blue);
  color: var(--button-color);
  border: none;
  padding: 10px 14px; /* più piccolo */
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  transition: background-color 0.25s ease;
  display: flex;
  align-items: center;
  gap: 6px;
  box-shadow: none;
}

.sidebar button:hover,
button.send:hover {
  background-color: var(--button-hover-bg);
}

.sidebar input {
  padding: 10px;
  border-radius: 6px;
  border: 1px solid var(--input-border);
  background-color: var(--input-bg);
  color: var(--text-color);
  font-size: 14px;
  font-weight: 400;
  outline-offset: 2px;
  transition: border-color 0.2s ease;
}

.sidebar input:focus {
  border-color: var(--button-bg);
  outline: none;
}

.chat-list {
  flex: 1;
  overflow-y: auto;
  margin-top: 8px;
}

.chat-list div {
  padding: 10px 12px; /* meno padding */
  background-color: var(--primary-gray-light);
  border-radius: 6px;
  margin-bottom: 6px;
  cursor: pointer;
  user-select: none;
  color: var(--text-color-dark);
  font-size: 14px;
  font-weight: 500;
  transition: background-color 0.3s ease, color 0.3s ease;
}

.chat-list div.selected {
  background-color: var(--button-bg);
  color: var(--button-color);
}

.chat-list div.selected:hover {
  background-color: var(--button-hover-bg);
}
/* Chat list ellipsis menu - */

.chat-list div {
  position: relative;
  /* padding-right: 32px; */
}

/* Contenitore dei puntini */
.ellipsis-btn {
  position: relative; /* crea contesto per il menu */
  cursor: pointer;
  padding: 0 8px;
  font-size: 18px;
  user-select: none;
}

.ellipsis-btn:hover {
  background-color: var(--primary-gray);
  color: var(--text-color);
}

/* Menu-dropdown */
.menu-popup {
  position: absolute !important; /* si posiziona in relazione all'ellipsis-btn */
  top: 100%;
  right: 0px; /* subito sotto i puntini */
  display: none;
  background-color: white;
  border: 1px solid #ccc;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
  z-index: 100;
  flex-direction: column;
  /* width: 140px;                 menù più stretto */
  width: auto;
  padding: 4px 0;
}

/* Stili bottoni menu */
.menu-popup button {
  width: 100%;
  background: none;
  border: none;
  padding: 8px 12px;
  text-align: left;
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--button-bg);
}

/* Hover dei bottoni */
.menu-popup button:hover {
  background-color: #f0f0f0;
}

/* Mostra il menu quando la classe menu‑open è attiva */
.menu-open .menu-popup {
  display: flex;
  /* width: 80px; */
}

.menu-popup button i {
  font-size: 15px;
  color: var(--button-bg);
}

/* Animazione fade in */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Main chat area */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  /* height: 100vh; */
  height: 100dvh;
  min-height: 0; /* evita overflow */
  background-color: var(--bg-white);
  border-radius: 0 8px 8px 0;
  box-shadow: inset 0 0 8px #f0f1f3;
  font-size: 14px;
}
.prefix-btn {
  background: none;
  border: none;
  /* color: var(--text-color-light); */
  color: var(--athena);
  font-size: 16px;
  margin-left: 6px;
  cursor: pointer;
  transition: color 0.3s ease;
}

.prefix-btn.active {
  color: var(--text-color);
  border: 1px solid var(--text-color);
  /* color: var(--accent-color);
  border: 1px solid var(--accent-color); */
  border-radius: 7px;
  /* background-color: var(--button-bg); */
}

.save-btn {
  color: var(--bg-white);
}
/* Chat Header */
.chat-header {
  display: flex;
  justify-content: flex-end;
  padding-right: 60px;
  align-items: center;
  gap: 12px;
  position: relative;
  box-shadow: 0 4px 6px -2px rgba(42, 77, 105, 0.7);
}
.chat-header.active {
  background-color: var(--text-color);
  color: #fff;
}
.chat-logo {
  max-width: 40px; /* logo più piccolo */
  object-fit: contain;
}

.chat-title {
  font-weight: 700;
  font-size: 1.2rem;
  color: var(--button-bg);
}

#hamburger-btn {
  font-size: 28px;
  background: transparent;
  border: none;
  color: var(--button-bg);
  cursor: pointer;
  padding: 4px 12px 4px 0;
  margin-right: 12px;
  flex-shrink: 0;
  display: none;
  position: fixed;
  top: 15px;
  left: 15px;
  z-index: 1200;
}

/* Chat box */
.chat-box {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
  padding: 20px 24px; /* meno padding */
  display: flex;
  flex-direction: column;
  gap: 10px; /* gap più piccolo */
  background-color: var(--bg-white);
  font-size: 14px;
}

/* Input area */
.input-area {
  display: flex;
  gap: 10px; /* gap più stretto */
  padding: 14px 24px; /* padding meno ampio */
  border-bottom: 1px solid var(--border-color);
  background-color: var(--bg-white);
}
.textarea-container {
  position: relative;
  display: inline-block; /* o block, a seconda delle esigenze */
}

.div-textarea-style {
  /* width: 100%; */
  margin: 0 20px;
  min-height: 120px;
  padding: 10px 12px;
  /* border: 1px solid #ccc; */
  border-radius: 8px;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1);
  font-size: 16px;
  line-height: 1.4;
  background-color: white;
  resize: vertical; /* solo se vuoi simulare il ridimensionamento */
  overflow-y: auto;
  box-sizing: border-box;
}

#btn-invio {
  border-left: 1px solid var(--border-color);
}

.bottom-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 10px;
}

/* Nascondi il bottone mobile su desktop */
.mobile-only {
  display: none;
}

textarea {
  flex: 1;
  border-right: 1px solid var(--border-color);
  /* padding: 10px 14px;
  border-radius: 8px;
  border: 1px solid var(--input-border);
  resize: none;
  background-color: var(--input-bg);
  color: var(--text-color);
  font-family: "Inter", sans-serif;
  font-size: 14px;
  min-height: 50px;
  transition: border-color 0.2s ease; */
  all: unset;
  width: 100%;
  font-size: 13px;
  height: 80px;
  box-sizing: border-box;
}

textarea:focus {
  border-color: var(--button-bg);
  outline: none;
}

button.send {
  background-color: var(--button-bg);
  color: var(--button-color);
  border: none;
  padding: 12px 20px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: background-color 0.25s ease;
}

button.send:hover {
  background-color: var(--button-hover-bg);
}

/* Message bubbles */
.message {
  display: flex;
  gap: 8px; /* più compatto */
  margin-bottom: 4px;
  align-items: flex-start;
}

.message.user {
  flex-direction: row-reverse;
  text-align: right;
}

.avatar img {
  width: 32px; /* avatar più piccoli */
  height: 32px;
  border-radius: 50%;
  user-select: none;
  filter: none;
  box-shadow: none;
}

.bubble {
  max-width: 75%; /* leggermente più largo */
  padding: 8px 12px; /* meno padding */
  border-radius: 10px;
  background-color: var(--primary-gray-light);
  color: var(--text-color);
  font-size: 14px;
  white-space: pre-wrap;
  word-wrap: break-word;
  overflow-wrap: break-word;
  margin: 0;
  line-height: 1.3;
  border: 1px solid var(--border-color);
  box-shadow: none;
}

.bubble.user {
  background-color: var(--button-bg);
  color: var(--button-color);
  border-color: var(--button-bg);
}

.bubble p {
  margin: 0;
}

/* Code styling */
.bubble code,
.bubble pre {
  background: #f3f6fc;
  color: #2a4d69;
  font-family: "Courier New", Courier, monospace;
  padding: 6px 10px;
  border-radius: 6px;
  display: block;
  overflow-x: auto;
  margin-top: 6px;
  margin-bottom: 6px;
  font-size: 13px;
}

.bubble p code {
  display: inline-block;
  padding: 2px 5px;
  border-radius: 4px;
  background: #f3f6fc;
  color: #2a4d69;
  font-size: 13px;
}

/* Server status */
#server-status {
  position: fixed;
  bottom: 100px;
  right: 32px;
  z-index: 1200;
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  user-select: none;
  color: var(--bg-white);
  background-color: var(--primary-gray-dark);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  transition: background-color 0.3s ease;
  display: flex;
  align-items: center;
  gap: 10px;
}

#server-status.online {
  background-color: #4caf50;
}

#server-status.offline {
  background-color: #e53e3e;
}

#server-status .fas {
  font-size: 18px;
}

#server-status .spinning {
  animation: spin 1s infinite linear;
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

#server-status.online i {
  display: none;
}

#server-status.online .fa-check-circle {
  display: inline-block;
}

footer {
  font-size: 12px;
  text-align: center;
  padding: 12px;
  background: var(--bg-white);
  border-top: 1px solid var(--border-color);
  user-select: none;
  color: var(--text-color-light);
}

/* MODAL */
#customModal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 9999;
}

#customModalBackdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 9998;
  display: none;
}

.notificationCard {
  width: 280px;
  height: 280px;
  background: rgb(245, 245, 245);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px 35px;
  gap: 10px;
  box-shadow: 5px 5px 10px rgba(0, 0, 0, 0.123);
  border-radius: 20px;
}

.bellIcon {
  width: 50px;
  margin: 20px 0px;
}

.notificationHeading {
  color: var(--button-bg);
  font-weight: 600;
  /* font-size: 0.8em; */
  font-size: 20px;
}

.notificationPara {
  color: rgb(133, 133, 133);
  font-size: 15px;
  font-weight: 600;
  text-align: center;
}

.buttonContainer {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.AllowBtn {
  /* width: 120px;
  height: 25px; */
  background-color: var(--button-bg);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 18px;
  font-weight: 600;
  cursor: pointer;
  padding: 8px;
  margin: 15px;
}

.NotnowBtn {
  /* width: 120px;
  height: 25px; */
  color: var(--button-bg);
  border: none;
  background-color: transparent;
  font-weight: 600;
  font-size: 18px;
  cursor: pointer;
}

.NotnowBtn:hover {
  background-color: rgb(239, 227, 255);
}

.AllowBtn:hover {
  background-color: rgb(153, 110, 255);
}

.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.3);
  z-index: 999;
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
}

/* mostra backdrop */
.modal-backdrop.show {
  opacity: 1;
  pointer-events: auto;
}

/* modale base */
.modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.95);
  z-index: 1000;
  opacity: 0;
  transition: all 0.3s ease;
  pointer-events: none;
}

/* mostra modale */
.modal.show {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
  pointer-events: auto;
}

/* pulsante chiudi */
.closeModalBtn {
  position: absolute;
  top: 10px;
  right: 15px;
  font-size: 20px;
  font-weight: bold;
  cursor: pointer;
  color: var(--button-bg);
}

.closeModalBtn:hover {
  color: #000;
}

.closeModalBtn:hover {
  color: #000;
}

/* Typing animation */
.typing-dots {
  display: inline-flex;
  gap: 6px;
  margin-left: 6px;
  align-items: center;
}
.typing-dots span {
  width: 7px;
  height: 7px;
  background-color: var(--button-bg);
  border-radius: 50%;
  opacity: 0.25;
  animation-name: blink;
  animation-duration: 1.4s;
  animation-iteration-count: infinite;
  animation-timing-function: ease-in-out;
}
.typing-dots span:nth-child(1) {
  animation-delay: 0s;
}
.typing-dots span:nth-child(2) {
  animation-delay: 0.25s;
}
.typing-dots span:nth-child(3) {
  animation-delay: 0.5s;
}

@keyframes blink {
  0%,
  80%,
  100% {
    opacity: 0.25;
  }
  40% {
    opacity: 1;
  }
}

/* Mobile Styles */
@media (max-width: 768px) {
  body {
    flex-direction: column;
    height: 100vh;
    overflow: visible;
    font-size: 13px; /* più piccolo anche su mobile */
  }

  #server-status {
    bottom: 130px;
    right: 16px;
    padding: 6px 12px;
    font-size: 13px;
  }

  .chat-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
  }

  #hamburger-btn {
    display: block;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100%;
    width: 90%;
    padding: 16px;
    background: var(--bg-white);
    border-right: 1px solid var(--border-color);
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    z-index: 1001;
    border-radius: 0 8px 8px 0;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  body.sidebar-open {
    overflow: hidden;
  }

  .main {
    margin-top: 0;
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border-radius: 0;
  }

  .chat-box {
    padding: 12px 14px;
    font-size: 13px;
    flex: 1;
    overflow-y: auto;
  }

  .message {
    margin-bottom: 6px;
    gap: 8px;
  }

  .bubble {
    max-width: 75%;
    padding: 8px 12px;
    font-size: 13px;
    margin: 4px 6px;
    line-height: 1.2;
    border-radius: 10px;
  }

  .avatar img {
    width: 28px;
    height: 28px;
  }

  .input-area {
    padding: 12px 16px;
  }

  textarea {
    font-size: 13px;
    min-height: 40px;
    padding: 8px 12px;
    height: 60px;
  }

  .chat-list div {
    font-size: 13px;
    padding: 8px 10px;
  }
  .sidebar img {
    max-width: 50%;
    margin-left: 40px;
  }
}

/* VERSIONE MOBILE */
@media screen and (max-width: 600px) {
  .input-area {
    flex-direction: column;
  }

  /* Nasconde il pulsante di invio accanto alla textarea su mobile */
  .input-area .prefix-btn {
    display: none;
  }

  /* Mostra il bottone in basso a destra su mobile */
  .mobile-only {
    display: inline-block;
  }

  .bottom-bar {
    justify-content: space-between;
  }
  footer {
    margin-top:10px;
    margin-bottom: 10px; 
  }
}
