/* ========================================================================
   VA Dialer — distinctive utility interface
   Warm paper background, bold accent, oversized touch targets.
   ======================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Bricolage+Grotesque:opsz,wght@12..96,400;12..96,500;12..96,600;12..96,700;12..96,800&family=JetBrains+Mono:wght@400;500;700&display=swap');

:root {
  --paper: #f5f1e8;
  --paper-2: #ebe5d4;
  --ink: #1a1a1a;
  --ink-2: #4a4a4a;
  --ink-3: #8a8a8a;
  --line: #d6cfb8;
  --accent: #d2461b;       /* warm vermillion — "go" action */
  --accent-2: #b53a14;
  --accent-soft: #f5dfd2;
  --green: #2d6b3a;
  --green-soft: #d8e6da;
  --red: #a83232;
  --red-soft: #f0d8d8;
  --blue: #2a4d6e;
  --blue-soft: #d8e0e8;
  --shadow: 0 1px 0 rgba(0,0,0,0.04), 0 4px 16px rgba(60,40,10,0.06);
  --shadow-lg: 0 2px 0 rgba(0,0,0,0.04), 0 16px 48px rgba(60,40,10,0.16);
  --radius: 4px;
  --radius-lg: 8px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: 'Bricolage Grotesque', system-ui, sans-serif;
  font-size: 16px;
  color: var(--ink);
  background: var(--paper);
  background-image:
    radial-gradient(circle at 1px 1px, rgba(60,40,10,0.04) 1px, transparent 0);
  background-size: 24px 24px;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

button { font-family: inherit; cursor: pointer; }
input, textarea, select { font-family: inherit; font-size: 16px; }
a { color: var(--accent); }

/* ========== Header ========== */
.app-header {
  background: var(--ink);
  color: var(--paper);
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 3px solid var(--accent);
}
.app-header .brand {
  font-weight: 800;
  font-size: 20px;
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: 10px;
}
.app-header .brand::before {
  content: '';
  display: inline-block;
  width: 12px; height: 12px;
  background: var(--accent);
  border-radius: 50%;
}
.app-header .user {
  display: flex; align-items: center; gap: 16px;
  font-size: 14px;
}
.app-header .user button {
  background: transparent;
  color: var(--paper);
  border: 1px solid rgba(255,255,255,0.2);
  padding: 6px 14px;
  border-radius: var(--radius);
  font-size: 14px;
}
.app-header .user button:hover { border-color: var(--accent); }

/* ========== Layout ========== */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px;
}

/* ========== Login ========== */
.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login-card {
  background: white;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 48px 40px;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow-lg);
}
.login-card h1 {
  margin: 0 0 8px;
  font-size: 36px;
  font-weight: 800;
  letter-spacing: -0.03em;
  display: flex;
  align-items: baseline;
  gap: 12px;
}
.login-card h1::before {
  content: '';
  display: inline-block;
  width: 16px; height: 16px;
  background: var(--accent);
  border-radius: 50%;
  flex-shrink: 0;
  align-self: center;
}
.login-card p { color: var(--ink-3); margin: 0 0 32px; font-size: 14px; }

/* ========== Forms ========== */
.field { margin-bottom: 16px; }
.field label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-2);
  margin-bottom: 6px;
}
.field input, .field select, .field textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
  transition: border-color 120ms;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none;
  border-color: var(--accent);
  background: white;
}
.field textarea { min-height: 80px; resize: vertical; font-family: inherit; }

/* ========== Buttons ========== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 20px;
  border: 1.5px solid var(--ink);
  background: white;
  color: var(--ink);
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 15px;
  transition: transform 80ms, box-shadow 120ms;
}
.btn:hover { transform: translate(-1px, -1px); box-shadow: 2px 2px 0 var(--ink); }
.btn:active { transform: translate(0,0); box-shadow: none; }

.btn-primary { background: var(--accent); border-color: var(--accent); color: white; }
.btn-primary:hover { box-shadow: 2px 2px 0 var(--ink); }
.btn-block { width: 100%; padding: 14px 20px; font-size: 16px; }
.btn-danger { background: var(--red); border-color: var(--red); color: white; }
.btn-ghost { background: transparent; border-color: var(--line); }

/* ========== Stat strip ========== */
.stat-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 24px;
  overflow: hidden;
}
.stat-strip .stat {
  background: white;
  padding: 16px 20px;
}
.stat .label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-3);
}
.stat .value {
  font-size: 32px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-top: 2px;
  font-feature-settings: 'tnum' 1;
}

