/* Dashboard layout — inherits design tokens from theme.css */

/* ===== LAYOUT ===== */
.dashboard-body {
  overflow: hidden;
  height: 100vh;
}

.dashboard-shell {
  display: grid;
  grid-template-columns: 220px 1fr;
  height: 100vh;
  overflow: hidden;
}

/* ===== SIDEBAR ===== */
.sidebar {
  background: var(--bg-elevated);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 1.5rem 0;
  overflow-y: auto;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1rem;
}

.brand-logo {
  width: 2rem;
  height: 2rem;
  background: var(--accent);
  color: var(--bg);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.75rem;
  letter-spacing: 0.05em;
  flex-shrink: 0;
}

.brand-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--fg);
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 0 0.75rem;
  flex: 1;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0.75rem;
  border-radius: 8px;
  color: var(--fg-muted);
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
  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, 73, 0.2);
}

.nav-icon {
  font-size: 1rem;
  width: 1.2rem;
  text-align: center;
}

.sidebar-footer {
  padding: 1rem 1.25rem 0;
  border-top: 1px solid var(--border);
  margin-top: 1rem;
}

.sidebar-home-link {
  font-size: 0.78rem;
  color: var(--fg-dim);
  text-decoration: none;
  transition: color 0.15s;
}

.sidebar-home-link:hover {
  color: var(--fg-muted);
}

/* ===== MAIN ===== */
.dashboard-main {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  height: 100vh;
}

/* ===== HEADER ===== */
.dash-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 1.5rem 2rem 1rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.business-name {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--fg);
  margin-bottom: 0.35rem;
}

.business-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

.status-live {
  background: #22c55e;
  box-shadow: 0 0 6px rgba(34, 197, 94, 0.5);
}

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

/* ===== STATS BAR ===== */
.stats-bar {
  display: flex;
  gap: 0.75rem;
  padding: 1rem 2rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  background: var(--bg-elevated);
}

.stat-pill {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  padding: 0.6rem 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  min-width: 80px;
}

.stat-pill.accent .stat-pill-value { color: var(--accent); }
.stat-pill.warn .stat-pill-value { color: #f87171; }

.stat-pill-label {
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--fg-dim);
  font-family: var(--font-display);
}

.stat-pill-value {
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--fg);
  line-height: 1;
}

/* ===== TAB PANELS ===== */
.tab-panel {
  display: none;
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem 2rem 2rem;
}

.tab-panel.active {
  display: block;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}

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

.panel-filters {
  display: flex;
  gap: 0.4rem;
}

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

.filter-btn:hover {
  border-color: var(--fg-muted);
  color: var(--fg);
}

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

/* ===== CALLS LIST ===== */
.calls-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.call-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.1rem 1.25rem;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 1rem;
  align-items: start;
  transition: border-color 0.15s;
}

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

.call-status-icon {
  width: 2rem;
  height: 2rem;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  flex-shrink: 0;
}

.call-status-icon.booked { background: rgba(34, 197, 94, 0.1); }
.call-status-icon.missed { background: rgba(248, 113, 113, 0.1); }
.call-status-icon.callback_requested { background: rgba(251, 191, 36, 0.1); }
.call-status-icon.received { background: rgba(99, 102, 241, 0.1); }

.call-body {
  min-width: 0;
}

