/* ===== APP SHELL ===== */
.app-body {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ===== SIDEBAR ===== */
.sidebar {
  width: 220px;
  flex-shrink: 0;
  background: var(--bg-elevated);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 20px 0;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 20px 24px;
}

.logo-mark {
  width: 32px;
  height: 32px;
  background: var(--accent);
  color: #0a0a0f;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 16px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.logo-text {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--fg);
}

.sidebar-nav {
  flex: 1;
  padding: 0 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: var(--fg-muted);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
  position: relative;
  cursor: pointer;
}

.nav-item:hover {
  background: var(--bg-card);
  color: var(--fg);
}

.nav-item.active {
  background: var(--accent-glow);
  color: var(--accent);
  border: 1px solid rgba(232,168,56,0.15);
}

.nav-badge {
  margin-left: auto;
  background: var(--accent);
  color: #0a0a0f;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 100px;
}

.sidebar-footer {
  padding: 12px;
  border-top: 1px solid var(--border);
  margin-top: 8px;
}

/* ===== MAIN ===== */
.app-main {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.view {
  flex: 1;
  overflow-y: auto;
  padding: 32px 36px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.view.hidden { display: none; }

.view-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.view-title {
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--fg);
  margin-bottom: 4px;
}

.view-subtitle {
  color: var(--fg-muted);
  font-size: 0.9rem;
}

.view-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s;
  text-decoration: none;
}

.btn-accent {
  background: var(--accent);
  color: #0a0a0f;
  font-weight: 600;
}

.btn-accent:hover { background: var(--accent-subtle); }

.btn-ghost {
  background: transparent;
  color: var(--fg-muted);
  border-color: var(--border);
}

.btn-ghost:hover {
  background: var(--bg-card);
  color: var(--fg);
}

.btn-ai {
  background: var(--accent-glow);
  color: var(--accent);
  border-color: rgba(232,168,56,0.2);
  font-weight: 600;
}

.btn-ai:hover { background: rgba(232,168,56,0.22); }

.btn-sm { padding: 5px 10px; font-size: 0.82rem; }

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ===== PANELS ===== */
.panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

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

.panel-title {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 600;
  color: var(--fg);
}

.panel-list {
  display: flex;
  flex-direction: column;
}

/* ===== STATS ===== */
.stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.stat-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.stat-icon--amber { background: var(--accent-glow); color: var(--accent); }
.stat-icon--green { background: rgba(52,211,153,0.1); color: #34d399; }
.stat-icon--blue  { background: rgba(96,165,250,0.1); color: #60a5fa; }
.stat-icon--purple { background: rgba(167,139,250,0.1); color: #a78bfa; }

.stat-val {
  display: block;
  font-family: var(--font-display);
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--fg);
  line-height: 1;
  margin-bottom: 4px;
}

.stat-label {
  font-size: 0.82rem;
  color: var(--fg-muted);
}

/* ===== DASHBOARD COLS ===== */
.dash-cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.dash-col { display: flex; flex-direction: column; }

/* Dashboard list items */
.dash-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.15s;
}

.dash-item:last-child { border-bottom: none; }
.dash-item:hover { background: rgba(255,255,255,0.02); }

.dash-item-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--accent-glow);
  color: var(--accent);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

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

.dash-item-name {
  font-weight: 500;
  font-size: 0.9rem;
  color: var(--fg);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dash-item-sub {
  font-size: 0.8rem;
  color: var(--fg-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dash-item-meta {
  font-size: 0.78rem;
  color: var(--fg-muted);
  flex-shrink: 0;
}

/* ===== INBOX ===== */
.inbox-layout {
  display: flex;
  height: calc(100vh - 64px);
  margin: -32px -36px;
}

.thread-list-panel {
  width: 320px;
  flex-shrink: 0;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.thread-list-header {
  padding: 16px 16px 12px;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.thread-filters {
  display: flex;
  gap: 4px;
}

.filter-btn {
  padding: 4px 12px;
  border-radius: 100px;
  font-size: 0.8rem;
  font-weight: 500;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--fg-muted);
  cursor: pointer;
  transition: all 0.15s;
}

.filter-btn.active {
  background: var(--accent-glow);
  border-color: rgba(232,168,56,0.25);
  color: var(--accent);
}

.filter-btn:hover:not(.active) {
  background: var(--bg-card);
  color: var(--fg);
}

.thread-list {
  flex: 1;
  overflow-y: auto;
}

.thread-item {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.15s;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

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

.thread-item.active {
  background: var(--accent-glow);
  border-left: 2px solid var(--accent);
}

.thread-item-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.thread-item-name {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--fg);
}

.thread-item-time {
  font-size: 0.75rem;
  color: var(--fg-muted);
  flex-shrink: 0;
}

.thread-item-subject {
  font-size: 0.82rem;
  color: var(--fg-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.thread-item-preview {
  font-size: 0.8rem;
  color: var(--fg-muted);
  opacity: 0.7;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.thread-item-badges {
  display: flex;
  gap: 6px;
  align-items: center;
}

/* ===== THREAD PANE ===== */
.thread-pane {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.thread-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--fg-muted);
  font-size: 0.9rem;
}

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

.thread-customer {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--fg);
}

.thread-subject {
  font-size: 0.85rem;
  color: var(--fg-muted);
}

.thread-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.channel-badge {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 100px;
  background: var(--bg-card);
  color: var(--fg-muted);
  border: 1px solid var(--border);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.status-badge {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 100px;
  text-transform: capitalize;
}

.status-badge.open   { background: rgba(251,191,36,0.12); color: #fbbf24; }
.status-badge.replied { background: rgba(52,211,153,0.12); color: #34d399; }
.status-badge.closed  { background: rgba(255,255,255,0.06); color: var(--fg-muted); }

.messages-area {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.message-bubble {
  max-width: 68%;
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 0.9rem;
  line-height: 1.6;
}

.message-bubble.inbound {
  background: var(--bg-card);
  border: 1px solid var(--border);
  align-self: flex-start;
  border-bottom-left-radius: 4px;
}

.message-bubble.outbound {
  background: var(--accent-glow);
  border: 1px solid rgba(232,168,56,0.2);
  align-self: flex-end;
  border-bottom-right-radius: 4px;
  color: var(--fg);
}

.message-meta {
  font-size: 0.73rem;
  color: var(--fg-muted);
  margin-top: 4px;
}

.message-meta.right { text-align: right; }

.ai-tag {
  font-size: 0.68rem;
  color: var(--accent);
  font-weight: 600;
  margin-left: 6px;
}

.reply-area {
  border-top: 1px solid var(--border);
  background: var(--bg-elevated);
  padding: 12px 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.reply-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
}

.reply-hint {
  font-size: 0.78rem;
  color: var(--fg-muted);
  margin-left: auto;
}

.reply-input {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--fg);
  font-family: var(--font-body);
  font-size: 0.9rem;
  padding: 10px 14px;
  resize: none;
  transition: border-color 0.2s;
  line-height: 1.55;
}

.reply-input:focus {
  outline: none;
  border-color: rgba(232,168,56,0.35);
}

.reply-footer {
  display: flex;
  justify-content: flex-end;
}

/* ===== BADGES ===== */
.badge {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 100px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.badge-email   { background: rgba(96,165,250,0.12); color: #60a5fa; }
.badge-text    { background: rgba(167,139,250,0.12); color: #a78bfa; }
.badge-form    { background: rgba(52,211,153,0.12); color: #34d399; }
.badge-open    { background: rgba(251,191,36,0.12); color: #fbbf24; }
.badge-replied { background: rgba(52,211,153,0.12); color: #34d399; }
.badge-unread  { background: var(--accent); color: #0a0a0f; width:8px; height:8px; padding:0; border-radius:50%; }

/* ===== APPOINTMENTS ===== */
.appt-layout {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 20px;
  align-items: start;
}

.appt-list-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.appt-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  transition: border-color 0.2s;
}

.appt-card:hover { border-color: rgba(232,168,56,0.2); }

.appt-date-col {
  text-align: center;
  min-width: 54px;
  flex-shrink: 0;
}

.appt-date-day {
  font-family: var(--font-display);
  font-size: 1.7rem;
  font-weight: 700;
  color: var(--accent);
  line-height: 1;
}

.appt-date-month {
  font-size: 0.75rem;
  color: var(--fg-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

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

.appt-title {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--fg);
  margin-bottom: 4px;
}

.appt-meta {
  font-size: 0.82rem;
  color: var(--fg-muted);
  display: flex;
  gap: 12px;
}

.appt-status {
  padding: 4px 10px;
  border-radius: 100px;
  font-size: 0.78rem;
  font-weight: 600;
  flex-shrink: 0;
}

.appt-status.confirmed { background: rgba(52,211,153,0.12); color: #34d399; }
.appt-status.cancelled { background: rgba(239,68,68,0.12); color: #ef4444; }
.appt-status.pending   { background: rgba(251,191,36,0.12); color: #fbbf24; }

.appt-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

/* ===== MINI CALENDAR ===== */
.mini-cal {
  padding: 12px 16px 16px;
}

.mini-cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
  text-align: center;
}

.mini-cal-dow {
  font-size: 0.72rem;
  color: var(--fg-muted);
  padding: 4px;
  font-weight: 600;
  text-transform: uppercase;
}

.mini-cal-cell {
  font-size: 0.82rem;
  padding: 6px 4px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.1s;
  color: var(--fg-muted);
  position: relative;
}

.mini-cal-cell:hover { background: var(--bg-card); color: var(--fg); }

.mini-cal-cell.today {
  background: var(--accent-glow);
  color: var(--accent);
  font-weight: 700;
}

.mini-cal-cell.has-appt::after {
  content: '';
  position: absolute;
  bottom: 2px;
  left: 50%;
  transform: translateX(-50%);
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--accent);
}

/* ===== SETTINGS ===== */
.settings-grid {
  display: grid;
  grid-template-columns: min(560px, 100%);
}

.settings-form {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.form-label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--fg-muted);
}

.form-input {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--fg);
  font-family: var(--font-body);
  font-size: 0.9rem;
  padding: 9px 12px;
  transition: border-color 0.2s;
}

.form-input:focus {
  outline: none;
  border-color: rgba(232,168,56,0.35);
}

.save-confirm {
  font-size: 0.85rem;
  color: #34d399;
  align-self: flex-start;
}

/* ===== MODAL ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-overlay.hidden { display: none; }

.modal {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: min(500px, 92vw);
  max-height: 90vh;
  overflow-y: auto;
}

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

.modal-header h3 {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 600;
}

.modal-close {
  background: none;
  border: none;
  color: var(--fg-muted);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 4px;
  line-height: 1;
  border-radius: 4px;
  transition: color 0.15s;
}

.modal-close:hover { color: var(--fg); }

.modal-body {
  padding: 20px 24px 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.modal-body .form-label { color: var(--fg-muted); }
.modal-body .form-input { background: var(--bg-card); }

/* ===== TOAST ===== */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 20px;
  font-size: 0.88rem;
  color: var(--fg);
  z-index: 2000;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
  transition: opacity 0.3s;
}

.toast.hidden { display: none; }

/* ===== LOADING ===== */
.loading-shimmer {
  height: 60px;
  background: linear-gradient(90deg, var(--bg-card) 25%, var(--bg-elevated) 50%, var(--bg-card) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
  margin: 12px 16px;
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--fg-muted);
  font-size: 0.9rem;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 1100px) {
  .stats-row { grid-template-columns: repeat(2, 1fr); }
  .dash-cols { grid-template-columns: 1fr; }
  .appt-layout { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
  .sidebar { display: none; }
  .view { padding: 20px; }
  .inbox-layout { flex-direction: column; height: auto; margin: -20px; }
  .thread-list-panel { width: 100%; border-right: none; border-bottom: 1px solid var(--border); height: 280px; }
}
