/* JDH AI Call Quality Dashboard — Redesign */
@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@400;500;600;700;800&display=swap');

:root {
  --navy:         #001C3D;
  --navy-mid:     #002a5c;
  --navy-light:   #0a3060;
  --blue:         #0075FF;
  --blue-hover:   #005fcc;
  --orange:       #E77139;
  --orange-hover: #cf6030;
  --bg:           #f0f4f9;
  --card:         #ffffff;
  --text:         #0d1b2e;
  --text-muted:   #5a708a;
  --border:       #dce5f0;
  --green:        #22c55e;
  --yellow:       #f0b429;
  --red:          #ef4444;
  --excellent:    #22c55e;
  --good:         #f0b429;
  --needs-work:   #E77139;
  --poor:         #ef4444;
  --radius:       10px;
  --shadow:       0 2px 8px rgba(0, 28, 61, 0.08);
  --shadow-md:    0 4px 20px rgba(0, 28, 61, 0.12);
}

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

body {
  font-family: 'Montserrat', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  font-size: 14px;
}

.hidden { display: none !important; }
.screen { min-height: 100vh; }

/* ─── Login ─── */
#login-screen {
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-mid) 60%, #0a3560 100%);
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-card {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(12px);
  padding: 52px 44px;
  border-radius: 20px;
  text-align: center;
  max-width: 420px;
  width: 90%;
  box-shadow: 0 8px 40px rgba(0,0,0,0.35);
}

.login-logo-img {
  height: 64px;
  margin-bottom: 20px;
  filter: brightness(0) invert(1);
}

.login-card h1 {
  font-size: 22px;
  font-weight: 700;
  color: #ffffff;
  margin-bottom: 8px;
  letter-spacing: -0.3px;
}

.login-card p {
  color: rgba(255,255,255,0.55);
  margin-bottom: 36px;
  font-size: 14px;
}

/* ─── Buttons ─── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius);
  font-family: 'Montserrat', sans-serif;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
}

.btn-primary {
  background: var(--blue);
  color: white;
}
.btn-primary:hover { background: var(--blue-hover); }

.btn-orange {
  background: var(--orange);
  color: white;
}
.btn-orange:hover { background: var(--orange-hover); }

.btn-google {
  background: white;
  color: #2d3748;
  border: 1px solid rgba(255,255,255,0.2);
  padding: 13px 28px;
  font-size: 14px;
  font-weight: 600;
  border-radius: 10px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.15);
}
.btn-google:hover {
  background: #f8fafc;
  box-shadow: 0 4px 16px rgba(0,0,0,0.2);
  transform: translateY(-1px);
}

.btn-sm { padding: 5px 14px; font-size: 12px; }

.btn-outline {
  background: transparent;
  border: 1px solid rgba(255,255,255,0.25);
  color: rgba(255,255,255,0.8);
}
.btn-outline:hover {
  background: rgba(255,255,255,0.1);
  border-color: rgba(255,255,255,0.5);
  color: white;
}

.btn-train {
  background: var(--orange);
  color: white;
  padding: 4px 12px;
  font-size: 11px;
  font-weight: 700;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  letter-spacing: 0.3px;
  transition: background 0.15s;
}
.btn-train:hover { background: var(--orange-hover); }

/* ─── Top Nav ─── */
.topnav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 32px;
  height: 64px;
  background: var(--navy);
  position: sticky;
  top: 0;
  z-index: 200;
  box-shadow: 0 2px 12px rgba(0,0,0,0.3);
}

.nav-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

.nav-logo-img {
  height: 36px;
  filter: brightness(0) invert(1);
}

.nav-divider {
  width: 1px;
  height: 24px;
  background: rgba(255,255,255,0.2);
}

.nav-title {
  font-size: 14px;
  font-weight: 600;
  color: rgba(255,255,255,0.7);
  letter-spacing: 0.2px;
}

.nav-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-info {
  font-size: 13px;
  font-weight: 500;
  color: rgba(255,255,255,0.8);
}

.avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.25);
}

/* ─── Main Content ─── */
.main-content {
  max-width: 1440px;
  margin: 0 auto;
  padding: 28px 32px;
}

/* ─── Flywheel Widget ─── */
.flywheel-widget {
  background: var(--navy);
  border-radius: 16px;
  padding: 28px 32px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-md);
  position: relative;
  overflow: hidden;
}

.flywheel-widget::before {
  content: '';
  position: absolute;
  top: -60px;
  right: -60px;
  width: 220px;
  height: 220px;
  background: radial-gradient(circle, rgba(231,113,57,0.15) 0%, transparent 70%);
  pointer-events: none;
}

