/* Empêche les débordements horizontaux dus aux padding/width */
*,
*::before,
*::after {
  box-sizing: border-box;
}

/* Évite tout scroll horizontal global */
html, body {
  max-width: 100%;
  overflow-x: hidden;
}

/* Images et médias ne doivent jamais dépasser */
img, video, iframe {
  max-width: 100%;
  height: auto;
  display: block;
}

/* === Base Styles === */
body {
  font-family: "Segoe UI", sans-serif;
  background-color: #f5ffff;
  color: #222;
  margin: 0;
  padding: 20px;
  font-size: 16px;
  line-height: 1.6;
  overflow-x: hidden;
}

a {
  color: #199397;
  text-decoration: none;
  word-wrap: break-word;
}

a:hover {
  text-decoration: underline;
}

/* === Navigation Bar === */
.nav-links {
  margin: 0;           /* important: un margin peut pousser */
  padding: 0;
}

.nav-links a {
  overflow-wrap: anywhere; /* évite débordement par texte */
}

nav.navbar {
  background-color: #50d4d9;
  color: white;

  /* Full bleed across viewport despite body padding */
  width: calc(100% + 40px);
  max-width: none;

  padding: 20px;
  margin: -20px -20px 10px -20px;

  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;

  box-sizing: border-box;
  overflow: visible;
  position: relative;
  z-index: 200;
}

.nav-logo {
  flex: 1 1 auto;
  display: flex;
  justify-content: flex-start;
  margin-bottom: 20px;
  max-width: 100%;
  box-sizing: border-box;
  overflow-x: hidden;
}

.nav-logo img {
  height: 42px;
  max-height: 50px;
  max-width: 100%;
  width: auto;
  display: block;
}

.nav-links {
  display: flex;
  flex-wrap: wrap;
  gap: 1.2rem;
  padding: 0;
  margin: 0;
  list-style: none;
  justify-content: flex-end;
  width: 100%;
}

.nav-links a {
  color: white;
  font-weight: bold;
  white-space: nowrap;
  font-size: 1rem;
}

/* === Éditeur de description (Quill) === */
#description-editor {
  min-height: 200px;
  font-size: 1rem;
  font-family: inherit;
}

.ql-toolbar.ql-snow {
  border-radius: 6px 6px 0 0;
  border-color: #ccc;
  background: #f9f9f9;
  flex-wrap: wrap;
}

.ql-container.ql-snow {
  border-radius: 0 0 6px 6px;
  border-color: #ccc;
  font-size: 1rem;
  font-family: inherit;
  background: white;
}

.ql-editor {
  background: white;
}

/* === Bandeaux de présence (edit_event.php) === */
.presence-banner {
  background-color: #e8f4fd;
  border: 1px solid #90caf9;
  border-radius: 6px;
  padding: 10px 14px;
  margin-bottom: 12px;
  color: #1565c0;
  font-size: 0.95rem;
  position: sticky;
  top: 0;
  z-index: 700;
}

.stale-banner {
  background-color: #fff3cd;
  border: 1px solid #ffc107;
  border-radius: 6px;
  padding: 10px 14px;
  margin-bottom: 12px;
  color: #856404;
  font-size: 0.95rem;
}

.stale-banner a {
  color: #856404;
  font-weight: bold;
  text-decoration: underline;
}

/* === Nav Dropdown (groupes collapsables dans la navbar) === */
.nav-dropdown {
  position: relative;
}

.nav-dropdown-toggle {
  background: none;
  border: none;
  color: white;
  font-weight: bold;
  font-size: 1rem;
  cursor: pointer;
  padding: 0;
  margin: 0;
  width: auto;
  white-space: nowrap;
}

.nav-dropdown-toggle:hover {
  background: none;
  text-decoration: underline;
}

.nav-dropdown-menu {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background-color: #3bbfc4;
  list-style: none;
  padding: 6px 0;
  margin: 0;
  border-radius: 6px;
  min-width: 210px;
  z-index: 100;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
}

.nav-dropdown-menu a {
  display: block;
  padding: 8px 16px;
  white-space: nowrap;
  font-weight: bold;
  color: white;
}