.call-caller {
  font-family: var(--font-display);
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--fg);
  margin-bottom: 0.25rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.call-summary {
  font-size: 0.82rem;
  color: var(--fg-muted);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.call-intent-badge {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 600;
  font-family: var(--font-display);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  margin-bottom: 0.4rem;
}

.call-meta {
  text-align: right;
  flex-shrink: 0;
}

.call-time {
  font-size: 0.75rem;
  color: var(--fg-dim);
  margin-bottom: 0.4rem;
  display: block;
}

.call-duration {
  font-size: 0.72rem;
  color: var(--fg-dim);
}

.badge-emergency { background: rgba(248,113,113,0.15); color: #f87171; }
.badge-annual_service { background: rgba(34,197,94,0.1); color: #4ade80; }
.badge-installation { background: rgba(99,102,241,0.1); color: #818cf8; }
.badge-quote { background: rgba(251,191,36,0.1); color: #fbbf24; }
.badge-general { background: rgba(156,163,175,0.1); color: #9ca3af; }
.badge-unknown { background: rgba(156,163,175,0.1); color: #6b7280; }

/* ===== APPOINTMENTS GRID ===== */
.appointments-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1rem;
}

.appt-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  transition: border-color 0.15s;
}

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

.appt-time {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

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

.appt-weekday {
  font-size: 0.75rem;
  color: var(--fg-muted);
  margin-top: 0.2rem;
}

.appt-duration-badge {
  font-size: 0.72rem;
  padding: 0.2rem 0.5rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--fg-muted);
  font-family: var(--font-display);
}

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

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

.appt-phone {
  font-size: 0.78rem;
  color: var(--fg-dim);
}

.appt-notes {
  font-size: 0.78rem;
  color: var(--fg-muted);
  padding: 0.5rem 0.75rem;
  background: var(--bg-elevated);
  border-radius: 6px;
  line-height: 1.5;
  font-style: italic;
}

.appt-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.25rem;
}

.appt-status-badge {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 600;
  font-family: var(--font-display);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 0.2rem 0.6rem;
  border-radius: 4px;
}

.badge-confirmed { background: rgba(34,197,94,0.1); color: #4ade80; }
.badge-cancelled { background: rgba(248,113,113,0.1); color: #f87171; }
.badge-completed { background: rgba(99,102,241,0.1); color: #818cf8; }
.badge-no_show { background: rgba(156,163,175,0.1); color: #9ca3af; }

/* ===== ANALYTICS ===== */
.analytics-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 1.25rem;
}

.analytics-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.5rem;
}

.analytics-card-label {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--fg-dim);
  font-family: var(--font-display);
  margin-bottom: 1.25rem;
}

.conversion-display {
  font-family: var(--font-display);
  font-size: 3rem;
  font-weight: 700;
  color: var(--accent);
  line-height: 1;
  margin-bottom: 0.5rem;
}

.conversion-sub {
  font-size: 0.8rem;
  color: var(--fg-muted);
}

.intent-bar {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.intent-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.8rem;
}

.intent-label {
  color: var(--fg-muted);
  width: 120px;
  flex-shrink: 0;
}

.intent-track {
  flex: 1;
  height: 6px;
  background: var(--bg-elevated);
  border-radius: 3px;
  overflow: hidden;
}

.intent-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
  transition: width 0.5s ease;
}

.intent-count {
  color: var(--fg-dim);
  min-width: 1.5rem;
  text-align: right;
}

/* ===== API DOCS ===== */
.api-docs {
  display: flex;
  flex-direction: column;
  gap: 2rem;
  max-width: 760px;
}

.api-section {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.api-key-display {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem 1rem;
}

.api-key-value {
  font-family: 'Space Mono', 'Courier New', monospace;
  font-size: 0.8rem;
  color: var(--accent);
  flex: 1;
  word-break: break-all;
}

.api-endpoint {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-family: 'Space Mono', monospace;
  font-size: 0.85rem;
  color: var(--fg);
}

.method-badge {
  font-size: 0.65rem;
  font-weight: 700;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  font-family: var(--font-display);
  letter-spacing: 0.05em;
}

.method-badge.post { background: rgba(34,197,94,0.1); color: #4ade80; }
.method-badge.get { background: rgba(99,102,241,0.1); color: #818cf8; }

.code-block {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem 1.25rem;
  font-family: 'Space Mono', 'Courier New', monospace;
  font-size: 0.78rem;
  color: var(--fg-muted);
  line-height: 1.6;
  white-space: pre;
  overflow-x: auto;
}

.api-note {
  font-size: 0.8rem;
  color: var(--fg-dim);
  line-height: 1.6;
}

/* ===== BUTTONS ===== */
.btn-primary {
  padding: 0.6rem 1.2rem;
  background: var(--accent);
  color: var(--bg);
  border: none;
  border-radius: 8px;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 0.15s;
}

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

.btn-secondary {
  padding: 0.6rem 1.2rem;
  background: transparent;
  color: var(--fg-muted);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-secondary:hover {
  border-color: var(--fg-muted);
  color: var(--fg);
}

.btn-copy {
  padding: 0.3rem 0.75rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--fg-muted);
  font-size: 0.75rem;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-copy:hover { color: var(--accent); border-color: rgba(232,168,73,0.3); }

.btn-cancel-appt {
  padding: 0.3rem 0.75rem;
  background: transparent;
  border: 1px solid rgba(248,113,113,0.3);
  border-radius: 6px;
  color: #f87171;
  font-size: 0.72rem;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-cancel-appt:hover { background: rgba(248,113,113,0.1); }

/* ===== MODAL ===== */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 100;
  align-items: center;
  justify-content: center;
}

.modal-overlay.open {
  display: flex;
}

.modal {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 2rem;
  width: 100%;
  max-width: 500px;
  max-height: 85vh;
  overflow-y: auto;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}

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

.modal-close {
  background: none;
  border: none;
  color: var(--fg-muted);
  font-size: 1rem;
  cursor: pointer;
  padding: 0.25rem;
  transition: color 0.15s;
}

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

.modal-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.form-row {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.form-row label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--fg-muted);
  font-family: var(--font-display);
}

.form-row input,
.form-row select,
.form-row textarea {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.6rem 0.85rem;
  color: var(--fg);
  font-family: var(--font-body);
  font-size: 0.88rem;
  transition: border-color 0.15s;
  outline: none;
}

.form-row input:focus,
.form-row select:focus,
.form-row textarea:focus {
  border-color: rgba(232,168,73,0.4);
}

.form-row textarea {
  min-height: 80px;
  resize: vertical;
}

.modal-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
  padding-top: 0.5rem;
}

/* ===== LOADING / EMPTY STATES ===== */
.loading-state, .empty-state {
  text-align: center;
  padding: 3rem 2rem;
  color: var(--fg-dim);
  font-size: 0.88rem;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 900px) {
  .dashboard-shell {
    grid-template-columns: 1fr;
  }
  .sidebar {
    display: none;
  }
  .analytics-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 600px) {
  .stats-bar {
    flex-wrap: wrap;
    gap: 0.5rem;
  }
  .stat-pill {
    min-width: 70px;
  }
  .dash-header {
    flex-direction: column;
    gap: 0.75rem;
  }
}
