/*
  style.css — BotDesk Shared Design System
  Matches agent-inbox.html prototype layout and spacing.
*/

/* ════════════════════════════════════════════════════
   1. CSS Custom Properties
   ════════════════════════════════════════════════════ */
:root {
  --sidebar-width: 64px;

  --sidebar-bg: #1a1a2e;
  --sidebar-text: #c8c7d4;
  --sidebar-text-active: #ffffff;
  --accent: #6c63ff;
  --accent-hover: #5a52e0;
  --bg: #f5f4f0;
  --surface: #ffffff;
  --border: #e8e6e0;
  --text-primary: #1a1a1e;
  --text-secondary: #6b6b7a;
  --text-muted: #9b9baa;

  --badge-bot-bg: #e8f5f0;
  --badge-bot-text: #0a7a50;
  --badge-escalated-bg: #fff3e8;
  --badge-escalated-text: #b85c00;
  --badge-human-bg: #eef0ff;
  --badge-human-text: #4338ca;
  --badge-resolved-bg: #f0f0f2;
  --badge-resolved-text: #6b6b7a;
  --badge-open-bg: #e0f2fe;
  --badge-open-text: #0369a1;

  --font-body: 'DM Sans', sans-serif;
  --font-mono: 'DM Mono', monospace;

  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;

  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-full: 9999px;

  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.07);
}

/* ════════════════════════════════════════════════════
   2. Reset & Base
   ════════════════════════════════════════════════════ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  font-family: var(--font-body);
  font-size: 14px;
  color: var(--text-primary);
  background: var(--bg);
  line-height: 1.5;
}

/* ════════════════════════════════════════════════════
   3. App Shell Layout
   ════════════════════════════════════════════════════ */
body:not(.login-page) {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

.sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 20px 0;
  gap: 6px;
  z-index: 100;
}

.sidebar-logo { margin-bottom: 16px; }

.logo-icon {
  width: 36px;
  height: 36px;
  background: var(--accent);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  font-family: var(--font-mono);
  letter-spacing: -1px;
}

.sidebar-nav {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  flex: 1;
  width: 100%;
  align-items: center;
}

.sidebar-bottom {
  width: 100%;
  display: flex;
  justify-content: center;
}

.nav-item {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  background: transparent;
  border: none;
  color: var(--sidebar-text);
  font-size: 18px;
  transition: background 0.15s, color 0.15s;
}

.nav-item:hover,
.nav-item.active {
  background: rgba(108, 99, 255, 0.25);
  color: #a89eff;
}

.app-main {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* ════════════════════════════════════════════════════
   4a. Inbox Layout
   ════════════════════════════════════════════════════ */
.inbox-layout {
  display: flex;
  height: 100%;
  overflow: hidden;
}

/* ── Left: Conversation List ── */
.conv-panel {
  width: 300px;
  min-width: 260px;
  border-right: 1px solid var(--border);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.conv-panel-header {
  padding: 20px 16px 12px;
  border-bottom: 1px solid var(--border);
}

.panel-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 12px;
  color: var(--text-primary);
}

.conv-search {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  font-family: var(--font-body);
  font-size: 13px;
  background: var(--bg);
  outline: none;
}

.conv-search:focus { border-color: var(--accent); }

/* Filter tabs */
.filter-tabs {
  display: flex;
  padding: 10px 16px;
  gap: 6px;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  scrollbar-width: none;
}
.filter-tabs::-webkit-scrollbar { display: none; }

.tab {
  padding: 4px 10px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border);
  background: transparent;
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  color: var(--text-secondary);
  white-space: nowrap;
  transition: all 0.15s;
}

.tab:hover { border-color: var(--accent); color: var(--accent); }
.tab.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* Conv list */
.conv-list { flex: 1; overflow-y: auto; }

/* Conversation item — flex row with avatar */
.conv-item {
  display: flex;
  padding: 12px 16px;
  gap: 10px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.1s;
  position: relative;
}

.conv-item:hover { background: var(--bg); }

.conv-item.active { background: #f0eeff; }

.conv-item.active::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--accent);
  border-radius: 0 2px 2px 0;
}

/* Initials avatar in conv list */
.conv-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
}

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

.conv-row1 {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 3px;
}

