/* Always Booked Inbox — UI styles. Clean, professional, dependency-free. */

:root {
  --bg: #f4f6f8;
  --panel: #ffffff;
  --border: #e2e6ea;
  --text: #1c2530;
  --muted: #6b7785;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --book: #059669;
  --book-dark: #047857;
  --danger: #dc2626;
  --in-bubble: #eef1f5;
  --out-bubble: #2563eb;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}
.hidden { display: none !important; }
.muted { color: var(--muted); }
.spacer { flex: 1; }

/* ── Toasts ─────────────────────────────────────────────── */
.toasts {
  position: fixed; top: 16px; right: 16px; z-index: 1000;
  display: flex; flex-direction: column; gap: 8px; max-width: 380px;
}
.toast {
  background: #111827; color: #fff; padding: 12px 14px; border-radius: 8px;
  box-shadow: var(--shadow); font-size: 13px; animation: slideIn .15s ease;
}
.toast.error { background: var(--danger); }
.toast.ok { background: var(--book); }
@keyframes slideIn { from { transform: translateY(-8px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ── Login ──────────────────────────────────────────────── */
.login-view { display: flex; align-items: center; justify-content: center; height: 100vh; }
.login-card {
  background: var(--panel); padding: 32px; border-radius: 12px; box-shadow: var(--shadow);
  width: 340px; display: flex; flex-direction: column; gap: 14px;
}
.login-card h1 { margin: 0; font-size: 20px; }
.login-card label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
.login-card input {
  padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; font-size: 14px;
}
.form-error { color: var(--danger); font-size: 13px; min-height: 16px; }

/* ── App shell ──────────────────────────────────────────── */
.app-view { display: flex; flex-direction: column; height: 100vh; }
.topbar {
  display: flex; align-items: center; gap: 16px; padding: 0 16px; height: 56px;
  background: var(--panel); border-bottom: 1px solid var(--border); flex: 0 0 auto;
}
.brand { font-weight: 700; font-size: 16px; }
.brand span { color: var(--primary); }
.tabs { display: flex; gap: 4px; }
.tab {
  background: none; border: none; padding: 8px 14px; border-radius: 8px; cursor: pointer;
  color: var(--muted); font-size: 14px; font-weight: 600;
}
.tab.active { background: #eef2ff; color: var(--primary); }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
#who { font-size: 13px; }

/* ── Buttons ────────────────────────────────────────────── */
button { font-family: inherit; }
.btn-primary {
  background: var(--primary); color: #fff; border: none; padding: 9px 16px;
  border-radius: 8px; font-weight: 600; cursor: pointer;
}
.btn-primary:hover { background: var(--primary-dark); }
.btn-primary:disabled { opacity: .6; cursor: not-allowed; }
.btn-secondary {
  background: #fff; color: var(--text); border: 1px solid var(--border);
  padding: 9px 14px; border-radius: 8px; font-weight: 600; cursor: pointer;
}
.btn-secondary:hover { background: #f7f9fb; }
.btn-book {
  background: var(--book); color: #fff; border: none; padding: 9px 16px;
  border-radius: 8px; font-weight: 600; cursor: pointer;
}
.btn-book:hover { background: var(--book-dark); }
.btn-link { background: none; border: none; color: var(--primary); cursor: pointer; font-size: 13px; }
.btn-icon { background: none; border: none; cursor: pointer; font-size: 16px; color: var(--muted); }

/* ── Inbox layout ───────────────────────────────────────── */
.inbox { display: flex; flex: 1 1 auto; min-height: 0; }
.conv-list {
  width: 360px; flex: 0 0 360px; border-right: 1px solid var(--border);
  background: var(--panel); display: flex; flex-direction: column; min-height: 0;
}
.filters { padding: 12px; border-bottom: 1px solid var(--border); display: flex; flex-direction: column; gap: 8px; }
.filter-row { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  background: #f1f4f7; border: 1px solid transparent; color: var(--muted);
  padding: 5px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; cursor: pointer;
}
.chip.active { background: var(--primary); color: #fff; }
.chip-ch.active { background: #111827; }
.search { padding: 8px 12px; border: 1px solid var(--border); border-radius: 8px; font-size: 13px; }

.conv-rows { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1 1 auto; }
.conv-rows .empty { padding: 24px; color: var(--muted); text-align: center; }
.conv-row {
  padding: 12px 14px; border-bottom: 1px solid var(--border); cursor: pointer; display: flex; gap: 10px;
}
.conv-row:hover { background: #f7f9fb; }
.conv-row.active { background: #eef2ff; }
.conv-row .avatar {
  width: 36px; height: 36px; border-radius: 50%; background: #dde3ea; color: #54616e;
  display: flex; align-items: center; justify-content: center; font-weight: 700; flex: 0 0 36px;
}
.conv-main { flex: 1 1 auto; min-width: 0; }
.conv-top { display: flex; align-items: center; gap: 6px; }
.conv-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-biz { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-snippet { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.badge {
  font-size: 10px; font-weight: 700; padding: 2px 6px; border-radius: 4px; text-transform: uppercase;
}
.badge.instagram { background: #fde7f3; color: #be185d; }
.badge.instantly { background: #e0f2fe; color: #0369a1; }
.badge.ghl       { background: #ede9fe; color: #6d28d9; }
.badge.whatsapp  { background: #dcfce7; color: #15803d; }
.status-tag { font-size: 10px; font-weight: 700; padding: 2px 6px; border-radius: 4px; background: #f1f4f7; color: var(--muted); }
.status-tag.new { background: #fee2e2; color: #b91c1c; }
.status-tag.booked { background: #dcfce7; color: #15803d; }
.status-tag.escalated { background: #fef3c7; color: #b45309; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--primary); flex: 0 0 8px; margin-left: auto; }

/* ── Thread ─────────────────────────────────────────────── */
.thread { flex: 1 1 auto; display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.thread-empty { margin: auto; color: var(--muted); }
.thread-inner { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.thread-header {
  padding: 14px 18px; border-bottom: 1px solid var(--border); background: var(--panel);
  display: flex; align-items: center; gap: 10px; flex: 0 0 auto;
}
.thread-header .h-name { font-weight: 700; font-size: 15px; }
.thread-header .h-sub { font-size: 12px; color: var(--muted); }

.messages { flex: 1 1 auto; overflow-y: auto; padding: 18px; display: flex; flex-direction: column; gap: 10px; }
.bubble { max-width: 70%; padding: 10px 13px; border-radius: 14px; font-size: 14px; line-height: 1.4; word-wrap: break-word; white-space: pre-wrap; }
.bubble.in { align-self: flex-start; background: var(--in-bubble); color: var(--text); border-bottom-left-radius: 4px; }
.bubble.out { align-self: flex-end; background: var(--out-bubble); color: #fff; border-bottom-right-radius: 4px; }
.bubble .meta { display: block; font-size: 10px; margin-top: 4px; opacity: .75; }
.bubble.out.failed { background: var(--danger); }
.bubble.out.pending { background: #93c5fd; }
.delivery { font-weight: 700; }

.reply-area { border-top: 1px solid var(--border); background: var(--panel); padding: 12px 14px; flex: 0 0 auto; }
.reply-status { font-size: 12px; min-height: 14px; margin-bottom: 4px; }
.reply-box { width: 100%; min-height: 64px; resize: vertical; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; font-size: 14px; font-family: inherit; }
.reply-actions { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.status-select { padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; font-size: 13px; }

/* ── WhatsApp ───────────────────────────────────────────── */
.whatsapp { flex: 1 1 auto; overflow-y: auto; padding: 24px; }
.whatsapp h2 { margin-top: 0; }
.wa-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.wa-card { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 16px; box-shadow: var(--shadow); }
.wa-card .wa-name { font-weight: 700; }
.wa-card .wa-num { color: var(--muted); font-size: 13px; margin-bottom: 8px; }
.wa-card .wa-msg { background: #f7f9fb; border-radius: 8px; padding: 10px; font-size: 13px; white-space: pre-wrap; margin-bottom: 12px; }
.empty { color: var(--muted); }

/* ── Modal ──────────────────────────────────────────────── */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.4); display: flex; align-items: center; justify-content: center; z-index: 900; }
.modal-card { background: #fff; border-radius: 12px; width: min(900px, 92vw); max-height: 88vh; display: flex; flex-direction: column; overflow: hidden; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--border); font-weight: 700; }
.modal-body { padding: 18px; overflow: auto; display: flex; flex-direction: column; gap: 12px; }
.modal-body iframe { width: 100%; height: 70vh; border: none; border-radius: 8px; }
.modal-body label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
.modal-body input { padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; font-size: 14px; }
