/* ══════════════════════════════════════════════════════
   FloresYa Chat — Liquid Glass Light Theme
   Diseño claro, glassmorphism suave, no fatiga la vista
   ══════════════════════════════════════════════════════ */

:root {
  --bg: #f0f2f5;
  --bg-glass: rgba(255, 255, 255, 0.72);
  --bg-glass-hover: rgba(255, 255, 255, 0.88);
  --bg-glass-active: rgba(232, 245, 233, 0.8);
  --bg-chat: #e8ece5;

  --text: #1a1a2e;
  --text-secondary: #5f6368;
  --text-muted: #9aa0a6;

  --green: #25d366;
  --green-dark: #128c7e;
  --green-light: #dcf8c6;
  --blue: #4a90d9;
  --orange: #ff9800;
  --red: #e53935;

  --border: rgba(0, 0, 0, 0.08);
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 30px rgba(0,0,0,0.12);
  --shadow-glass: 0 8px 32px rgba(0,0,0,0.06);

  --radius: 12px;
  --radius-sm: 8px;
  --radius-full: 999px;

  --font: 'Inter', -apple-system, system-ui, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  overflow: hidden;
  display: flex;
}

.hidden { display: none !important; }

/* ── GLASS EFFECT ── */
.glass {
  background: var(--bg-glass);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-glass);
}

/* ══ LOGIN ══ */
#login-view {
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #e8f5e9 0%, #f3e5f5 50%, #e3f2fd 100%);
}

.login-card {
  background: var(--bg-glass);
  backdrop-filter: blur(24px) saturate(200%);
  -webkit-backdrop-filter: blur(24px) saturate(200%);
  border: 1px solid rgba(255,255,255,0.5);
  box-shadow: var(--shadow-lg);
  border-radius: 20px;
  padding: 3rem 2.5rem;
  width: 100%; max-width: 380px;
  text-align: center;
}

.login-logo { font-size: 3rem; margin-bottom: 0.75rem; }
.login-card h1 { font-size: 1.5rem; font-weight: 700; color: var(--green-dark); margin-bottom: 0.25rem; }
.login-sub { color: var(--text-secondary); font-size: 0.9rem; margin-bottom: 2rem; }

.login-card input {
  width: 100%;
  padding: 0.85rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: rgba(255,255,255,0.7);
  font-size: 0.95rem;
  font-family: var(--font);
  margin-bottom: 1rem;
  color: var(--text);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.login-card input:focus {
  outline: none;
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(37, 211, 102, 0.15);
}

.login-card input::placeholder { color: var(--text-muted); }

.error-msg {
  color: var(--red);
  font-size: 0.85rem;
  margin-bottom: 0.75rem;
  padding: 0.5rem;
  background: rgba(229, 57, 53, 0.08);
  border-radius: var(--radius-sm);
}

.btn-primary {
  width: 100%;
  padding: 0.85rem;
  background: var(--green);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
}

.btn-primary:hover { background: var(--green-dark); }
.btn-primary:active { transform: scale(0.98); }

/* ══ INBOX LAYOUT ══ */
#inbox-view {
  width: 100%; height: 100%;
  display: flex;
}

/* ── SIDEBAR ── */
.sidebar {
  width: 320px;
  height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--bg-glass);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-right: 1px solid var(--border);
  flex-shrink: 0;
}

.sidebar-top {
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
}

.agent-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.avatar-sm {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--green);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 0.9rem;
  flex-shrink: 0;
}

.agent-name {
  font-weight: 600;
  font-size: 0.95rem;
}

.btn-icon {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s, color 0.15s;
}

.btn-icon:hover {
  background: rgba(0,0,0,0.05);
  color: var(--text);
}

.sidebar-search {
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid var(--border);
}

.sidebar-search svg {
  color: var(--text-muted);
  flex-shrink: 0;
}

.sidebar-search input {
  flex: 1;
  border: none;
  background: transparent;
  font-size: 0.88rem;
  font-family: var(--font);
  color: var(--text);
  padding: 6px 0;
}

.sidebar-search input:focus { outline: none; }
.sidebar-search input::placeholder { color: var(--text-muted); }

.sidebar-filters {
  display: flex;
  gap: 6px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
}