.conv-name {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.conv-time {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  flex-shrink: 0;
  margin-left: 6px;
}

.conv-row2 {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
}

.conv-preview {
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

.conv-list-empty {
  padding: var(--space-xl);
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}

/* ── Center: Chat Panel ── */
.chat-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
}

.chat-panel-header {
  padding: 14px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Small avatar in chat header */
.chat-header-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  background: var(--bg);
  color: var(--text-muted);
}

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

.chat-contact-name {
  font-size: 15px;
  font-weight: 600;
}

.chat-contact-sub {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 1px;
}

.chat-badges { flex-shrink: 0; }

/* Message thread */
.chat-thread {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.chat-empty-state {
  text-align: center;
  color: var(--text-muted);
  margin-top: var(--space-xl);
  font-size: 13px;
}

/* Message row — avatar beside bubble (matches prototype) */
.message {
  display: flex;
  flex-direction: row;
  align-items: flex-end;
  gap: 8px;
  margin-bottom: 2px;
}

/* Agent messages: reverse so avatar goes to the right */
.message.from-agent,
.message.from-bot { flex-direction: row-reverse; }

/* Small circular avatar beside each bubble */
.msg-avatar-sm {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 600;
}

/* Bubble + meta column */
.message-content {
  display: flex;
  flex-direction: column;
  max-width: min(68%, 540px);
}

.message-bubble {
  padding: 9px 13px;
  border-radius: 14px;
  font-size: 13.5px;
  line-height: 1.5;
}

.from-contact .message-bubble {
  background: #f0f0f4;
  color: var(--text-primary);
  border-bottom-left-radius: var(--radius-sm);
}

.from-bot .message-bubble {
  background: #e8f5f0;
  color: #0a7a50;
  border-bottom-right-radius: var(--radius-sm);
}

.from-agent .message-bubble {
  background: var(--accent);
  color: #fff;
  border-bottom-right-radius: var(--radius-sm);
}

.message-meta {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 3px;
}

.message.from-agent .message-meta,
.message.from-bot .message-meta { text-align: right; }

/* Date divider between message groups */
.msg-date-divider {
  text-align: center;
  font-size: 11px;
  color: var(--text-muted);
  margin: 12px 0 8px;
  display: flex;
  align-items: center;
  gap: 10px;
  align-self: stretch;
}

.msg-date-divider::before,
.msg-date-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* Reply box */
.reply-box {
  padding: 14px 20px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  gap: var(--space-sm);
  align-items: flex-end;
}

.reply-input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-family: var(--font-body);
  font-size: 13.5px;
  resize: none;
  outline: none;
  background: var(--bg);
  line-height: 1.5;
  max-height: 100px;
}

.reply-input:focus { border-color: var(--accent); }
.reply-input:disabled, button:disabled { opacity: 0.4; cursor: not-allowed; }

/* ── Right: Info Panel ── */
.info-panel {
  width: 260px;
  min-width: 240px;
  border-left: 1px solid var(--border);
  background: var(--surface);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

/* Each section has padding + bottom border */
.info-section {
  padding: 16px;
  border-bottom: 1px solid var(--border);
}

.info-section-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  margin-bottom: 12px;
}

/* Contact card (centered, avatar + name + phone) */
.contact-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 6px;
}

.contact-avatar-lg {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 600;
  background: var(--bg);
  color: var(--text-muted);
  margin-bottom: 4px;
}

.contact-card-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.contact-card-phone {
  font-size: 12px;
  color: var(--text-secondary);
  font-family: var(--font-mono);
}

/* Info rows (label: value side by side) */
.info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 5px 0;
  font-size: 12.5px;
}

.info-row-label { color: var(--text-secondary); }
.info-row-value { font-weight: 500; color: var(--text-primary); }

/* Refresh status pinned to bottom */
.refresh-status {
  font-size: 11px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  padding: 12px 16px;
  margin-top: auto;
}

/* Quick action buttons in Actions section */
.quick-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.quick-btn {
  padding: 8px 12px;
  border-radius: var(--radius-md);
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid var(--border);
  font-family: var(--font-body);
  background: transparent;
  color: var(--text-primary);
  text-align: left;
  width: 100%;
  transition: all 0.15s;
}

.quick-btn:hover:not(:disabled) { background: var(--bg); }

.quick-btn.btn-escalate-action { color: var(--badge-escalated-text); border-color: var(--badge-escalated-text); }
.quick-btn.btn-escalate-action:hover:not(:disabled) { background: var(--badge-escalated-bg); }

.quick-btn.btn-resolve-action { color: var(--text-secondary); }

/* ════════════════════════════════════════════════════
   4b. Badges
   ════════════════════════════════════════════════════ */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 7px;
  border-radius: var(--radius-full);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  flex-shrink: 0;
}

