

:root {
  --bg-page: #f7f7f7;
  --bg-card: #ffffff;
  --text-primary: #1a1a1a;
  --text-secondary: #777777;
  --accent: #5a5af3;
  --shadow-light: rgba(0, 0, 0, 0.05);
}

body {
  background-color: var(--bg-page);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: var(--text-primary);
  margin: 0;
}

/* === Conversation List === */
.conversation-header {
  background: var(--bg-page);
  padding: 20px;
  text-align: center;
}
.conversation-header h1 {
  font-size: 22px;
  font-weight: 600;
}
.conversation-list {
  list-style: none;
  margin: 0;
  padding: 8px;
}
.conversation-list li {
  background: var(--bg-card);
  margin-bottom: 8px;
  padding: 12px 16px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  transition: transform .1s, box-shadow .1s;
}
.conversation-list li:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px var(--shadow-light);
}
.conversation-list .empty {
  text-align: center;
  padding: 24px;
  color: var(--text-secondary);
  font-style: italic;
}
.avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 16px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-right: 14px;
}
.chat-info {
  flex: 1;
  position: relative;
}
.chat-name {
  font-size: 16px;
  font-weight: 500;
}
.unread-badge {
  position: absolute;
  top: 0; right: 0;
  transform: translate(50%, -50%);
  background: #ff4d4d;
  color: #fff;
  width: 18px; height: 18px;
  font-size: 10px; font-weight: 600;
  border-radius: 50%;
  display: inline-flex !important;
  align-items: center; justify-content: center;
  box-shadow: 0 0 0 1px #fff;
}


/* === Chat View === */
.chat-container {
  background: var(--bg-card);
  border-radius: 0 0 12px 12px;
  max-width: 480px;
  margin: auto;
  overflow: hidden;
}
.chat-header {
  padding: 16px 20px;
  background: var(--bg-page);
  text-align: center;
}
.chat-header h1 {
  font-size: 17px;
  font-weight: 600;
  margin-bottom: 4px;
}
.chat-header a {
  font-size: 13px;
  color: var(--accent);
  text-decoration: none;
}
.chat-header a:hover {
  text-decoration: underline;
}
.chat-log {
  max-height: 280px;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.message {
  max-width: 70%;
  padding: 10px 14px;
  font-size: 14px;
  border-radius: 16px;
}
.sent {
  background: var(--accent);
  color: #fff;
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}
.received {
  background: #e2e2e5;
  color: var(--text-primary);
  align-self: flex-start;
  border-bottom-left-radius: 4px;
}
.no-messages {
  text-align: center;
  color: var(--text-secondary);
  font-size: 14px;
  padding: 40px 0;
}

/* === Input === */
.chat-input {
  display: flex;
  padding: 12px 16px;
  background: var(--bg-page);
}
.chat-input input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid #d1d1d6;
  border-radius: 18px;
  font-size: 14px;
  outline: none;
}
.chat-input input:focus {
  border-color: var(--accent);
}
.chat-input button {
  background: none;
  border: none;
  margin-left: 12px;
  font-size: 18px;
  cursor: pointer;
  color: var(--accent);
  transition: transform .1s;
}
.chat-input button:hover {
  transform: scale(1.1);
}

/* === Floating Button & Modal === */
.chat-floating-button {
  position: fixed;
  bottom: 24px; right: 24px; z-index: 1050;
}
.apple-chat-btn {
  width: 56px; height: 56px;
  border: none; border-radius: 50%;
  background: var(--accent);
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 12px var(--shadow-light);
  cursor: pointer; position: relative;
}
.apple-chat-btn .material-symbols-outlined {
  font-size: 28px; color: #fff;
}
.chat-unread-badge {
  position: absolute; top: 6px; right: 6px;
  background: #ff4d4d; color: #fff;
  width: 18px; height: 18px;
  border-radius: 50%;
  font-size: 10px; font-weight: 600;
  display: none;
  align-items: center; justify-content: center;
}

.minimal-modal {
  border: none; border-radius: 12px;
  box-shadow: 0 8px 24px var(--shadow-light);
}
.minimal-header {
  background: var(--bg-card);
  padding: 16px 24px;
}
.minimal-close {
  filter: brightness(0.6);
}
.minimal-body {
  background: var(--bg-page);
  padding: 0;
}

.modal-open {
  overflow: auto !important;
}

/* Permette di interagire con la pagina “dietro” il modal */
.modal {
  /* il container occupa comunque tutto lo schermo, ma ora lascia passare i click */
  pointer-events: none;
}

/* invece ripristina i click (e la selezione) dentro alla dialog stessa */
.modal-dialog {
  pointer-events: all;
}

/* per default lo span esiste ma rimane nascosto finché vuoto */
.conversation-list .unread-badge {
  display: none;
}

/* quando ha testo dentro, mostralo */
.conversation-list .unread-badge:empty {
  display: none;
}
.conversation-list .unread-badge:not(:empty) {
  display: inline-flex !important;
  position: absolute !important;
  top: -5px !important;
  right: -5px !important;
  background-color: #ff3b30 !important;
  color: #fff !important;
  min-width: 20px !important;
  height: 20px !important;
  line-height: 20px !important;
  font-size: 12px !important;
  font-weight: bold !important;
  text-align: center !important;
  border-radius: 50% !important;
  align-items: center !important;
  justify-content: center !important;
  box-shadow: 0 0 0 1px rgba(255,255,255,0.9) !important;
  z-index: 2000 !important;
}
.chat-info {
  position: relative !important;
}
.conversation-list li {
  position: relative;
  overflow: visible !important;
}

/* Solo sul contenitore cliccabile */
.conversation-list .conversation-item {
  cursor: pointer !important;
}