.filter-btn {
  padding: 5px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  background: transparent;
  font-size: 0.78rem;
  font-weight: 500;
  font-family: var(--font);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.filter-btn:hover { background: rgba(0,0,0,0.04); }

.filter-btn.active {
  background: var(--green);
  color: #fff;
  border-color: var(--green);
}

/* ── CONVERSATION LIST ── */
.conv-list {
  flex: 1;
  overflow-y: auto;
}

.conv-list::-webkit-scrollbar { width: 5px; }
.conv-list::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.1); border-radius: 3px; }

.conv-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  cursor: pointer;
  border-bottom: 1px solid rgba(0,0,0,0.04);
  transition: background 0.12s;
}

.conv-item:hover { background: rgba(0,0,0,0.03); }

.conv-item.active {
  background: var(--bg-glass-active);
  border-left: 3px solid var(--green);
}

.conv-item.resolved { opacity: 0.55; }

.conv-info {
  flex: 1;
  min-width: 0;
}

.conv-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 2px;
}

.conv-name {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.conv-time {
  font-size: 0.72rem;
  color: var(--text-muted);
  flex-shrink: 0;
  margin-left: 8px;
}

.conv-preview {
  font-size: 0.82rem;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.badge-bot-mini {
  display: inline-block;
  background: rgba(37, 211, 102, 0.15);
  color: var(--green-dark);
  font-size: 0.65rem;
  font-weight: 600;
  padding: 1px 5px;
  border-radius: 4px;
  margin-right: 4px;
}

.tag-dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  margin-right: 3px;
  vertical-align: middle;
}

/* ══ CHAT COLUMN ══ */
.chat-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--bg-chat);
  background-image:
    url("data:image/svg+xml,%3Csvg width='80' height='80' viewBox='0 0 80 80' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='%23000000' fill-opacity='0.02'%3E%3Cpath d='M0 0h40v40H0V0zm40 40h40v40H40V40zm0-40h2l-2 2V0zm0 4l4-4h2l-6 6V4zm0 4l8-8h2L40 10V8zm0 4L52 0h2L40 14v-2zm0 4L56 0h2L40 18v-2zm0 4L60 0h2L40 22v-2zm0 4L64 0h2L40 26v-2zm0 4L68 0h2L40 30v-2zm0 4L72 0h2L40 34v-2zm0 4L76 0h2L40 38v-2z'/%3E%3C/g%3E%3C/svg%3E");
  position: relative;
  min-width: 0;
}

.empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.empty-icon { font-size: 3.5rem; margin-bottom: 1rem; opacity: 0.5; }
.empty-state h2 { font-weight: 500; color: var(--text-secondary); margin-bottom: 0.5rem; }
.empty-state p { color: var(--text-muted); font-size: 0.9rem; }

/* ── CHAT HEADER ── */
.chat-active {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100%;
}

.chat-header {
  padding: 10px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg-glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  z-index: 5;
}

.chat-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.chat-header-left h2 {
  font-size: 1.05rem;
  font-weight: 600;
}

.chat-header-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.badge {
  font-size: 0.72rem;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-weight: 500;
}

.badge-bot {
  background: rgba(37, 211, 102, 0.12);
  color: var(--green-dark);
}

.badge-agent {
  background: rgba(255, 152, 0, 0.12);
  color: var(--orange);
}

/* Toggle */
.toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.toggle input { display: none; }

.toggle-track {
  position: relative;
  width: 40px; height: 22px;
  background: #ccc;
  border-radius: 11px;
  transition: background 0.2s;
}

.toggle-track::after {
  content: '';
  position: absolute;
  top: 2px; left: 2px;
  width: 18px; height: 18px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.toggle input:checked + .toggle-track {
  background: var(--green);
}

.toggle input:checked + .toggle-track::after {
  transform: translateX(18px);
}

.btn-outline {
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-glass);
  font-size: 0.82rem;
  font-weight: 500;
  font-family: var(--font);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s;
}

.btn-outline:hover {
  background: rgba(0,0,0,0.05);
  border-color: var(--text-muted);
}

/* ── MESSAGES ── */
.messages-area {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.messages-area::-webkit-scrollbar { width: 6px; }
.messages-area::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.1); border-radius: 3px; }