.badge-open     { background: var(--badge-open-bg);     color: var(--badge-open-text); }
.badge-bot      { background: var(--badge-bot-bg);      color: var(--badge-bot-text); }
.badge-escalated{ background: var(--badge-escalated-bg);color: var(--badge-escalated-text); }
.badge-human    { background: var(--badge-human-bg);    color: var(--badge-human-text); }
.badge-resolved { background: var(--badge-resolved-bg); color: var(--badge-resolved-text); }

/* ════════════════════════════════════════════════════
   4c. Buttons
   ════════════════════════════════════════════════════ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 7px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  background: var(--surface);
  color: var(--text-primary);
  transition: background 0.15s, opacity 0.15s;
}

.btn:hover:not(:disabled) { background: var(--bg); }

.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }

.btn-link {
  background: none;
  border: none;
  padding: 0;
  font-size: 12px;
  color: var(--accent);
  cursor: pointer;
  font-family: var(--font-body);
  font-weight: 500;
}

.btn-link:hover { text-decoration: underline; }

/* ════════════════════════════════════════════════════
   4d. Form Inputs
   ════════════════════════════════════════════════════ */
.form-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.form-group label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
}

.form-group input {
  padding: var(--space-sm) var(--space-md);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-family: var(--font-body);
  font-size: 14px;
  background: var(--bg);
  outline: none;
  transition: border-color 0.15s;
}

.form-group input:focus { border-color: var(--accent); }

.error-message {
  background: #fef2f2;
  color: #dc2626;
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-md);
  font-size: 13px;
  border: 1px solid #fecaca;
}

/* ════════════════════════════════════════════════════
   5. Login Page
   ════════════════════════════════════════════════════ */
body.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--bg);
}

.login-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: var(--space-xl);
  width: 100%;
  max-width: 400px;
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
}

.login-logo { text-align: center; }

.logo-text {
  font-size: 28px;
  font-weight: 700;
  color: var(--accent);
  font-family: var(--font-mono);
  letter-spacing: -1px;
}

.login-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: var(--space-xs);
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

/* ════════════════════════════════════════════════════
   6. Loading & Empty States
   ════════════════════════════════════════════════════ */
.loading-state {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-muted);
  font-size: 14px;
}

/* ════════════════════════════════════════════════════
   7. Edit Contact Modal
   ════════════════════════════════════════════════════ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: 0 20px 40px rgba(0,0,0,0.15);
  width: 420px;
  max-width: 90vw;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

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

.modal-title {
  font-size: 15px;
  font-weight: 600;
}

.modal-close {
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  color: var(--text-muted);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
}

.modal-close:hover { background: var(--bg); color: var(--text-primary); }

.modal-body {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.modal-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: var(--space-sm);
  justify-content: flex-end;
}

/* ════════════════════════════════════════════════════
   8. Contacts Page
   ════════════════════════════════════════════════════ */
.contacts-page {
  padding: 24px;
  height: 100%;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.contacts-table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  flex: 1;
}

.contacts-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.contacts-table thead th {
  background: var(--bg);
  padding: 10px 16px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}

.contacts-table tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
}

.contacts-table tbody tr:last-child { border-bottom: none; }
.contacts-table tbody tr:hover { background: var(--bg); }

.contacts-table td {
  padding: 12px 16px;
  color: var(--text-primary);
  vertical-align: middle;
}

.contact-name { font-weight: 500; }
.contact-sub  { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

.table-empty {
  text-align: center;
  color: var(--text-muted);
  padding: 40px 16px !important;
}

.pagination {
  display: flex;
  align-items: center;
  gap: 12px;
}

.pagination-info {
  font-size: 13px;
  color: var(--text-muted);
}

/* ════════════════════════════════════════════════════
   9. Scrollbars
   ════════════════════════════════════════════════════ */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: var(--radius-full); }

/* ════════════════════════════════════════════════════
   10. Chat Header Enhancements
   ════════════════════════════════════════════════════ */

.chat-header-name-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.chat-header-meta {
  font-size: 11.5px;
  color: var(--text-muted);
  margin-top: 2px;
}

.chat-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  margin-left: auto;
}

.btn-sm {
  padding: 5px 12px;
  font-size: 12.5px;
}

/* ════════════════════════════════════════════════════
   11. Quick Replies
   ════════════════════════════════════════════════════ */

.quick-replies {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 20px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
}

.quick-replies-label {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  flex-shrink: 0;
}

.quick-reply-chip {
  padding: 4px 10px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border);
  background: var(--bg);
  font-family: var(--font-body);
  font-size: 12px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.quick-reply-chip:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: #f0eeff;
}

/* ════════════════════════════════════════════════════
   12. Assigned To Section
   ════════════════════════════════════════════════════ */

