/*
 * This is a manifest file that'll be compiled into application.css.
 *
 * With Propshaft, assets are served efficiently without preprocessing steps. You can still include
 * application-wide styles in this file, but keep in mind that CSS precedence will follow the standard
 * cascading order, meaning styles declared later in the document or manifest will override earlier ones,
 * depending on specificity.
 *
 * Consider organizing styles into separate files for maintainability.
 */

:root {
  --navy: #1E3364;
  --navy-deep: #142449;
  --sky: #1EC2E5;
  --orange: #ED1C24;
  --orange-dark: #B3141A;
  --ink: #1B2733;
  --light: #F2F6FA;
  --green: #00A544;
  --red: #D6303C;
  --white: #FFFFFF;
  --muted: #5B6B7C;
  --line: #E2EAF1;
  --shadow-sm: 0 2px 8px rgba(30, 51, 100, .08);
  --shadow-md: 0 8px 28px rgba(30, 51, 100, .12);
  --shadow-lg: 0 18px 50px rgba(10, 44, 71, .28);
  --radius: 14px;
  --radius-lg: 20px;
  --maxw: 1180px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: var(--light);
  line-height: 1.55;
  font-size: 17px;
}

a { color: inherit; text-decoration: none; }

.wrap { margin: 0 auto; padding: 0 20px; width: 100%; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 9px;
  font-weight: 800; font-size: 17px; line-height: 1; text-align: center;
  border: none; border-radius: 60px; cursor: pointer;
  padding: 17px 28px; transition: transform .15s ease, box-shadow .15s ease, background .15s ease, opacity .15s ease;
  white-space: nowrap; font-family: inherit;
}
.btn:active { transform: translateY(1px) scale(.99); }
.btn:disabled { opacity: .7; cursor: not-allowed; transform: none; }
.btn-orange { background: var(--orange); color: #fff; box-shadow: 0 8px 22px rgba(237, 28, 36, .38); }
.btn-orange:hover:not(:disabled) { background: var(--orange-dark); box-shadow: 0 10px 26px rgba(237, 28, 36, .5); }
.btn-navy { background: var(--navy); color: #fff; box-shadow: var(--shadow-sm); }
.btn-navy:hover:not(:disabled) { background: var(--navy-deep); }
.btn-ghost-navy { background: transparent; color: var(--navy); border: 1.6px solid var(--line); }
.btn-ghost-navy:hover:not(:disabled) { background: var(--light); border-color: var(--navy); }
.btn-ghost-red { background: transparent; color: var(--red); border: 1.6px solid var(--line); }
.btn-ghost-red:hover:not(:disabled) { background: var(--red); color: #fff; border-color: var(--red); }
.btn-block { width: 100%; }
.btn-lg { padding: 20px 30px; font-size: 18.5px; }
.btn-sm { padding: 10px 18px; font-size: 14.5px; border-radius: 40px; }

.spinner {
  width: 17px; height: 17px; border-radius: 50%;
  border: 2.5px solid rgba(255, 255, 255, .4); border-top-color: #fff;
  animation: spin .7s linear infinite; flex: none; display: none;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Shared top bar / logo ---------- */
header.topbar {
  background: rgba(255, 255, 255, .96);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 2px 14px rgba(30, 51, 100, .06);
}
.topbar-inner { display: flex; align-items: center; justify-content: space-between; gap: 14px; height: 68px; width: 100%; padding: 0 32px; }
.logo { display: flex; align-items: center; gap: 11px; font-weight: 900; letter-spacing: -.4px; font-size: 21px; color: var(--navy); }
.logo .mark {
  width: 40px; height: 40px; border-radius: 11px; flex: none;
  background: linear-gradient(135deg, var(--sky), var(--navy));
  display: flex; align-items: center; justify-content: center;
  color: #fff; box-shadow: var(--shadow-sm);
}
.logo .mark svg { width: 23px; height: 23px; }
.logo b { color: var(--sky); }

/* ---------- Auth page ---------- */
.auth-page {
  min-height: calc(100vh - 68px);
  background: radial-gradient(1100px 620px at 78% -8%, #1d5d8c 0%, rgba(29, 93, 140, 0) 60%),
              linear-gradient(155deg, #1E3364 0%, #142449 60%, #0F1B38 100%);
  display: flex; align-items: center; justify-content: center;
  padding: 48px 20px;
}
.auth-card {
  width: 100%; max-width: 440px;
  background: #fff; border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  overflow: hidden;
}
.auth-card .ac-head {
  background: linear-gradient(100deg, var(--navy), var(--navy-deep));
  color: #fff; padding: 28px 32px; text-align: center;
}
.auth-card .ac-head h1 { font-size: 24px; font-weight: 900; letter-spacing: -.3px; line-height: 1.2; }
.auth-card .ac-head p { font-size: 14.5px; opacity: .85; margin-top: 6px; font-weight: 600; }
.auth-card .ac-body { padding: 28px 32px 32px; }

.alert-banner {
  display: flex; align-items: center; gap: 10px;
  border-radius: 11px; padding: 13px 15px; font-size: 14.5px; font-weight: 700;
  margin-bottom: 18px;
}
.alert-banner.alert { background: #FDEAEA; color: var(--orange-dark); border: 1.5px solid #FAD2B0; }
.alert-banner.notice { background: #E6F7ED; color: #0F7A3B; border: 1.5px solid #BFE9CE; }

.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; font-weight: 700; color: var(--navy); margin-bottom: 6px; letter-spacing: .2px; }
.field input {
  width: 100%; font-size: 16px; font-family: inherit; color: var(--ink);
  padding: 13px 14px; border: 1.6px solid var(--line); border-radius: 11px;
  background: #fbfdff; transition: border .15s, box-shadow .15s;
}
.field input:focus { outline: none; border-color: var(--sky); box-shadow: 0 0 0 3px rgba(30, 194, 229, .18); }
.field input.field-invalid { border-color: var(--red); }
.field-hint { font-size: 12.5px; color: var(--red); margin-top: 6px; font-weight: 600; display: none; }
.field-hint.show { display: block; }

.password-field { position: relative; }
.password-field input { padding-right: 46px; }
.password-toggle {
  position: absolute; top: 50%; right: 6px; transform: translateY(-50%);
  width: 34px; height: 34px; border: none; background: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center; color: var(--muted); border-radius: 8px;
}
.password-toggle:hover { color: var(--navy); background: var(--light); }
.password-toggle svg { width: 19px; height: 19px; }
.password-toggle .icon-hide { display: none; }
.password-toggle.is-visible .icon-show { display: none; }
.password-toggle.is-visible .icon-hide { display: block; }

.checkbox-row { display: flex; align-items: center; gap: 9px; margin-bottom: 22px; }
.checkbox-row input[type="checkbox"] { width: 17px; height: 17px; accent-color: var(--navy); cursor: pointer; }
.checkbox-row label { font-size: 14.5px; color: var(--muted); font-weight: 600; cursor: pointer; margin: 0; }

.form-foot { margin-top: 6px; }

/* ---------- Admin shell ---------- */
.admin-topbar-right { display: flex; align-items: center; gap: 16px; }
.admin-greeting { font-size: 15px; font-weight: 700; color: var(--navy); }
.admin-main { min-height: calc(100vh - 68px); padding: 56px 20px; }
.admin-placeholder {
  max-width: 640px; margin: 0 auto; background: #fff; border: 1px solid var(--line);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); padding: 48px 40px; text-align: center;
}
.admin-placeholder h1 { font-size: 26px; font-weight: 900; color: var(--navy); letter-spacing: -.4px; margin-bottom: 12px; }
.admin-placeholder p { font-size: 16px; color: var(--muted); }

@media (max-width: 480px) {
  .topbar-inner { padding: 0 16px; }
  .auth-card .ac-head { padding: 24px 22px; }
  .auth-card .ac-body { padding: 22px 22px 26px; }
  .admin-placeholder { padding: 36px 22px; }
}

/* ---------- Admin Leads ---------- */
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; }
.page-header h1 { font-size: 26px; font-weight: 900; color: var(--navy); letter-spacing: -.4px; }

.filter-bar {
  display: flex; flex-wrap: wrap; gap: 12px; align-items: center;
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; margin-bottom: 20px; box-shadow: var(--shadow-sm);
}
.filter-input, .filter-select {
  padding: 10px 14px; border: 1.6px solid var(--line); border-radius: 10px;
  font-size: 14.5px; color: var(--ink); font-family: inherit; background: #fff;
}

.table-scroll { overflow-x: auto; background: #fff; border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.data-table { width: 100%; border-collapse: collapse; font-size: 14.5px; }
.data-table th {
  text-align: left; padding: 14px 16px; background: var(--light); color: var(--muted);
  font-weight: 800; font-size: 12.5px; text-transform: uppercase; letter-spacing: .04em;
  border-bottom: 1px solid var(--line);
}
.data-table td { padding: 14px 16px; border-bottom: 1px solid var(--line); color: var(--ink); }
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: var(--light); }
.empty-row { text-align: center; color: var(--muted); padding: 40px !important; }

.badge { display: inline-block; padding: 4px 12px; border-radius: 40px; font-size: 12.5px; font-weight: 700; background: var(--light); color: var(--navy); }
.badge-status-new { background: #E7F0FF; color: var(--navy); }
.badge-status-contacted { background: #FFF3D6; color: #8A6100; }
.badge-status-qualified { background: #E2F8E9; color: var(--green); }
.badge-status-closed { background: #F0F0F0; color: var(--muted); }

/* Compliance analysis */
.muted { color: var(--muted); font-weight: 600; }
.badge-severity-high { background: #FDEAEA; color: #B42318; }
.badge-severity-medium { background: #FFF3D6; color: #8A6100; }
.badge-severity-low { background: #EDEBFF; color: #5B4FC0; }
.badge-clean { background: #E2F8E9; color: var(--green); }

/* Priority lead flag (urgent / emergency chatbot leads) */
.badge-priority { background: #FDEAEA; color: #B42318; }
.filter-check { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--navy); font-weight: 600; }
.analysis-list, .analysis-flags { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 8px; }
.analysis-flags { list-style: none; padding-left: 0; }
.analysis-flags li { padding: 10px 12px; border: 1.5px solid var(--line); border-radius: 10px; }
.analysis-flag-desc { margin: 6px 0 0; }
.analysis-flag-quote { margin: 4px 0 0; color: var(--muted); font-style: italic; }
.analysis-notes { margin-top: 10px; }
.analysis-meta { margin-top: 14px; font-size: 12.5px; }

.pagination { display: flex; gap: 6px; justify-content: center; margin-top: 24px; }
.pagination .page-link {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 36px; height: 36px; border-radius: 10px; font-weight: 700; font-size: 14px;
  color: var(--navy); border: 1.6px solid var(--line);
}
.pagination .page-link.active { background: var(--navy); color: #fff; border-color: var(--navy); }
.pagination .page-gap { display: inline-flex; align-items: center; padding: 0 4px; color: var(--muted); }

/* ── Admin nav ─────────────────────────────────────────────── */
.admin-nav { display: flex; gap: 4px; margin-left: 22px; flex: 1; }
.admin-nav-link {
  text-decoration: none; color: var(--navy); font-weight: 700; font-size: 14px;
  padding: 8px 14px; border-radius: 9px; transition: background .15s, color .15s;
}
.admin-nav-link:hover { background: var(--light); }

/* ── Knowledge-source form ─────────────────────────────────── */
.field textarea, .field select {
  width: 100%; font-size: 15px; font-family: inherit; color: var(--ink);
  padding: 13px 14px; border: 1.6px solid var(--line); border-radius: 11px;
  background: #fbfdff; transition: border .15s, box-shadow .15s;
}
.field textarea { resize: vertical; min-height: 140px; line-height: 1.5; }
.field textarea:focus, .field select:focus {
  outline: none; border-color: var(--sky); box-shadow: 0 0 0 3px rgba(30, 194, 229, .18);
}
.field input[type="file"] { padding: 10px 12px; }
.field-note { font-size: 12.5px; color: var(--muted); margin-top: 6px; font-weight: 500; }
.ks-form { max-width: 720px; }
.ks-form-wrap { padding-top: 8px; }
.ks-form-foot { display: flex; gap: 10px; }
.ks-meta { color: var(--muted); font-size: 13.5px; margin: 0 0 18px; }

/* ── Knowledge-source table ────────────────────────────────── */
.row-actions { display: flex; gap: 6px; white-space: nowrap; }
.row-actions form { display: inline; margin: 0; }
.badge-on  { background: #E6F7ED; color: #0F7A3B; }
.badge-off { background: #EEF1F4; color: var(--muted); }

/* ── Lead show page ────────────────────────────────────────── */
.back-link { display: inline-block; font-size: 13.5px; font-weight: 700; color: var(--muted); margin-bottom: 8px; }
.back-link:hover { color: var(--navy); }
.detail-badges { display: flex; gap: 8px; align-items: flex-start; }

.detail-card {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow-sm); padding: 24px; margin-bottom: 20px;
}
.detail-card h2 { font-size: 16px; font-weight: 800; color: var(--navy); margin-bottom: 14px; }

.detail-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 18px; }
.detail-item dt { font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin-bottom: 4px; }
.detail-item dd { font-size: 15px; color: var(--ink); font-weight: 600; }
.detail-item-full { margin-top: 18px; }
/* Free-text fields (Notes, Transcription) keep author line breaks. Single-value
   fields must not, or ERB source indentation renders as literal whitespace. */
.detail-item-full dd { white-space: pre-wrap; }
/* Transcription branches on state in ERB, so its dd must NOT keep source
   indentation as whitespace — the pre-wrap lives on the inner text node only. */
.transcription-item dd { white-space: normal; }
.transcription-text { white-space: pre-wrap; margin: 0; font-size: 15px; font-weight: 600; color: var(--ink); }
.transcription-item .muted { color: var(--muted); font-weight: 600; }

/* Voice Intelligence conversation view: role + timestamp gutter, then the line,
   speakers interleaved in chronological order (mirrors the Twilio console). */
.vi-transcript { display: flex; flex-direction: column; margin-top: 4px; border: 1px solid var(--line, #E6EAF0); border-radius: 12px; overflow: hidden; }
.vi-line { display: grid; grid-template-columns: 110px 1fr; gap: 14px; padding: 12px 16px; border-bottom: 1px solid var(--line, #EEF1F6); }
.vi-line:last-child { border-bottom: 0; }
.vi-line-customer { background: #F6F8FB; }
.vi-meta { display: flex; flex-direction: column; text-align: right; }
.vi-role { font-size: 12px; font-weight: 800; color: var(--navy, #1B2A4A); }
.vi-time { font-size: 12px; font-weight: 600; color: var(--muted); font-variant-numeric: tabular-nums; }
.vi-text { margin: 0; font-size: 14.5px; font-weight: 500; color: var(--ink); white-space: pre-wrap; border-left: 2px solid var(--line, #E6EAF0); padding-left: 14px; }

.transcript { display: flex; flex-direction: column; gap: 10px; }
.transcript-msg { padding: 10px 14px; border-radius: 11px; background: var(--light); max-width: 80%; }
.transcript-msg p { font-size: 14.5px; margin-top: 2px; }
.transcript-role { font-size: 11.5px; font-weight: 800; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.transcript-msg-bot { background: #E7F0FF; align-self: flex-start; }
.transcript-msg-user { background: var(--light); align-self: flex-end; }

.icon-btn { display: inline-flex; align-items: center; gap: 6px; }
.icon-btn svg { width: 16px; height: 16px; }