.msg {
  max-width: 65%;
  padding: 7px 12px;
  border-radius: 10px;
  font-size: 0.9rem;
  line-height: 1.45;
  position: relative;
  word-wrap: break-word;
  -webkit-user-select: text;
  user-select: text;
  cursor: text;
}

.msg-in {
  align-self: flex-start;
  background: #fff;
  border: 1px solid rgba(0,0,0,0.06);
  border-top-left-radius: 3px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}

.msg-out {
  align-self: flex-end;
  background: var(--green-light);
  border-top-right-radius: 3px;
}

.msg-out.bot-msg {
  background: #e3f0fc;
}

.msg-out.agent-msg {
  background: var(--green-light);
}

.msg-system {
  align-self: center;
  max-width: 80%;
  background: rgba(255, 249, 196, 0.8);
  border-radius: 8px;
  font-size: 0.78rem;
  color: var(--text-secondary);
  text-align: center;
  padding: 4px 14px;
  border: 1px solid rgba(0,0,0,0.04);
}

.msg-reaction {
  max-width: none !important;
  background: transparent !important;
  box-shadow: none !important;
  padding: 2px 8px !important;
  border: none !important;
}
.reaction-emoji {
  font-size: 1.6rem;
  line-height: 1;
}
.msg-reaction .msg-time {
  font-size: 0.65rem;
  margin-left: 4px;
}

.msg-sender {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--green-dark);
  margin-bottom: 1px;
}

.msg-time {
  display: block;
  text-align: right;
  font-size: 0.68rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.msg img {
  max-width: 240px;
  border-radius: 8px;
  display: block;
  margin-bottom: 4px;
}

/* Load more */
.load-more {
  text-align: center;
  padding: 8px 16px;
  margin: 4px auto 10px;
  background: rgba(0,0,0,0.05);
  border-radius: 16px;
  font-size: 0.78rem;
  color: var(--text-secondary);
  cursor: pointer;
  width: fit-content;
  transition: background 0.15s;
}

.load-more:hover { background: rgba(0,0,0,0.09); }

/* New message indicator */
.new-msg-pill {
  position: absolute;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--green);
  color: #fff;
  padding: 6px 18px;
  border-radius: 20px;
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  z-index: 10;
  box-shadow: var(--shadow-md);
  animation: slideUp 0.25s ease;
}

/* Typing */
.typing-dot {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-style: italic;
  padding: 4px 12px;
  align-self: flex-start;
}

/* ── CHAT INPUT ── */
.chat-input {
  padding: 10px 20px;
  display: flex;
  align-items: flex-end;
  gap: 10px;
  background: var(--bg-glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--border);
}

.chat-input textarea {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 10px 16px;
  font-size: 0.9rem;
  font-family: var(--font);
  resize: none;
  max-height: 100px;
  background: #fff;
  color: var(--text);
  transition: border-color 0.15s;
}

.chat-input textarea:focus {
  outline: none;
  border-color: var(--green);
}

.chat-input textarea::placeholder { color: var(--text-muted); }

.btn-send {
  width: 42px; height: 42px;
  border-radius: 50%;
  background: var(--green);
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s, transform 0.1s;
  flex-shrink: 0;
}

.btn-send:hover { background: var(--green-dark); }
.btn-send:active { transform: scale(0.93); }

/* Quick replies */
.qr-wrap { position: relative; }

.qr-dropdown {
  position: absolute;
  bottom: 100%;
  left: 0;
  min-width: 280px;
  max-height: 260px;
  overflow-y: auto;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 6px;
  margin-bottom: 8px;
  z-index: 100;
}

.qr-item {
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--text-secondary);
  transition: background 0.12s;
}

.qr-item:hover { background: rgba(0,0,0,0.04); }
.qr-item strong { color: var(--green-dark); }

/* ══ DETAIL COLUMN ══ */
.detail-col {
  width: 280px;
  height: 100%;
  background: var(--bg-glass);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-left: 1px solid var(--border);
  overflow-y: auto;
  flex-shrink: 0;
}

.detail-header {
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
}

.detail-header h3 {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
}

#detail-content { padding: 16px 18px; }

.detail-section { margin-bottom: 18px; }

.detail-label {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 4px;
  font-weight: 600;
}

.detail-value {
  font-size: 0.88rem;
  color: var(--text);
  margin-bottom: 3px;
}

