/* ════════════════════════════════════════════════════════════════════
   style.css — ResponsePro Dashboard
   Designed to match responsepro.app's visual language:
     Primary blue:  #0066cc
     Dark blue:     #004c99
     Page bg:       #f8f9fa
     Dark text:     #222
     Muted text:    #555
     Border:        #e0e0e0
     Card bg:       #fff
   ════════════════════════════════════════════════════════════════════ */

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  /* System font stack matches the static site exactly */
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Helvetica Neue', Arial, sans-serif;
  background-color: #f8f9fa;
  color: #222;
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

main { flex: 1; }

/* ── Container ────────────────────────────────────────────────────── */
/* Same max-width and padding as responsepro.app */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
}

/* ── Links ────────────────────────────────────────────────────────── */
a {
  color: #0066cc;
  text-decoration: none;
  transition: color 0.2s ease;
}
a:hover { color: #004c99; text-decoration: underline; }

/* ══════════════════════════════════════════════════════════════════
   HEADER / NAV
   White background with bottom shadow — same as static site header
   ══════════════════════════════════════════════════════════════════ */
.site-header {
  background: #fff;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  position: sticky;
  top: 0;
  z-index: 100;
}

.nav-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 0.75rem;
  padding-bottom: 0.75rem;
  gap: 1rem;
}

/* Brand — matches .nav-brand on the static site */
.nav-brand {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  font-size: 1.5rem;
  font-weight: 700;
  color: #0066cc;
  white-space: nowrap;
  flex-shrink: 0;
}