.nav-dropdown-menu a:hover {
  background-color: rgba(255, 255, 255, 0.18);
  text-decoration: none;
}

.nav-dropdown.open .nav-dropdown-menu {
  display: block;
}

/* === Headings === */
h1, h2, h3 {
  color: #0e6062;
  margin-top: 1em;
  margin-bottom: 0.5em;
  word-wrap: break-word;
}

/* === Buttons === */
button {
  background-color: #50d4d9;
  border: none;
  padding: 10px 18px;
  color: white;
  font-weight: bold;
  border-radius: 6px;
  cursor: pointer;
  margin-top: 5px;
  font-size: 1rem;
}

button:hover {
  background-color: #3cbfc4;
}

/* === Forms === */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="datetime-local"],
textarea {
  width: 100%;
  max-width: 500px;
  padding: 10px;
  border: 1px solid #ccc;
  border-radius: 4px;
  margin-top: 6px;
  margin-bottom: 16px;
  font-size: 1rem;
  box-sizing: border-box;
}

label {
  font-weight: bold;
  display: block;
  margin-top: 10px;
}

/* === Containers === */
.container {
  max-width: 900px;
  margin: 0 auto;
  padding: 1rem;
}

/* === Message Boxes === */
.message {
  background-color: #e4fbfc;
  border-left: 4px solid #50d4d9;
  padding: 10px;
  margin-bottom: 10px;
  border-radius: 4px;
}

.error {
  background-color: #ffd2d2;
  border-left: 4px solid #ff5a5a;
  padding: 10px;
  margin-bottom: 10px;
  border-radius: 4px;
}

/* === Attendance List === */
.attendance-list {
  margin: 10px 0;
  padding: 0;
  list-style-type: none;
}

.attendance-list li::before {
  content: "🎵 ";
  color: #50d4d9;
}

/* === Comments === */
.comment {
  border-bottom: 1px solid #ccc;
  padding-bottom: 8px;
  margin-bottom: 12px;
}

/* === Events list wrap === */
.event-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-top: 1rem;
}

.event-card {
  padding: 1rem;
  border: 1px solid #ccc;
  border-radius: 12px;
  background-color: #ffffff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
  transition: transform 0.2s ease;
}

.event-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.08);
}

.event-card-link {
  text-decoration: none;
  color: inherit;
  display: block;
}

.event-card-link:hover .event-card {
  /*background-color: #f0fcfc;*/
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.1);
}

.event-card-other {
  border:#0e6062 1px dashed;
  background-color: #e6fffb;
}

/* === Remember Label === */
.remember-label {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  font-size: 1rem;
  width: 100%;
  max-width: 500px;
  margin-top: 10px;
}

.remember-label input[type="checkbox"] {
  margin: 0;
  width: auto;
}

/* === Responsive Media Queries === */
@media (max-width: 768px) {
  body {
    padding: 15px;
    font-size: 16px;
  }

  h1, h2, h3 {
    font-size: 1.3em;
  }

  nav.navbar {
    flex-direction: column;
    align-items: center;
    width: calc(100% + 30px);
    margin: -15px -15px 10px -15px;
  }

  .nav-logo {
    justify-content: center;
    width: 100%;
    margin-bottom: 35px;
  }

  .nav-links {
    justify-content: center;
    width: 100%;
  }

  button {
    width: 100%;
    font-size: 1rem;
  }

  input[type="text"],
  input[type="email"],
  input[type="password"],
  input[type="datetime-local"],
  textarea {
    width: 100%;
    font-size: 1rem;
  }

  input[type="checkbox"] {
    width: auto;
  }

  .container {
    padding: 0.5rem;
  }
}

@media (max-width: 480px) {
  body {
    font-size: 20px;
  }

  h1, h2, h3 {
    font-size: 1.1em;
  }

  button {
    font-size: 0.95rem;
  }
}

/* === Event description box === */
.event-description-box {
  background: #fff;
  border: 1.5px solid #209ca0;
  border-radius: 14px;
  padding: 16px 18px;
  margin: 18px 0;
  box-sizing: border-box;
  max-width: 100%;
  overflow-wrap: break-word;
  word-break: break-word;
  font-size: 1rem;
  box-shadow: 0 2px 8px rgba(80, 212, 217, 0.04);
}