/* Tags in detail */
.tags-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 8px;
}

.tag-pill {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  color: #fff;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 0.72rem;
  font-weight: 500;
  cursor: pointer;
  transition: opacity 0.15s;
}

.tag-pill:hover { opacity: 0.7; }

.tag-add-select {
  width: 100%;
  padding: 5px 8px;
  font-size: 0.8rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--text);
  font-family: var(--font);
  margin-top: 4px;
}

/* Status buttons in detail */
.status-row {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.status-btn {
  padding: 4px 10px;
  font-size: 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  font-family: var(--font);
  cursor: pointer;
  transition: all 0.15s;
  color: var(--text-secondary);
}

.status-btn:hover { background: rgba(0,0,0,0.04); }
.status-btn.current { background: var(--green); color: #fff; border-color: var(--green); }

/* Orders list */
.order-link {
  display: block;
  padding: 5px 0;
  color: var(--green-dark);
  text-decoration: none;
  font-size: 0.85rem;
  transition: color 0.15s;
}

.order-link:hover { color: var(--blue); text-decoration: underline; }

/* ══ TOAST ══ */
.toast-box {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: #fff;
  border: 1px solid var(--border);
  padding: 12px 18px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  font-size: 0.88rem;
  animation: slideUp 0.3s ease;
  max-width: 320px;
}

.toast.ok { border-left: 4px solid var(--green); }
.toast.err { border-left: 4px solid var(--red); }

/* ══ ANIMATIONS ══ */
@keyframes slideUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ══ AGENT DASHBOARD ══ */
.agent-dashboard {
  width: 100%;
  max-width: 700px;
  margin-top: 1.5rem;
  padding: 0 1rem;
}

.dashboard-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 0.75rem;
}

.dashboard-summary {
  display: flex;
  gap: 12px;
  margin-bottom: 1rem;
  justify-content: center;
  flex-wrap: wrap;
}

.dash-card {
  background: var(--bg-glass);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 20px;
  text-align: center;
  min-width: 120px;
  box-shadow: var(--shadow-sm);
}

.dash-card-number {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--green-dark);
  line-height: 1;
}

.dash-card-label {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.agent-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 10px;
}

.agent-card {
  background: var(--bg-glass);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: var(--shadow-sm);
}

.agent-card-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--green);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 0.85rem;
  flex-shrink: 0;
}

.agent-card-avatar.admin-avatar { background: var(--orange); }

.agent-card-info { flex: 1; min-width: 0; }