/* ========== Lead list ========== */
.toolbar {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
  align-items: center;
  flex-wrap: wrap;
}
.search-box {
  flex: 1;
  min-width: 240px;
  position: relative;
}
.search-box input {
  width: 100%;
  padding: 14px 16px 14px 44px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  background: white;
  font-size: 15px;
}
.search-box input:focus { outline: none; border-color: var(--accent); }
.search-box::before {
  content: '⌕';
  position: absolute;
  left: 16px; top: 50%;
  transform: translateY(-50%);
  font-size: 20px;
  color: var(--ink-3);
}

.lead-list {
  background: white;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.lead-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 16px;
  align-items: center;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
  transition: background 100ms;
}
.lead-row:last-child { border-bottom: none; }
.lead-row:hover { background: var(--paper); }

.lead-info .name {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin-bottom: 2px;
}
.lead-info .meta {
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  color: var(--ink-2);
  display: flex;
  gap: 12px;
  align-items: center;
}
.lead-info .meta .company {
  font-family: 'Bricolage Grotesque', sans-serif;
  color: var(--ink-3);
}
.lead-info .badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 2px 8px;
  border-radius: 100px;
  background: var(--paper-2);
  color: var(--ink-2);
  margin-left: 8px;
}
.badge.connected { background: var(--green-soft); color: var(--green); }
.badge.voicemail { background: var(--blue-soft); color: var(--blue); }
.badge.no_answer, .badge.bad_number { background: var(--paper-2); color: var(--ink-2); }
.badge.new { background: var(--accent-soft); color: var(--accent-2); }

.lead-actions { display: flex; gap: 8px; }
.lead-actions .btn {
  min-width: 80px;
  padding: 12px 16px;
  font-size: 14px;
}
.btn-call { background: var(--accent); border-color: var(--accent); color: white; }
.btn-text { background: var(--blue); border-color: var(--blue); color: white; }

.empty {
  padding: 64px 24px;
  text-align: center;
  color: var(--ink-3);
}

/* ========== Modal ========== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(20, 14, 4, 0.6);
  backdrop-filter: blur(4px);
  display: grid;
  place-items: center;
  padding: 24px;
  z-index: 100;
  animation: fadeIn 200ms;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: var(--paper);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 480px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: slideUp 240ms cubic-bezier(0.2, 0.9, 0.3, 1.2);
}
@keyframes slideUp {
  from { transform: translateY(20px) scale(0.96); opacity: 0; }
  to { transform: translateY(0) scale(1); opacity: 1; }
}
.modal-header {
  padding: 24px 28px 8px;
}
.modal-header h2 {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.modal-header p {
  margin: 4px 0 0;
  color: var(--ink-3);
  font-size: 14px;
}
.modal-body { padding: 16px 28px 28px; }
.modal-footer { padding: 0 28px 24px; display: flex; gap: 8px; justify-content: flex-end; }

/* ========== Active call panel ========== */
.call-panel {
  background: var(--ink);
  color: var(--paper);
  padding: 48px 40px 40px;
  text-align: center;
}
.call-panel.ringing { background: var(--accent); }
.call-panel.in-progress { background: var(--green); }

.call-state {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  opacity: 0.7;
  margin-bottom: 12px;
}
.call-state .pulse {
  display: inline-block;
  width: 8px; height: 8px;
  background: currentColor;
  border-radius: 50%;
  margin-right: 8px;
  animation: pulse 1.2s infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 0.4; transform: scale(0.9); }
  50% { opacity: 1; transform: scale(1.1); }
}

.call-name {
  font-size: 36px;
  font-weight: 800;
  letter-spacing: -0.03em;
  margin: 0 0 4px;
  line-height: 1.1;
}
.call-number {
  font-family: 'JetBrains Mono', monospace;
  font-size: 16px;
  opacity: 0.7;
  margin-bottom: 32px;
}
.call-timer {
  font-family: 'JetBrains Mono', monospace;
  font-size: 56px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 32px;
  font-feature-settings: 'tnum' 1;
}

.btn-hangup {
  background: var(--red);
  color: white;
  border: none;
  padding: 18px 36px;
  border-radius: 100px;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.02em;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  box-shadow: 0 6px 20px rgba(168, 50, 50, 0.5);
  transition: transform 100ms;
}
.btn-hangup:hover { transform: translateY(-2px); }
.btn-hangup:active { transform: translateY(0); }