.assigned-card {
  display: flex;
  align-items: center;
  gap: 10px;
}

.assigned-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
  background: var(--bg);
  color: var(--text-muted);
}

.assigned-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}

.assigned-role {
  font-size: 11.5px;
  color: var(--text-muted);
  margin-top: 1px;
}

/* ════════════════════════════════════════════════════
   13. Labels Section
   ════════════════════════════════════════════════════ */

.conv-labels-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.label-chip {
  padding: 3px 9px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 500;
  background: var(--badge-human-bg);
  color: var(--badge-human-text);
  text-transform: capitalize;
}

/* ════════════════════════════════════════════════════
   14. Reassign Agent Modal
   ════════════════════════════════════════════════════ */

.agent-option-list {
  max-height: 360px;
  overflow-y: auto;
}

.agent-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  cursor: pointer;
  transition: background 0.1s;
  border-bottom: 1px solid var(--border);
}

.agent-option:last-child { border-bottom: none; }
.agent-option:hover { background: var(--bg); }
.agent-option-active { background: #f0eeff; }
.agent-option-active:hover { background: #e8e4ff; }

.agent-option-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
}

.agent-option-info { flex: 1; }

.agent-option-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}

.agent-option-role {
  font-size: 11.5px;
  color: var(--text-muted);
  margin-top: 1px;
  text-transform: capitalize;
}

.agent-option-check {
  color: var(--accent);
  font-size: 14px;
  font-weight: 700;
}

/* ════════════════════════════════════════════════════
   15. Sidebar Expand / Collapse
   ════════════════════════════════════════════════════ */

.sidebar { transition: width 0.22s ease; overflow: hidden; }

/* Brand name — hidden by default, shown when expanded */
.sidebar-brand {
  display: none;
  font-size: 14px;
  font-weight: 700;
  color: #fff;
  font-family: var(--font-mono);
  white-space: nowrap;
  letter-spacing: -0.5px;
}

/* Nav labels — hidden by default */
.nav-label {
  display: none;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  color: inherit;
}

/* Sidebar logo as flex row */
.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 0;
  transition: gap 0.22s ease;
}

/* ── Expanded state ── */
.sidebar.sidebar-expanded { width: 220px; align-items: flex-start; padding: 20px 12px; }

.sidebar.sidebar-expanded .sidebar-logo {
  gap: 10px;
  width: 100%;
  padding: 0 4px;
}

.sidebar.sidebar-expanded .sidebar-brand { display: inline; }
.sidebar.sidebar-expanded .nav-label     { display: inline; }

.sidebar.sidebar-expanded .sidebar-nav {
  width: 100%;
  align-items: stretch;
}

.sidebar.sidebar-expanded .nav-item {
  width: 100%;
  border-radius: 8px;
  padding: 0 12px;
  justify-content: flex-start;
  gap: 10px;
}

.sidebar.sidebar-expanded .sidebar-bottom {
  flex-direction: column;
  width: 100%;
  align-items: stretch;
  gap: 4px;
}

/* ════════════════════════════════════════════════════
   16. Contacts Two-Panel Layout
   ════════════════════════════════════════════════════ */

.contacts-layout {
  display: flex;
  height: 100%;
  overflow: hidden;
}

/* Left list panel — reuses conv-panel sizing */
.contacts-list-panel {
  width: 300px;
  min-width: 260px;
  border-right: 1px solid var(--border);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.contacts-pagination {
  padding: 10px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

/* Right contact detail panel */
.contact-detail-panel {
  flex: 1;
  overflow-y: auto;
  background: var(--bg);
  display: flex;
  flex-direction: column;
}

.contact-detail-inner {
  max-width: 660px;
  width: 100%;
  margin: 0 auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Contact detail header card */
.contact-detail-header {
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
}

.contact-detail-avatar {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 700;
}

.contact-detail-header-info { flex: 1; min-width: 0; }

.contact-detail-name {
  font-size: 17px;
  font-weight: 700;
  color: var(--text-primary);
}

.contact-detail-sub {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 3px;
  font-family: var(--font-mono);
}

/* Info section card */
.contact-info-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 20px;
}

.contact-info-section .info-section-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  margin-bottom: 12px;
}

/* Edit form */
.contact-edit-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* Conversation history list */
.contact-conv-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.contact-conv-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg);
  gap: 12px;
  overflow: hidden;
}

.contact-conv-item-left {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow: hidden;
  flex: 1;
}

.contact-conv-item-date {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  flex-shrink: 0;
  font-family: var(--font-mono);
}