.agent-card-name {
  font-weight: 600;
  font-size: 0.85rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.agent-card-role {
  font-size: 0.68rem;
  color: var(--text-muted);
  text-transform: uppercase;
}

.agent-card-stats {
  display: flex;
  gap: 10px;
  margin-top: 4px;
}

.agent-stat {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.agent-stat strong {
  color: var(--text);
}

/* ══ REPLY QUOTE ══ */
.reply-preview {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px 6px 16px;
  background: rgba(37, 211, 102, 0.08);
  border-left: 3px solid var(--green);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 0.82rem;
  color: var(--text-secondary);
  margin: 0 20px;
  animation: slideUp 0.2s ease;
}

.reply-preview-text {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.reply-preview-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1.1rem;
  padding: 2px 6px;
  border-radius: 4px;
}

.reply-preview-close:hover { background: rgba(0,0,0,0.06); }

.msg-quoted {
  background: rgba(0,0,0,0.04);
  border-left: 3px solid var(--green);
  border-radius: 4px;
  padding: 4px 8px;
  margin-bottom: 4px;
  font-size: 0.78rem;
  color: var(--text-secondary);
  cursor: pointer;
}

.msg-reply-btn {
  display: none;
  position: absolute;
  top: 2px;
  background: rgba(255,255,255,0.9);
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 24px; height: 24px;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  color: var(--text-secondary);
  box-shadow: var(--shadow-sm);
}

.msg-in .msg-reply-btn { right: -30px; }
.msg-out .msg-reply-btn { left: -30px; }

.msg:hover .msg-reply-btn { display: flex; }

/* ── Back button (hidden on desktop) ── */
.back-btn { display: none; }

/* ══ RESPONSIVE ══ */
@media (max-width: 1100px) {
  .detail-col { width: 240px; }
}

@media (max-width: 900px) {
  .detail-col { display: none !important; }
  .sidebar { width: 280px; }
}

/* ── MOBILE: WhatsApp-style single-panel navigation ── */
@media (max-width: 680px) {
  #inbox-view {
    position: relative;
    overflow: hidden;
  }

  .sidebar {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0; left: 0;
    z-index: 20;
    transition: transform 0.25s ease;
  }

  .chat-col {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0; left: 0;
    z-index: 10;
    transform: translateX(100%);
    transition: transform 0.25s ease;
  }

  /* When a chat is open: slide sidebar out, chat in */
  #inbox-view.mobile-chat-open .sidebar {
    transform: translateX(-100%);
  }

  #inbox-view.mobile-chat-open .chat-col {
    transform: translateX(0);
  }

  .detail-col { display: none !important; }

  /* Show back button on mobile */
  .back-btn {
    display: flex;
    margin-right: 4px;
  }

  /* Chat header adjustments */
  .chat-header {
    padding: 8px 12px;
  }

  .chat-header-left h2 {
    font-size: 0.95rem;
  }

  .chat-header-right {
    gap: 8px;
  }

  .btn-outline {
    padding: 5px 10px;
    font-size: 0.75rem;
  }

  .toggle-label { display: none; }

  /* Messages area */
  .messages-area {
    padding: 10px 12px;
  }

  .msg {
    max-width: 82%;
    font-size: 0.88rem;
  }

  .msg img {
    max-width: 200px;
  }

  /* Chat input */
  .chat-input {
    padding: 8px 10px;
    gap: 6px;
  }

  .chat-input textarea {
    padding: 8px 14px;
    font-size: 0.88rem;
  }

  .btn-send {
    width: 38px;
    height: 38px;
  }

  /* Sidebar search & filters */
  .sidebar-search input {
    font-size: 0.85rem;
  }

  .sidebar-filters {
    padding: 8px 12px;
    gap: 4px;
    overflow-x: auto;
    flex-wrap: nowrap;
  }

  .filter-btn {
    padding: 4px 12px;
    font-size: 0.75rem;
  }

  /* Conversation items */
  .conv-item {
    padding: 10px 14px;
  }

  /* Login */
  .login-card {
    margin: 0 16px;
    padding: 2rem 1.5rem;
  }

  /* Toast at bottom center on mobile */
  .toast-box {
    right: 50%;
    transform: translateX(50%);
    bottom: 16px;
  }

  .toast {
    max-width: 280px;
  }
}

/* ── Reply button fix: inside message, not clipped ── */
.msg { position: relative; }
.msg-reply-btn {
  display: none !important;
  position: absolute;
  top: 4px;
  background: rgba(255,255,255,0.95);
  border: 1px solid rgba(0,0,0,0.1);
  border-radius: 50%;
  width: 26px; height: 26px;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  color: #555;
  box-shadow: 0 1px 4px rgba(0,0,0,0.1);
  z-index: 5;
  padding: 0;
  line-height: 1;
}
.msg-in .msg-reply-btn { right: 4px; }
.msg-out .msg-reply-btn { left: 4px; }
.msg:hover .msg-reply-btn { display: flex !important; }
/* Mobile: show on tap via JS class */
.msg.show-reply .msg-reply-btn { display: flex !important; }

/* ══ MODAL ══ */
.modal-overlay {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: rgba(0,0,0,0.4);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9000;
}
.modal-card {
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.2);
  width: 100%;
  max-width: 420px;
  margin: 16px;
  overflow: hidden;
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid #eee;
}
.modal-header h3 { font-size: 1rem; font-weight: 600; margin: 0; }
.modal-body { padding: 20px; }
.modal-label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: #555;
  margin-bottom: 6px;
}
.modal-input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 1rem;
  font-family: var(--font);
  margin-bottom: 12px;
}
.modal-input:focus { outline: none; border-color: var(--green); box-shadow: 0 0 0 3px rgba(37,211,102,0.15); }
.modal-template-preview {
  background: #f0f2f5;
  padding: 12px 14px;
  border-radius: 8px;
  font-size: 0.85rem;
  color: #555;
  line-height: 1.5;
  border-left: 3px solid var(--green);
}
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 20px;
  border-top: 1px solid #eee;
}
