/* ======== BASE ======== */
body {
  background-color: #0d0d0d;
  color: #e6e6e6;
  font-family: 'Inter', Arial, sans-serif;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100vh;
  margin: 0;
  overflow: visible;
}

/* ===== TASTO ACCEDI ===== */
#adminLoginBtn {
  background: linear-gradient(#00C3FF);
  border: none;
  color: white;
  padding: 8px 16px;
  font-size: 15px;
  font-weight: 600;
  border-radius: 8px;
  cursor: pointer;
  transition: 0.3s;
  display: flex;
  align-items: center;
  gap: 6px;
}

#adminLoginBtn:hover {
  transform: scale(1.05);
  box-shadow: 0 0 10px rgba(130, 102, 255, 0.6);
}

.nav-buttons {
  display: flex;            
  justify-content: center;  
  align-items: center;     
  gap: 10px;                
}

/* ===== OVERLAY MODAL ===== */
#loginModal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: 0.3s ease;
  z-index: 999;
}

#loginModal.hidden {
  opacity: 0;
  pointer-events: none;
}

/* ===== BOX MODAL ===== */
.modal-box {
  background: #1e1e2e;
  padding: 22px;
  width: 320px;
  border-radius: 14px;
  text-align: center;
  box-shadow: 0 0 15px rgba(0,0,0,0.3);
  transform: scale(0.9);
  transition: 0.3s ease;
  border: 1px solid rgba(255,255,255,0.1);
}

#loginModal.show .modal-box {
  transform: scale(1);
}

/* ===== INPUT ===== */
.modal-box input {
  width: 100%;
  padding: 10px;
  margin-top: 10px;
  background: #2a2a3b;
  border: 1px solid #3a3a50;
  border-radius: 6px;
  color: white;
  font-size: 15px;
  outline: none;
}

.modal-box input:focus {
  border-color: #6a5af9;
  box-shadow: 0 0 5px #6a5af9;
}

/* ===== BOTTONE LOGIN ===== */
.modal-box button {
  width: 100%;
  padding: 10px;
  margin-top: 14px;
  background: #00C3FF;
  border: none;
  border-radius: 6px;
  color: white;
  font-weight: 600;
  cursor: pointer;
  font-size: 16px;
  transition: 0.2s;
}

.modal-box button:hover {
  background: #7b6bff;
}

/* ======== TOP BAR ======== */
.topbar {
  display: flex;
  justify-content: space-between; /* logo a sinistra, pulsanti a destra */
  align-items: center;
  padding: 10px 14px;
  background: #141414;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.4);
  position: fixed;
  top: 0;
  width: 100%;
  z-index: 10;
  box-sizing: border-box;
}

.left, .right {
  display: flex;
  align-items: center;
  gap: 8px;
}

#visitCounter {
  font-weight: bold;
  color: white;
  margin: 0 20px; /* distanza dai lati */
  white-space: nowrap;
}

.logo {
  width: 36px;
  height: 36px;
  border-radius: 8px;
}

.brand {
  font-weight: 600;
  font-size: 1.1rem;
}

.tabs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.tab {
  background: none;
  border: none;
  color: #aaa;
  font-size: 0.95rem;
  cursor: pointer;
  padding: 6px 12px;
  border-radius: 8px;
  transition: 0.2s;
  white-space: nowrap;
}

.tab:hover {
  background: #1f1f1f;
  color: #fff;
}

.tab.active {
  background: #00c3ff;
  color: #fff;
}

/* ======== MENU HAMBURGER ======== */
.right {
  position: relative;
}

.menu-btn {
  background: none;
  border: none;
  font-size: 1.5rem;
  color: #aaa;
  cursor: pointer;
  transition: color 0.2s ease;
}

.menu-btn:hover {
  color: #fff;
}

.dropdown {
  position: absolute;
  top: 40px;
  right: 0;
  background: #141414;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 6px 0;
  min-width: 120px;
  box-shadow: 0 4px 10px rgba(0,0,0,0.4);
  z-index: 20;
}

.dropdown.hidden {
  display: none;
}

.dropdown .tab {
  padding: 8px 16px;
  text-align: left;
  width: 100%;
}

.dropdown .tab:hover {
  background: #1f1f1f;
}

/* ======== SECTIONS ======== */
.section {
  margin-top: 80px;
  width: 100%;
  max-width: 900px;
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.hidden {
  display: none;
}

/* ======== CHAT ======== */
#chat-container {
  width: 100%;
  max-width: 900px;
  height: calc(100vh - 160px);
  display: flex;
  flex-direction: column;
  background: #111;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 0 10px #000;
  position: relative;
}

#chat-box {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 1rem;
  scrollbar-width: thin;
  height: 100%;
}

#chat-box::-webkit-scrollbar {
  width: 8px;
}

#chat-box::-webkit-scrollbar-thumb {
  background: #333;
  border-radius: 4px;
}

#chat-box::-webkit-scrollbar-track {
  background: transparent;
}

/* ======== TASTO STOP ======== */
#send-btn.stop-btn {
  background: #ff4d4d; /* rosso acceso */
  color: white;
  transition: background 0.2s, transform 0.2s;
}

#send-btn.stop-btn:hover {
  background: #e60000;
  transform: scale(1.1);
}

/* ======== MESSAGGI ======== */
.message {
  margin: 8px 0;
  padding: 10px 14px;
  border-radius: 12px;
  max-width: 85%;
  line-height: 1.4;
  word-wrap: break-word;
  position: relative;
  animation: fadeIn 0.2s ease;
}