.event-description-box,
.event-description-box * {
  line-height: 1.42 !important;
}

.event-description-box p,
.event-description-box ol,
.event-description-box ul {
  margin: 0;
  padding: 0;
}

.event-description-box ol,
.event-description-box ul {
  padding-left: 1.5em;
}

/* === Calendar (table-based, cohérent avec calendar.php) === */
.calendar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 10px 0 14px;
}

.calendar-title {
  margin: 0;
  text-align: center;
  flex: 1;
}

.calendar-nav {
  font-weight: bold;
  font-size: 1.2rem;
  padding: 6px 10px;
  border-radius: 8px;
  background: #e4fbfc;
  color: #0e6062;
}

/* ✅ Animation changement de mois (classe ajoutée via JS) */
.calendar-animate {
  animation: monthFadeSlide 220ms ease;
}

@keyframes monthFadeSlide {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.calendar-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.calendar-table th {
  text-align: center;
  padding: 10px 6px;
  color: #0e6062;
  background: #e4fbfc;
  font-weight: 700;
}

.calendar-cell {
  position: relative;
  height: 78px;
  padding: 8px;
  vertical-align: top;
  border: 1px solid rgba(32, 156, 160, 0.25);
  background: #fff;
  cursor: default;
}

.calendar-empty {
  background: transparent;
  border: none;
}

.calendar-daynum {
  font-weight: 700;
  color: #0e6062;
}

.calendar-cell.has-events {
  cursor: pointer;
}

/* ✅ Jours avec événements légèrement colorés */
.calendar-cell.has-events {
  background: rgba(80, 212, 217, 0.16);
}
.calendar-cell.has-events:hover {
  background: rgba(80, 212, 217, 0.25);
}

/* ✅ Jour actuel entouré d’un cercle */
.calendar-cell.is-today .calendar-daynum {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  border: 2px solid #209ca0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
}

.calendar-dot {
  position: absolute;
  bottom: 8px;
  left: 8px;
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: #e53935;
}

/* Popover */
.calendar-popover {
  position: absolute;
  z-index: 9999;
  width: min(340px, calc(100vw - 20px));
}

.calendar-popover-inner {
  background: #fff;
  border: 1.5px solid #209ca0;
  border-radius: 14px;
  padding: 12px;
  box-shadow: 0 8px 20px rgba(0,0,0,0.12);
}

.calendar-popover-date {
  font-weight: 800;
  color: #0e6062;
  margin-bottom: 10px;
}

.calendar-popover-list {
  list-style: none;
  padding: 0;
  margin: 0 0 10px 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.calendar-popover-item {
  display: flex;
  gap: 10px;
  align-items: baseline;
}

.calendar-popover-time {
  font-weight: 800;
  color: #199397;
  min-width: 52px;
}

.calendar-popover-link {
  color: #0e6062;
  font-weight: 700;
  text-decoration: underline;
}

.calendar-popover-close {
  width: 100%;
}

/* Mobile calendar tweaks */
@media (max-width: 480px) {
  .calendar-cell { height: 66px; padding: 6px; }
  .calendar-dot { bottom: 6px; left: 6px; }
}

/* ===== Event participation status ===== */

.event-status {
  display: inline-block;
  margin-top: 6px;
  font-size: 0.9rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 8px;
}

.status-yes {
  background: #e6f7ee;
  color: #1a7f4b;
}

.status-no {
  background: #ffeaea;
  color: #b42318;
}

.status-none {
  background: #f0f0f0;
  color: #555;
}

.status-pending {
  background: #f3e6d3;
  color: #6b3e13;
}

/* ===== Month separator ===== */
.month-separator {
  /* margin: 1.8rem 0 1rem 0; */
  /* padding-top: 1rem; */
  /*border-top: 1px solid rgba(80, 212, 217, 0.25);*/
  font-size: 0.8rem;
  color: #999;
  font-weight: 500;
  letter-spacing: 0.5px;
  text-transform: capitalize;
}

/* ═══════════════════════════════════════════════════════
   CHAT — styles globaux
═══════════════════════════════════════════════════════ */

/* Badge navbar */
.chat-nav-badge {
  display: inline-block;
  background: #e84040;
  color: white;
  font-size: 0.7rem;
  font-weight: 700;
  border-radius: 10px;
  padding: 1px 5px;
  line-height: 1.4;
  margin-left: 3px;
  vertical-align: top;
}

/* Lien discussion sur event.php */
.event-chat-link {
  display: inline-block;
  margin: 6px 0 14px;
  background: #e8f9fa;
  border: 1px solid #50d4d9;
  border-radius: 20px;
  padding: 6px 14px;
  font-weight: bold;
  color: #0e6062;
  font-size: 0.95rem;
  text-decoration: none;
}
.event-chat-link:hover { background: #cff4f5; }

/* ── Chat list page (chat.php) ─────────────────────────── */
.chat-page {
  max-width: 680px;
  margin: 0 auto;
  padding: 0 0 80px;
}

.chat-list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0 4px;
}
.chat-list-header h2 { margin: 0; }

.chat-new-btn {
  background: #50d4d9;
  color: white;
  border: none;
  border-radius: 20px;
  padding: 8px 16px;
  font-size: 0.95rem;
  font-weight: bold;
  cursor: pointer;
  width: auto;
}
.chat-new-btn:hover { background: #3bbfc4; }

.chat-section { margin-top: 16px; }
.chat-section-title {
  font-size: 0.82rem;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  margin: 0 0 6px;
}

.chat-thread-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.chat-thread-item { border-bottom: 1px solid #eee; }
.chat-thread-item:last-child { border-bottom: none; }

.chat-thread-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 4px;
  text-decoration: none;
  color: inherit;
}
.chat-thread-link:hover { background: #f5feff; border-radius: 8px; }

.chat-thread-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: #50d4d9;
  color: white;
  font-weight: bold;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.chat-thread-info { flex: 1; min-width: 0; }
.chat-thread-name { font-weight: bold; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-thread-preview { font-size: 0.88rem; color: #777; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.chat-thread-unread .chat-thread-name { color: #0e6062; }
.chat-thread-unread .chat-thread-preview { color: #333; font-weight: 600; }

.chat-thread-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex-shrink: 0; }
.chat-thread-time { font-size: 0.78rem; color: #aaa; }
.chat-badge {
  background: #50d4d9;
  color: white;
  border-radius: 10px;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 1px 6px;
}

.chat-empty { color: #aaa; font-size: 0.9rem; padding: 6px 0; }

/* User picker in new-thread modal */
.chat-user-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 8px 0 12px;
  max-height: 180px;
  overflow-y: auto;
}
.chat-user-chip {
  display: flex;
  align-items: center;
  gap: 5px;
  background: #f0f0f0;
  border-radius: 16px;
  padding: 4px 10px;
  cursor: pointer;
  font-size: 0.9rem;
}
.chat-user-chip input { margin: 0; }
.chat-user-chip:has(input:checked) { background: #cff4f5; color: #0e6062; font-weight: bold; }

/* ── Thread page (chat_thread.php) ─────────────────────── */
.chat-thread-page {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 90px); /* overridden by JS via --navbar-h */
  max-width: 760px;
  margin: 0 auto;
}

.chat-thread-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 4px 8px;
  border-bottom: 1px solid #eee;
  flex-shrink: 0;
}
.chat-back-btn {
  font-size: 1.3rem;
  text-decoration: none;
  color: #0e6062;
  padding: 0 6px;
}
.chat-thread-header-name { flex: 1; min-width: 0; }
.chat-thread-header-name strong { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-member-count { font-size: 0.8rem; color: #888; }
.chat-thread-header-actions { display: flex; align-items: center; gap: 10px; }
.chat-members-btn {
  background: none;
  border: 1px solid #ccc;
  border-radius: 6px;
  cursor: pointer;
  padding: 3px 7px;
  font-size: 1rem;
  width: auto;
}

/* Notification toggle switch */
.chat-notif-toggle {
  position: relative;
  display: inline-flex;
  align-items: center;
  cursor: pointer;
}
.chat-notif-toggle input { opacity: 0; width: 0; height: 0; position: absolute; }
.chat-notif-slider {
  width: 36px;
  height: 20px;
  background: #ccc;
  border-radius: 20px;
  transition: background 0.2s;
  position: relative;
}
.chat-notif-slider::before {
  content: '';
  position: absolute;
  width: 14px;
  height: 14px;
  left: 3px;
  top: 3px;
  background: white;
  border-radius: 50%;
  transition: transform 0.2s;
}
.chat-notif-toggle input:checked + .chat-notif-slider { background: #50d4d9; }
.chat-notif-toggle input:checked + .chat-notif-slider::before { transform: translateX(16px); }

/* Member panel */
.chat-member-panel {
  background: #f9f9f9;
  border-bottom: 1px solid #eee;
  padding: 10px 12px;
  font-size: 0.9rem;
  flex-shrink: 0;
}
.chat-member-panel ul { list-style: none; padding: 0; margin: 6px 0; display: flex; flex-wrap: wrap; gap: 6px; }
.chat-member-panel li { display: flex; align-items: center; gap: 4px; background: #eee; border-radius: 14px; padding: 3px 10px; }
.chat-remove-member-btn {
  background: none;
  border: none;
  color: #999;
  cursor: pointer;
  font-size: 0.75rem;
  padding: 0;
  width: auto;
  line-height: 1;
}
.chat-add-member { display: flex; gap: 8px; margin-top: 8px; align-items: center; }
.chat-add-member select { flex: 1; padding: 5px; border-radius: 6px; border: 1px solid #ccc; }
.chat-add-member button { white-space: nowrap; width: auto; padding: 5px 12px; }

/* Messages area */
.chat-messages-area {
  flex: 1;
  overflow-y: auto;
  padding: 10px 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.chat-load-more-btn {
  align-self: center;
  background: #f0f0f0;
  color: #555;
  border: none;
  border-radius: 14px;
  padding: 5px 14px;
  font-size: 0.85rem;
  cursor: pointer;
  margin-bottom: 10px;
  width: auto;
}
.chat-load-more-btn:hover { background: #e0e0e0; }

.chat-date-separator {
  text-align: center;
  font-size: 0.78rem;
  color: #aaa;
  margin: 10px 0 4px;
}
.chat-date-separator span {
  background: white;
  padding: 0 8px;
}

/* Message bubbles */
.chat-msg {
  display: flex;
  flex-direction: column;
  max-width: 72%;
  align-self: flex-start;
  margin-bottom: 6px;
}
.chat-msg-mine { align-self: flex-end; align-items: flex-end; }

.chat-msg-sender { font-size: 0.78rem; color: #888; margin-bottom: 2px; padding-left: 4px; }

.chat-reply-context {
  background: rgba(0,0,0,0.05);
  border-left: 3px solid #50d4d9;
  border-radius: 4px;
  padding: 3px 8px;
  font-size: 0.8rem;
  color: #555;
  margin-bottom: 3px;
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat-reply-author { font-weight: bold; margin-right: 5px; }

.chat-msg-bubble {
  background: #f0f0f0;
  border-radius: 16px 16px 16px 4px;
  padding: 8px 12px;
  max-width: 100%;
  word-break: break-word;
  position: relative;
}
.chat-msg-mine .chat-msg-bubble {
  background: #d0f3f4;
  border-radius: 16px 16px 4px 16px;
}
.chat-msg-deleted .chat-msg-bubble { background: #f5f5f5; }

.chat-msg-body { font-size: 0.97rem; line-height: 1.45; }
.chat-msg-img { max-width: 220px; border-radius: 10px; display: block; margin-top: 4px; }
.chat-msg-time {
  font-size: 0.72rem;
  color: #aaa;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 6px;
  margin-top: 3px;
  text-align: right;
}
.chat-msg-time .chat-read-by-inline { font-size: 0.72rem; color: #aaa; }
.chat-msg-deleted-text { color: #bbb; font-size: 0.88rem; }

/* Message action buttons */
.chat-msg-actions {
  display: flex;
  gap: 4px;
  margin-top: 2px;
  opacity: 0;
  transition: opacity 0.15s;
}
.chat-msg:hover .chat-msg-actions,
.chat-msg:focus-within .chat-msg-actions { opacity: 1; }
.chat-action-btn {
  background: none;
  border: 1px solid #ddd;
  border-radius: 10px;
  font-size: 0.8rem;
  padding: 2px 6px;
  cursor: pointer;
  color: #555;
  width: auto;
}
.chat-action-btn:hover { background: #eee; }

/* Reactions */
.chat-reactions {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 3px;
}
.chat-reaction {
  background: #f5f5f5;
  border: 1px solid #e0e0e0;
  border-radius: 12px;
  padding: 2px 7px;
  font-size: 0.85rem;
  cursor: pointer;
  width: auto;
  display: flex;
  align-items: center;
  gap: 3px;
}
.chat-reaction:hover { background: #e8e8e8; }
.chat-reaction-mine { background: #cff4f5; border-color: #50d4d9; font-weight: bold; }

/* Read-by */
.chat-read-by { display: none; } /* replaced by inline version inside .chat-msg-time */

/* Emoji quick-picker */
.chat-emoji-picker {
  position: fixed;
  background: white;
  border: 1px solid #ddd;
  border-radius: 12px;
  padding: 8px 10px;
  display: flex;
  gap: 6px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.15);
  z-index: 500;
  flex-wrap: wrap;
  max-width: 220px;
  font-size: 1.4rem;
}
.chat-emoji-picker span { cursor: pointer; border-radius: 6px; padding: 2px 4px; }
.chat-emoji-picker span:hover { background: #f0f0f0; }

/* Reply bar */
.chat-reply-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #e8f9fa;
  border-top: 1px solid #50d4d9;
  padding: 5px 10px;
  font-size: 0.88rem;
  color: #0e6062;
  flex-shrink: 0;
}
.chat-reply-bar button { background: none; border: none; cursor: pointer; font-size: 1rem; width: auto; padding: 0 4px; }

/* Input area */
.chat-input-area {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 6px 6px;
  border-top: 1px solid #eee;
  background: white;
  flex-shrink: 0;
}
.chat-image-label {
  cursor: pointer;
  font-size: 1.3rem;
  display: flex;
  align-items: center;
  align-self: center;
  padding: 0;
  line-height: 1;
}
#imagePreviewWrap { display: flex; align-items: center; gap: 4px; }
#imagePreviewWrap button { background: none; border: none; cursor: pointer; width: auto; font-size: 0.85rem; color: #888; }

.chat-msg-input {
  flex: 1;
  border: 1px solid #ccc;
  border-radius: 20px;
  padding: 8px 14px;
  font-size: 0.97rem;
  resize: none;
  outline: none;
  max-height: 120px;
  overflow-y: auto;
  font-family: inherit;
  line-height: 1.4;
  display: block;
  margin: 0;
  align-self: center;
}
.chat-msg-input:focus { border-color: #50d4d9; }

.chat-send-btn {
  background: #50d4d9;
  color: white;
  border: none;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  font-size: 1rem;
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  align-self: center;
}
.chat-send-btn:disabled { opacity: 0.5; }
.chat-send-btn:hover:not(:disabled) { background: #3bbfc4; }

.chat-delete-thread-btn {
  background: none;
  border: 1px solid #ffaaaa;
  border-radius: 6px;
  cursor: pointer;
  padding: 3px 7px;
  font-size: 1rem;
  width: auto;
  color: #c0392b;
}
.chat-delete-thread-btn:hover { background: #fff0f0; }

/* Modal shared */
.chat-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 600;
}
.chat-modal {
  background: white;
  border-radius: 12px;
  padding: 20px 24px;
  max-width: 420px;
  width: 90%;
  position: relative;
}
.chat-modal h3 { margin-top: 0; }
.chat-modal label { display: block; margin: 10px 0 4px; font-weight: bold; font-size: 0.9rem; }
.chat-modal input[type=text] { width: 100%; }
.chat-modal button[type=button]:not(.chat-modal-close) { margin-top: 12px; width: 100%; }
.chat-modal-close {
  position: absolute;
  top: 10px;
  right: 12px;
  background: none;
  border: none;
  font-size: 1.1rem;
  cursor: pointer;
  width: auto;
  padding: 0;
  color: #888;
}

/* ── Responsive ───────────────────────────────────────── */
@media (max-width: 600px) {
  .chat-msg { max-width: 88%; }
}