.nav-brand-tag {
  font-size: 0.75rem;
  font-weight: 500;
  color: #888;
  background: #f0f0f0;
  padding: 2px 8px;
  border-radius: 12px;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

/* Tab navigation — replaces page links in the static site */
.nav-tabs {
  display: flex;
  list-style: none;
  gap: 0;
  border-bottom: 2px solid transparent; /* offset for active indicator */
}

.nav-tab {
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.9375rem;
  font-weight: 500;
  color: #555;
  padding: 0.5rem 1.125rem;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px; /* align with nav border */
  transition: color 0.2s ease, border-color 0.2s ease;
  white-space: nowrap;
}

.nav-tab:hover { color: #0066cc; }

.nav-tab.active {
  color: #0066cc;
  border-bottom-color: #0066cc;
}

/* Right side of nav */
.nav-right {
  display: flex;
  align-items: center;
  gap: 0.875rem;
  flex-shrink: 0;
}

.live-clock {
  font-size: 0.8125rem;
  font-weight: 500;
  color: #555;
  font-variant-numeric: tabular-nums; /* prevents layout shift as digits change */
  letter-spacing: 0.03em;
}

/* Status badge — shows "Ready" / "Loading" / "Loaded" */
.status-badge {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  font-size: 0.8125rem;
  font-weight: 500;
  color: #555;
  background: #f8f9fa;
  border: 1px solid #e0e0e0;
  padding: 0.25rem 0.625rem;
  border-radius: 20px;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #ccc;
  transition: background 0.3s ease;
}

/* Status dot color variants set via JS */
.status-dot.ready   { background: #ccc; }
.status-dot.loading { background: #f57c00; animation: pulse 1s infinite; }
.status-dot.loaded  { background: #2e7d32; }
.status-dot.error   { background: #c62828; }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* ══════════════════════════════════════════════════════════════════
   CLIENT BAR — the "load dashboard" control strip
   Sits between header and tab content, slightly elevated from page bg
   ══════════════════════════════════════════════════════════════════ */
.client-bar {
  background: #fff;
  border-bottom: 1px solid #e0e0e0;
  padding: 1rem 0;
}

.client-bar-inner {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

.client-input-row {
  display: flex;
  align-items: flex-end;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.input-group {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.input-group label {
  font-size: 0.8125rem;
  font-weight: 600;
  color: #333;
}

.input-group input {
  height: 2.375rem;
  padding: 0 0.75rem;
  font-size: 0.9375rem;
  font-family: inherit;
  border: 2px solid #ddd;
  border-radius: 4px;
  min-width: 200px;
  transition: border-color 0.2s ease;
  color: #222;
}

.input-group input:focus {
  outline: none;
  border-color: #0066cc;
}

.client-hint {
  font-size: 0.8125rem;
  color: #777;
}

/* ══════════════════════════════════════════════════════════════════
   BUTTONS
   ══════════════════════════════════════════════════════════════════ */

/* Primary — blue fill, matches static site .cta-button style */
.btn-primary {
  display: inline-flex;
  align-items: center;
  height: 2.375rem;
  padding: 0 1.25rem;
  background: #0066cc;
  color: #fff;
  font-family: inherit;
  font-size: 0.9375rem;
  font-weight: 600;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.15s ease, box-shadow 0.15s ease;
  white-space: nowrap;
}

.btn-primary:hover {
  background: #004c99;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 102, 204, 0.25);
}

.btn-primary:active { transform: translateY(0); }

/* Ghost — text button for secondary actions */
.btn-ghost {
  display: inline-flex;
  align-items: center;
  height: 2.375rem;
  padding: 0 0.875rem;
  background: none;
  color: #555;
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  border: 1px solid #ddd;
  border-radius: 4px;
  cursor: pointer;
  transition: border-color 0.2s ease, color 0.2s ease;
}

.btn-ghost:hover { border-color: #0066cc; color: #0066cc; }

.btn-ghost.btn-sm { height: 2rem; font-size: 0.8125rem; padding: 0 0.75rem; }

/* Page navigation buttons */
.btn-page {
  display: inline-flex;
  align-items: center;
  padding: 0.375rem 0.875rem;
  background: #fff;
  color: #0066cc;
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  border: 1px solid #0066cc;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease;
}

.btn-page:hover:not(:disabled) { background: #0066cc; color: #fff; }

.btn-page:disabled {
  color: #bbb;
  border-color: #e0e0e0;
  cursor: not-allowed;
}

/* ══════════════════════════════════════════════════════════════════
   GLOBAL STATES
   ══════════════════════════════════════════════════════════════════ */
.global-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 2rem;
  color: #555;
  font-size: 0.9375rem;
}

.spinner {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2px solid #e0e0e0;
  border-top-color: #0066cc;
  border-radius: 50%;
  animation: spin 0.65s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.global-error {
  margin: 1rem 20px;
  padding: 0.875rem 1rem;
  background: #fff3f3;
  border: 1px solid #f5c6c6;
  border-radius: 6px;
  color: #c62828;
  font-size: 0.9375rem;
}

/* ══════════════════════════════════════════════════════════════════
   TAB PANELS
   ══════════════════════════════════════════════════════════════════ */
.tab-panel { padding: 1.75rem 0; }

/* ══════════════════════════════════════════════════════════════════
   KPI CARDS
   White cards with colored icon tiles — elevated but familiar
   ══════════════════════════════════════════════════════════════════ */
.kpi-grid {
  display: grid;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.four-col { grid-template-columns: repeat(4, 1fr); }
.five-col { grid-template-columns: repeat(5, 1fr); }

.kpi-card {
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  padding: 1.25rem;
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

/* Highlight card — used for the most important metric (Recovery Rate) */
.kpi-card--highlight {
  border-color: #0066cc;
  background: linear-gradient(135deg, #fff 60%, #e8f0fe 100%);
}

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

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

.kpi-label {
  font-size: 0.8125rem;
  font-weight: 500;
  color: #666;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.25rem;
}

.kpi-value {
  font-size: 1.875rem;
  font-weight: 700;
  color: #222;
  line-height: 1.1;
  letter-spacing: -0.02em;
}

.kpi-unit {
  font-size: 0.75rem;
  color: #888;
  margin-top: 2px;
}

/* ══════════════════════════════════════════════════════════════════
   CHARTS
   ══════════════════════════════════════════════════════════════════ */
.charts-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.chart-card {
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  padding: 1.25rem;
}

.chart-card-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 1rem;
}

.chart-card-header h3 {
  font-size: 0.9375rem;
  font-weight: 600;
  color: #222;
}

.chart-period {
  font-size: 0.8125rem;
  color: #888;
}

/* ══════════════════════════════════════════════════════════════════
   FILTER BAR
   ══════════════════════════════════════════════════════════════════ */
.filter-bar {
  display: flex;
  align-items: flex-end;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
  padding: 1rem;
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.filter-group label {
  font-size: 0.75rem;
  font-weight: 600;
  color: #555;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.filter-group input,
.filter-group select {
  height: 2.125rem;
  padding: 0 0.625rem;
  font-size: 0.875rem;
  font-family: inherit;
  border: 1.5px solid #ddd;
  border-radius: 4px;
  color: #222;
  background: #fff;
  transition: border-color 0.2s ease;
}

.filter-group input:focus,
.filter-group select:focus {
  outline: none;
  border-color: #0066cc;
}

/* ══════════════════════════════════════════════════════════════════
   DATA CARDS + TABLES
   ══════════════════════════════════════════════════════════════════ */
.data-card {
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  overflow: hidden;
}

.data-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid #e0e0e0;
}

.data-card-header h3 {
  font-size: 0.9375rem;
  font-weight: 600;
  color: #222;
}

.record-count {
  font-size: 0.8125rem;
  color: #888;
  font-weight: 500;
}

/* Info strip — light blue note bar */
.info-strip {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.625rem 1.25rem;
  background: #e8f0fe;
  color: #004c99;
  font-size: 0.8125rem;
  border-bottom: 1px solid #c5d8f8;
}

.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.data-table thead {
  background: #f8f9fa;
}

.data-table th {
  padding: 0.625rem 1rem;
  text-align: left;
  font-size: 0.75rem;
  font-weight: 600;
  color: #555;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1px solid #e0e0e0;
  white-space: nowrap;
}

.data-table td {
  padding: 0.625rem 1rem;
  color: #333;
  border-bottom: 1px solid #f0f0f0;
  vertical-align: middle;
}

.data-table tbody tr:last-child td { border-bottom: none; }

.data-table tbody tr:hover td { background: #f8f9fa; }

.empty-cell {
  text-align: center;
  color: #888;
  padding: 2rem 1rem !important;
}

/* Pagination */
.pagination-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.875rem;
  padding: 0.875rem 1rem;
  border-top: 1px solid #e0e0e0;
}

.page-info {
  font-size: 0.875rem;
  color: #555;
  font-weight: 500;
}

/* ══════════════════════════════════════════════════════════════════
   BADGES
   Small colored pills used in table cells for status values
   ══════════════════════════════════════════════════════════════════ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.2rem 0.6rem;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}

/* Call status badges */
.badge--no-answer { background: #fff8e1; color: #e65100; border: 1px solid #ffe082; }
.badge--busy      { background: #fff3e0; color: #bf360c; border: 1px solid #ffcc80; }
.badge--failed    { background: #fce4ec; color: #b71c1c; border: 1px solid #f48fb1; }
.badge--completed { background: #f3e5f5; color: #4a148c; border: 1px solid #ce93d8; }

/* SMS / reply badges */
.badge--sent     { background: #e8f5e9; color: #1b5e20; border: 1px solid #a5d6a7; }
.badge--not-sent { background: #fce4ec; color: #b71c1c; border: 1px solid #f48fb1; }
.badge--replied  { background: #e8f0fe; color: #0d47a1; border: 1px solid #90caf9; }
.badge--waiting  { background: #f8f9fa; color: #777;    border: 1px solid #e0e0e0; }
.badge--err      { background: #fce4ec; color: #c62828; border: 1px solid #ef9a9a; }

/* ══════════════════════════════════════════════════════════════════
   EMPTY STATE
   ══════════════════════════════════════════════════════════════════ */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: #777;
}

.empty-icon {
  font-size: 2.5rem;
  margin-bottom: 0.75rem;
}

.empty-state h3 {
  font-size: 1.125rem;
  font-weight: 600;
  color: #333;
  margin-bottom: 0.5rem;
}

.empty-state p { font-size: 0.9375rem; }

.empty-state code {
  background: #f0f0f0;
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 0.875em;
}

/* ══════════════════════════════════════════════════════════════════
   FOOTER — matches responsepro.app footer exactly
   ══════════════════════════════════════════════════════════════════ */
footer {
  background: #222;
  color: #fff;
  padding: 1.5rem 0;
  margin-top: auto;
}

.footer-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
}

footer p { margin: 0; font-size: 0.9rem; }

.footer-nav {
  display: flex;
  gap: 1.5rem;
}

.footer-nav a {
  color: #ccc;
  font-size: 0.9rem;
  transition: color 0.2s ease;
}

.footer-nav a:hover { color: #0066cc; text-decoration: none; }

/* ══════════════════════════════════════════════════════════════════
   RESPONSIVE
   ══════════════════════════════════════════════════════════════════ */
@media (max-width: 1024px) {
  .five-col { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 768px) {
  .nav-inner {
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  .nav-tabs { order: 3; width: 100%; overflow-x: auto; }
  .nav-tab  { font-size: 0.875rem; padding: 0.375rem 0.75rem; }
  .nav-right { margin-left: auto; }

  .four-col { grid-template-columns: repeat(2, 1fr); }
  .five-col { grid-template-columns: repeat(2, 1fr); }

  .charts-row { grid-template-columns: 1fr; }

  .filter-bar { flex-direction: column; align-items: stretch; }
  .filter-group input, .filter-group select { width: 100%; }

  .footer-inner { flex-direction: column; text-align: center; }
  .footer-nav { flex-wrap: wrap; justify-content: center; }
}

@media (max-width: 480px) {
  html { font-size: 14px; }

  .four-col,
  .five-col { grid-template-columns: 1fr; }

  .client-input-row { flex-direction: column; align-items: stretch; }
  .input-group input { min-width: auto; }
  .btn-primary { width: 100%; justify-content: center; }
}

/* ══════════════════════════════════════════════════════════════════
   AUTH OVERLAY
   Full-screen gate shown before the dashboard loads.
   Hidden once the user is authenticated.
   ══════════════════════════════════════════════════════════════════ */
.auth-overlay {
  position: fixed;
  inset: 0;
  background: #f8f9fa;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.auth-card {
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 10px;
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.08);
  text-align: center;
}

.auth-logo {
  font-size: 1.625rem;
  font-weight: 700;
  color: #0066cc;
  margin-bottom: 0.375rem;
}

.auth-subtitle {
  font-size: 0.875rem;
  color: #777;
  margin-bottom: 2rem;
}

.auth-card h2 {
  font-size: 1.125rem;
  font-weight: 600;
  color: #222;
  margin-bottom: 1.5rem;
}

.auth-field {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
  margin-bottom: 1rem;
  text-align: left;
}

.auth-field label {
  font-size: 0.8125rem;
  font-weight: 600;
  color: #333;
}

.auth-field input {
  height: 2.625rem;
  padding: 0 0.875rem;
  font-size: 0.9375rem;
  font-family: inherit;
  border: 2px solid #ddd;
  border-radius: 4px;
  color: #222;
  transition: border-color 0.2s ease;
}

.auth-field input:focus {
  outline: none;
  border-color: #0066cc;
}

.auth-field input.invalid {
  border-color: #c62828;
}

.auth-error {
  color: #c62828;
  font-size: 0.8125rem;
  font-weight: 500;
  margin-bottom: 0.875rem;
  min-height: 1.2rem;
  text-align: left;
}

.auth-btn {
  width: 100%;
  height: 2.75rem;
  background: #0066cc;
  color: #fff;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.auth-btn:hover { background: #004c99; }
.auth-btn:disabled { background: #94b8e0; cursor: not-allowed; }

.auth-footer {
  margin-top: 1.75rem;
  font-size: 0.8125rem;
  color: #999;
}

.auth-footer a { color: #0066cc; }

.auth-lock-icon {
  font-size: 2rem;
  margin-bottom: 1rem;
}

/* Client ID display strip — replaces the text input for locked clients */
.client-display-bar {
  background: #fff;
  border-bottom: 1px solid #e0e0e0;
  padding: 0.75rem 0;
}

.client-display-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.client-display-info {
  display: flex;
  align-items: center;
  gap: 0.625rem;
}

.client-display-label {
  font-size: 0.8125rem;
  font-weight: 600;
  color: #555;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.client-display-id {
  font-size: 0.875rem;
  font-weight: 600;
  color: #0066cc;
  background: #e8f0fe;
  padding: 3px 10px;
  border-radius: 20px;
  font-family: 'Courier New', monospace;
}

.client-display-hint {
  font-size: 0.8rem;
  color: #999;
}

.btn-logout {
  background: none;
  border: 1px solid #ddd;
  color: #777;
  font-family: inherit;
  font-size: 0.8125rem;
  padding: 0.25rem 0.75rem;
  border-radius: 4px;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s;
}

.btn-logout:hover { border-color: #c62828; color: #c62828; }

/* Policy pages */
.policy-body { max-width: 760px; margin: 2.5rem auto; padding: 0 20px 3rem; }
.policy-body h1 { font-size: 1.875rem; font-weight: 700; color: #222; margin-bottom: 0.5rem; }
.policy-body .last-updated { font-size: 0.875rem; color: #777; margin-bottom: 2rem; }
.policy-body h2 { font-size: 1.125rem; font-weight: 600; color: #222; margin: 2rem 0 0.625rem; }
.policy-body p, .policy-body li { font-size: 0.9375rem; color: #444; line-height: 1.7; }
.policy-body ul { padding-left: 1.5rem; margin: 0.5rem 0; display: flex; flex-direction: column; gap: 0.25rem; }
.policy-body a { color: #0066cc; }
.policy-back { display: inline-flex; align-items: center; gap: 0.375rem; margin-bottom: 1.5rem; font-size: 0.875rem; font-weight: 500; color: #0066cc; }