.user {
  align-self: flex-end;
  background-color: #007bff;
  color: white;
}

.bot {
  align-self: flex-start;
  background-color: #2a2a2a;
  color: #00c3ff;
}

/* === Messaggio di benvenuto === */
.message.welcome {
  align-self: center;
  text-align: center;
  background: #1a1a1a;
  color: #00c3ff;
  border-radius: 12px;
  padding: 12px 16px;
  margin: 20px auto 10px auto;
  box-shadow: 0 0 10px rgba(0, 195, 255, 0.2);
  font-style: italic;
  font-size: 0.95rem;
  max-width: 80%;
  animation: fadeIn 0.8s ease;
}

/* === Messaggio Sto pensando === */
.message.thinking {
  align-self: flex-start;
  background-color: #1a1a1a;
  color: #00c3ff;
  border-radius: 12px;
  padding: 12px 16px;
  font-style: italic;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  animation: fadeIn 0.3s ease;
}

/* Puntini animati */
.dots {
  display: inline-block;
  margin-left: 3px;
}

.dots span {
  opacity: 0;
  animation: blink 1.5s infinite;
}

.dots span:nth-child(1) {
  animation-delay: 0s;
}
.dots span:nth-child(2) {
  animation-delay: 0.3s;
}
.dots span:nth-child(3) {
  animation-delay: 0.6s;
}

@keyframes blink {
  0%, 20% { opacity: 0; }
  50% { opacity: 1; }
  80%, 100% { opacity: 0; }
}

/* Effetto comparsa */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* === Anteprima immagine === */
.preview-img {
  width: 100px; 
  height: auto;
  border-radius: 8px;
  margin-top: 6px;
  display: block;
  box-shadow: 0 0 5px rgba(0, 0, 0, 0.4);
}

/* Bottone rimozione anteprima */
.remove-btn {
  background: none;
  border: none;
  color: #bbb;
  cursor: pointer;
  font-size: 14px;
  position: absolute;
  top: 6px;
  right: 8px;
  transition: color 0.2s ease;
}

.remove-btn:hover {
  color: #fff;
}

/* ======== INPUT AREA ======== */
#input-area {
  display: flex;
  align-items: center;
  padding: 0.75rem;
  background: #111;
}

#user-input {
  flex: 1;
  padding: 10px;
  border: none;
  border-radius: 10px;
  background: #222;
  color: white;
  outline: none;
}

#send-btn {
  background: #00c3ff;
  border: none;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  cursor: pointer;
  color: white;
  font-size: 18px;
  transition: 0.2s;
}

#send-btn:hover {
  background: #009bd8;
}

/* === Graffetta animata === */
.attach-btn {
  font-size: 22px;
  cursor: pointer;
  color: #ccc;
  margin-right: 10px;
  transition: transform 0.3s ease, color 0.3s ease;
}

.attach-btn:hover {
  color: white;
  transform: scale(1.2);
}

.attach-btn.spin {
  animation: spin 0.6s ease;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* === Anteprima sopra la chat === */
#image-preview {
  display: none;
  justify-content: center;
  align-items: center;
  gap: 10px;
  background: #1c1c1c;
  border-radius: 12px;
  padding: 10px 16px;
  margin: 10px auto;
  width: 90%;
  box-shadow: 0 0 10px #000;
  opacity: 0;
  transform: translateY(-10px);
  transition: opacity 0.3s ease, transform 0.3s ease;
}

#image-preview.show {
  opacity: 1;
  transform: translateY(0);
}

#image-preview img {
  width: 45px;
  height: 45px;
  border-radius: 6px;
  object-fit: cover;
}

#image-preview span {
  color: #ccc;
  font-size: 0.95rem;
  flex: 1;
  text-align: left;
}

#image-preview button {
  background: transparent;
  border: none;
  color: #888;
  cursor: pointer;
  font-size: 18px;
}

#image-input {
  display: none;
}

/* ======== INFO ======== */
#info {
  padding: 1rem;
  line-height: 1.6;
  text-align: center;
  overflow: hidden;
}

/* ======== TOS ======== */
#tos {
  padding: 1rem 1.5rem;
  line-height: 1.6;
  height: calc(100vh - 80px);
  overflow-y: auto;
  background: #111;
  border-radius: 16px;
  box-shadow: 0 0 10px #000;
  scrollbar-width: thin;
}

#tos::-webkit-scrollbar {
  width: 8px;
}

#tos::-webkit-scrollbar-thumb {
  background: #333;
  border-radius: 4px;
}

#tos::-webkit-scrollbar-track {
  background: transparent;
}

/* ======== FOOTER ======== */
footer {
  color: #777;
  font-size: 0.8rem;
  margin-bottom: 10px;
}

/* ======== CORONA MESSAGGI ADMIN ======== */
@keyframes float {
  0% { transform: translateY(0px); }
  50% { transform: translateY(-4px); }
  100% { transform: translateY(0px); }
}

@keyframes shine {
  0% { text-shadow: 0 0 5px gold; }
  50% { text-shadow: 0 0 15px gold, 0 0 25px orange; }
  100% { text-shadow: 0 0 5px gold; }
}

.admin-crown {
  display: inline-block;
  animation: float 1.8s ease-in-out infinite, shine 1.5s infinite alternate;
  margin-right: 4px;
}