.flywheel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.flywheel-header h3 {
  font-size: 15px;
  font-weight: 700;
  color: white;
  text-transform: uppercase;
  letter-spacing: 0.8px;
}

.flywheel-badge {
  background: rgba(231,113,57,0.2);
  border: 1px solid rgba(231,113,57,0.4);
  color: var(--orange);
  font-size: 11px;
  font-weight: 700;
  padding: 4px 12px;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.flywheel-body {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 32px;
  align-items: center;
}

/* Gauge */
.flywheel-gauge-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.gauge-circle {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: conic-gradient(var(--orange) 0% 0%, rgba(255,255,255,0.08) 0% 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: background 0.6s;
}

.gauge-inner {
  width: 90px;
  height: 90px;
  border-radius: 50%;
  background: var(--navy);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.gauge-value {
  font-size: 26px;
  font-weight: 800;
  color: var(--orange);
  line-height: 1;
}

.gauge-label {
  font-size: 9px;
  font-weight: 600;
  color: rgba(255,255,255,0.5);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 2px;
}

.gauge-caption {
  font-size: 11px;
  color: rgba(255,255,255,0.5);
  font-weight: 500;
}

/* Stats grid */
.flywheel-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}

.flywheel-stat {
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 12px;
  padding: 16px;
  transition: border-color 0.15s;
}

.flywheel-stat:hover {
  border-color: rgba(255,255,255,0.18);
}

.flywheel-num {
  display: block;
  font-size: 28px;
  font-weight: 800;
  color: white;
  line-height: 1;
  margin-bottom: 6px;
}

.flywheel-label {
  display: block;
  font-size: 11px;
  font-weight: 500;
  color: rgba(255,255,255,0.45);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

/* Progress bar */
.flywheel-progress {
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid rgba(255,255,255,0.08);
}

.flywheel-progress-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.flywheel-progress-header span {
  font-size: 11px;
  font-weight: 600;
  color: rgba(255,255,255,0.5);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.flywheel-progress-header strong {
  font-size: 12px;
  font-weight: 700;
  color: var(--orange);
}

.progress-bar-container {
  height: 6px;
  background: rgba(255,255,255,0.1);
  border-radius: 3px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--blue) 0%, var(--orange) 100%);
  border-radius: 3px;
  transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.progress-labels {
  display: flex;
  justify-content: space-between;
  margin-top: 5px;
}

.progress-labels span {
  font-size: 10px;
  color: rgba(255,255,255,0.3);
  font-weight: 500;
}

/* ─── Filters Bar ─── */
.filters-bar {
  background: var(--card);
  border-radius: 14px;
  padding: 18px 20px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: flex-end;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
}

.filter-group label {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.6px;
}

.filter-group input,
.filter-group select {
  padding: 8px 12px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-family: 'Montserrat', sans-serif;
  font-size: 13px;
  font-weight: 500;
  background: white;
  color: var(--text);
  transition: border-color 0.15s;
  appearance: auto;
}

.filter-group input:focus,
.filter-group select:focus {
  outline: none;
  border-color: var(--blue);
}

.quick-filters {
  display: flex;
  gap: 6px;
}

.chip {
  padding: 7px 14px;
  border: 1.5px solid var(--border);
  border-radius: 20px;
  font-family: 'Montserrat', sans-serif;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  background: white;
  color: var(--text-muted);
  transition: all 0.15s;
  letter-spacing: 0.2px;
}

.chip:hover, .chip.active {
  background: var(--navy);
  color: white;
  border-color: var(--navy);
}

/* ─── Table ─── */
.table-container {
  background: var(--card);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: var(--shadow);
}

table {
  width: 100%;
  border-collapse: collapse;
}

thead {
  background: #f7f9fc;
  border-bottom: 2px solid var(--border);
}

th {
  text-align: left;
  padding: 13px 16px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  color: var(--text-muted);
  white-space: nowrap;
}

td {
  padding: 13px 16px;
  font-size: 13px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

tbody tr {
  transition: background 0.1s;
}

tbody tr:hover {
  background: #f5f9ff;
  cursor: pointer;
}

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

.empty-state {
  text-align: center;
  padding: 56px !important;
  color: var(--text-muted);
  font-weight: 500;
}

/* Customer name in table */
.customer-name {
  font-weight: 600;
  color: var(--text);
}

.customer-phone {
  color: var(--text-muted);
  font-size: 12px;
}

/* Setter pill */
.setter-pill {
  display: inline-block;
  background: rgba(0,117,255,0.1);
  color: var(--blue);
  font-size: 11px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 20px;
  white-space: nowrap;
}

/* Service pill */
.service-pill {
  display: inline-block;
  background: rgba(231,113,57,0.1);
  color: var(--orange);
  font-size: 11px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 20px;
  white-space: nowrap;
}

/* Score badges */
.score-badge {
  display: inline-block;
  padding: 5px 12px;
  border-radius: 20px;
  font-weight: 700;
  font-size: 12px;
  color: white;
  min-width: 48px;
  text-align: center;
  letter-spacing: 0.3px;
}

.score-excellent { background: var(--excellent); }
.score-good      { background: var(--good); color: #3d2800; }
.score-needs-work{ background: var(--needs-work); }
.score-poor      { background: var(--poor); }

/* Play button */
.play-btn {
  background: rgba(0,117,255,0.08);
  border: 1.5px solid rgba(0,117,255,0.3);
  border-radius: 50%;
  width: 32px;
  height: 32px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--blue);
  font-size: 11px;
  transition: all 0.15s;
}

.play-btn:hover {
  background: var(--blue);
  color: white;
  border-color: var(--blue);
}

/* HubSpot link */
a.hs-link {
  color: var(--blue);
  text-decoration: none;
  font-size: 12px;
  font-weight: 600;
}

a.hs-link:hover { text-decoration: underline; }

/* ─── Pagination ─── */
.pagination {
  display: flex;
  justify-content: center;
  gap: 4px;
  margin-top: 20px;
  padding-bottom: 8px;
}

.page-btn {
  padding: 8px 14px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  background: var(--card);
  cursor: pointer;
  font-family: 'Montserrat', sans-serif;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  transition: all 0.15s;
}

.page-btn.active {
  background: var(--navy);
  color: white;
  border-color: var(--navy);
  font-weight: 700;
}

.page-btn:hover:not(.active) {
  background: var(--bg);
  border-color: var(--navy);
  color: var(--navy);
}

/* ─── Modal ─── */
.modal {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-overlay {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: rgba(0, 28, 61, 0.65);
  backdrop-filter: blur(4px);
}

.modal-content {
  position: relative;
  background: var(--card);
  border-radius: 20px;
  padding: 0;
  max-height: 92vh;
  overflow-y: auto;
  z-index: 1;
  box-shadow: 0 24px 64px rgba(0,0,0,0.3);
}

.modal-large {
  width: 92%;
  max-width: 1000px;
}

.modal-close {
  position: absolute;
  top: 16px;
  right: 20px;
  background: rgba(0,0,0,0.06);
  border: none;
  border-radius: 50%;
  width: 34px;
  height: 34px;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
  z-index: 2;
}

.modal-close:hover { background: rgba(0,0,0,0.12); color: var(--text); }

/* ─── Call Detail Layout ─── */
.detail-layout {
  display: grid;
  grid-template-columns: 1fr 300px;
  min-height: 100%;
}

.detail-main {
  padding: 32px;
  overflow-y: auto;
  border-right: 1px solid var(--border);
}

.detail-sidebar {
  padding: 28px 24px;
  background: #f7f9fc;
  border-radius: 0 20px 20px 0;
}

/* Detail header */
.detail-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 24px;
  gap: 16px;
}

.detail-header h2 {
  font-size: 22px;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 10px;
}

.detail-meta {
  font-size: 13px;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.detail-meta a {
  color: var(--blue);
  text-decoration: none;
  font-weight: 600;
}

.detail-score-wrap {
  text-align: center;
  flex-shrink: 0;
}

.detail-score {
  font-size: 52px;
  font-weight: 800;
  line-height: 1;
  display: block;
}

.detail-rating {
  font-size: 13px;
  font-weight: 700;
  margin-top: 4px;
  display: block;
}

/* Score sections */
.score-section {
  background: var(--bg);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  border: 1px solid var(--border);
}

.score-section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.score-section h4 {
  font-size: 13px;
  font-weight: 700;
  color: var(--navy);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.score-section-pts {
  font-weight: 700;
  font-size: 15px;
}

.sub-metric {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 7px 0;
  font-size: 13px;
  border-bottom: 1px solid var(--border);
  gap: 8px;
}

.sub-metric:last-child { border-bottom: none; }
.sub-metric-check { font-weight: 700; white-space: nowrap; }
.sub-metric-check.pass { color: var(--green); }
.sub-metric-check.fail { color: var(--red); }

.jump-link {
  display: inline-block;
  font-size: 11px;
  color: var(--blue);
  text-decoration: none;
  background: rgba(0,117,255,0.08);
  padding: 1px 7px;
  border-radius: 10px;
  margin-left: 6px;
  cursor: pointer;
  font-weight: 600;
}

.jump-link:hover {
  background: var(--blue);
  color: white;
}

/* Flags */
.flag-list { margin-top: 12px; }

.flag-item {
  display: flex;
  gap: 8px;
  padding: 9px 12px;
  background: #fff5f5;
  border-left: 3px solid var(--red);
  border-radius: 0 var(--radius) var(--radius) 0;
  margin-bottom: 8px;
  font-size: 13px;
  color: #7f1d1d;
}

/* Sidebar panels */
.sidebar-panel {
  background: white;
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 14px;
  border: 1px solid var(--border);
  box-shadow: 0 1px 4px rgba(0,0,0,0.04);
}

.sidebar-panel-title {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.sidebar-stat {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 5px 0;
  font-size: 13px;
  border-bottom: 1px solid var(--border);
}

.sidebar-stat:last-child { border-bottom: none; }

.sidebar-stat-label { color: var(--text-muted); font-weight: 500; }
.sidebar-stat-value { font-weight: 700; color: var(--text); }

/* Transcript */
.transcript-box {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  max-height: 380px;
  overflow-y: auto;
  font-size: 13px;
  line-height: 1.85;
  white-space: pre-wrap;
  font-family: 'SF Mono', Monaco, 'Courier New', monospace;
  color: #334155;
}

/* ─── Audio Bar ─── */
.audio-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--navy);
  border-top: 2px solid var(--orange);
  padding: 10px 28px;
  display: flex;
  align-items: center;
  gap: 16px;
  z-index: 500;
  box-shadow: 0 -4px 20px rgba(0,0,0,0.25);
}

.audio-bar-info {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 220px;
}

#audio-bar-title {
  font-size: 13px;
  font-weight: 600;
  color: rgba(255,255,255,0.9);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 180px;
}

.audio-bar audio {
  flex: 1;
  height: 36px;
}

.audio-bar .btn-sm {
  background: rgba(255,255,255,0.15);
  color: white;
  border: 1px solid rgba(255,255,255,0.2);
}

.audio-bar .btn-sm:hover {
  background: rgba(255,255,255,0.25);
}

/* ─── Responsive ─── */
@media (max-width: 1100px) {
  .flywheel-body {
    grid-template-columns: 1fr;
  }
  .flywheel-gauge-wrap {
    flex-direction: row;
    justify-content: center;
    gap: 24px;
  }
  .flywheel-stats {
    grid-template-columns: repeat(4, 1fr);
  }
  .detail-layout {
    grid-template-columns: 1fr;
  }
  .detail-sidebar {
    border-radius: 0 0 20px 20px;
    border-right: none;
    border-top: 1px solid var(--border);
  }
}

@media (max-width: 900px) {
  .flywheel-stats { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  .main-content { padding: 16px; }
  .topnav { padding: 0 16px; }
  .flywheel-widget { padding: 20px 16px; }
  .filters-bar { flex-direction: column; align-items: stretch; }
  .filter-group { width: 100%; }
  .filter-group input,
  .filter-group select { width: 100%; }

  table th:nth-child(3), table td:nth-child(3),
  table th:nth-child(8), table td:nth-child(8) { display: none; }
  td, th { padding: 10px 8px; font-size: 12px; }

  .modal-content { width: 100%; max-width: 100%; border-radius: 0; max-height: 100vh; }
  .detail-layout { grid-template-columns: 1fr; }
  .detail-main { padding: 20px 16px; }
  .detail-header { flex-direction: column; }
  .detail-score { font-size: 40px; }

  .audio-bar { flex-direction: column; padding: 8px 12px; gap: 6px; }
  .audio-bar-info { min-width: auto; }
  .audio-bar audio { width: 100%; }
}

@media (max-width: 480px) {
  .flywheel-stats { grid-template-columns: 1fr 1fr; }
  .flywheel-num { font-size: 22px; }
  .flywheel-label { font-size: 10px; }
  .score-badge { font-size: 11px; padding: 4px 8px; }
  .gauge-circle { width: 96px; height: 96px; }
  .gauge-inner { width: 72px; height: 72px; }
  .gauge-value { font-size: 20px; }
  .nav-title { display: none; }
  .nav-divider { display: none; }
}