/* ========== Disposition buttons ========== */
.disposition-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.disposition-grid .btn {
  padding: 18px 16px;
  font-size: 15px;
  flex-direction: column;
  gap: 4px;
  border-width: 2px;
  text-align: center;
}
.disposition-grid .btn .icon {
  font-size: 22px;
  margin-bottom: 2px;
}
.disposition-grid .btn.connected { border-color: var(--green); color: var(--green); }
.disposition-grid .btn.connected:hover { background: var(--green); color: white; box-shadow: 2px 2px 0 var(--ink); }
.disposition-grid .btn.voicemail { border-color: var(--blue); color: var(--blue); }
.disposition-grid .btn.voicemail:hover { background: var(--blue); color: white; box-shadow: 2px 2px 0 var(--ink); }
.disposition-grid .btn.no_answer { border-color: var(--ink-2); color: var(--ink-2); }
.disposition-grid .btn.no_answer:hover { background: var(--ink-2); color: white; box-shadow: 2px 2px 0 var(--ink); }
.disposition-grid .btn.wrong_number { border-color: var(--ink-3); color: var(--ink-2); }
.disposition-grid .btn.wrong_number:hover { background: var(--ink-3); color: white; }
.disposition-grid .btn.dnc { border-color: var(--red); color: var(--red); grid-column: 1 / -1; }
.disposition-grid .btn.dnc:hover { background: var(--red); color: white; box-shadow: 2px 2px 0 var(--ink); }

/* ========== SMS template list ========== */
.template-list { display: flex; flex-direction: column; gap: 8px; }
.template-card {
  background: white;
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  cursor: pointer;
  transition: all 120ms;
  text-align: left;
  width: 100%;
  font-family: inherit;
}
.template-card:hover { border-color: var(--accent); transform: translate(-1px, -1px); box-shadow: 2px 2px 0 var(--ink); }
.template-card .tpl-name {
  font-weight: 700;
  font-size: 14px;
  margin-bottom: 4px;
}
.template-card .tpl-preview {
  font-size: 13px;
  color: var(--ink-2);
  line-height: 1.4;
  white-space: pre-wrap;
}

.sms-preview {
  background: white;
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  font-size: 14px;
  line-height: 1.5;
  margin-bottom: 12px;
  white-space: pre-wrap;
  min-height: 80px;
}

/* ========== Lead detail / history ========== */
.history-section {
  background: white;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-top: 12px;
}
.history-section h3 {
  margin: 0 0 12px;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-3);
}
.history-item {
  padding: 12px 0;
  border-bottom: 1px solid var(--paper-2);
  font-size: 14px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  align-items: center;
}
.history-item:last-child { border-bottom: none; }
.history-item .when {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  color: var(--ink-3);
  white-space: nowrap;
}
.history-item audio { height: 32px; max-width: 240px; }

/* ========== Tabs ========== */
.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 2px solid var(--line);
  margin-bottom: 20px;
}
.tab {
  padding: 12px 18px;
  background: transparent;
  border: none;
  font-weight: 600;
  font-size: 15px;
  color: var(--ink-3);
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  cursor: pointer;
}
.tab.active { color: var(--ink); border-bottom-color: var(--accent); }

/* ========== Toast ========== */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--paper);
  padding: 12px 20px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  z-index: 200;
  font-size: 14px;
  animation: slideIn 240ms;
}
.toast.error { background: var(--red); }
.toast.success { background: var(--green); }
@keyframes slideIn {
  from { opacity: 0; transform: translate(-50%, 12px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

/* ========== Tables ========== */
table.data {
  width: 100%;
  border-collapse: collapse;
  background: white;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  font-size: 14px;
}
table.data th, table.data td {
  padding: 12px 14px;
  text-align: left;
  border-bottom: 1px solid var(--line);
}
table.data th {
  background: var(--paper);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-2);
}
table.data tbody tr:last-child td { border-bottom: none; }
table.data tbody tr:hover { background: var(--paper); }

.muted { color: var(--ink-3); }
.mono { font-family: 'JetBrains Mono', monospace; }

/* ========== Responsive ========== */
@media (max-width: 640px) {
  .container { padding: 16px; }
  .lead-row { grid-template-columns: 1fr; gap: 12px; }
  .lead-actions { display: grid; grid-template-columns: 1fr 1fr; }
  .lead-actions .btn { width: 100%; }
  .call-name { font-size: 28px; }
  .call-timer { font-size: 44px; }
}
