/* ═══════════════════════════════════════════════════════════════
   Matador Fire Analytics Dashboard — Styles
   Brand: Charcoal #0D0B09, Bone #F0E8DC, Red #EC1B34, Ember #C44A0A, 
          Orange #E8821A, Ash #6D6F70
   ═══════════════════════════════════════════════════════════════ */

:root {
  --red: #EC1B34;
  --ember: #C44A0A;
  --orange: #E8821A;
  --charcoal: #0D0B09;
  --bone: #F0E8DC;
  --ash: #6D6F70;
  --white: #FFFFFF;
  --surface: #161210;
  --surface-2: #1E1A17;
  --surface-3: #262220;
  --border: #2A2622;
  --border-light: #3A3632;
  --text-primary: #F0E8DC;
  --text-secondary: #A09888;
  --text-muted: #6D6F70;
  --success: #2ECC71;
  --warning: #F39C12;
  --danger: #EC1B34;
  --font-display: 'Clarendon', Rockwell, Georgia, serif;
  --font-body: 'Cabinet Grotesk', 'DM Sans', system-ui, -apple-system, sans-serif;
  --radius: 8px;
  --radius-lg: 12px;
  --transition: 0.2s ease;
}

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

html { 
  font-size: 16px; 
  -webkit-font-smoothing: antialiased; 
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-body);
  background: var(--charcoal);
  color: var(--text-primary);
  line-height: 1.5;
  min-height: 100vh;
}

.hidden { display: none !important; }

/* ═══ Password Screen ═══ */
.password-screen {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--charcoal);
  z-index: 1000;
}

.password-container {
  text-align: center;
  max-width: 360px;
  width: 100%;
  padding: 0 24px;
}

.password-logo {
  margin-bottom: 24px;
  animation: fadeInUp 0.6s ease;
}

.password-title {
  font-family: var(--font-display);
  font-size: 1.75rem;
  color: var(--bone);
  margin-bottom: 4px;
  letter-spacing: -0.01em;
}

.password-subtitle {
  font-family: var(--font-body);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.15em;
  color: var(--red);
  margin-bottom: 32px;
}

#password-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

#password-input {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  font-family: var(--font-body);
  font-size: 1rem;
  color: var(--bone);
  outline: none;
  transition: border-color var(--transition);
  text-align: center;
  letter-spacing: 0.15em;
}

#password-input:focus {
  border-color: var(--red);
}

#password-input::placeholder {
  color: var(--text-muted);
  letter-spacing: 0.05em;
}

#password-submit {
  background: var(--red);
  border: none;
  border-radius: var(--radius);
  padding: 14px;
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.15em;
  color: var(--white);
  cursor: pointer;
  transition: background var(--transition), transform 0.1s ease;
}

#password-submit:hover { background: #d41830; }
#password-submit:active { transform: scale(0.98); }

.password-error {
  color: var(--red);
  font-size: 0.85rem;
  margin-top: 12px;
  min-height: 20px;
}

/* ═══ Dashboard Layout ═══ */
.dashboard {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ═══ Header ═══ */
.dash-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 28px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-logo { flex-shrink: 0; }

.header-text h1 {
  font-family: var(--font-display);
  font-size: 1.2rem;
  color: var(--bone);
  letter-spacing: -0.01em;
  line-height: 1.2;
}

.header-badge {
  font-family: var(--font-body);
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.2em;
  color: var(--red);
  background: rgba(236, 27, 52, 0.1);
  padding: 2px 8px;
  border-radius: 4px;
  display: inline-block;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 20px;
}

.header-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
  display: inline-block;
}

.header-date {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.btn-reset {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 6px 14px;
  font-family: var(--font-body);
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}

.btn-reset:hover {
  color: var(--red);
  border-color: var(--red);
  background: rgba(236, 27, 52, 0.08);
}

.btn-reset:active { transform: scale(0.97); }

.btn-reset.resetting {
  pointer-events: none;
  opacity: 0.5;
}

.btn-reset.resetting svg {
  animation: spin 0.6s linear infinite;
}

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

/* ═══ Reset Confirmation Modal ═══ */
.reset-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(13, 11, 9, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: fadeIn 0.2s ease;
}

.reset-modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px;
  max-width: 400px;
  width: 90%;
  text-align: center;
}

.reset-modal h2 {
  font-family: var(--font-display);
  font-size: 1.25rem;
  color: var(--bone);
  margin-bottom: 8px;
  letter-spacing: -0.01em;
}

.reset-modal p {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 24px;
  line-height: 1.5;
}

.reset-modal-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
}

.reset-modal .btn-cancel {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 24px;
  font-family: var(--font-body);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition);
}

.reset-modal .btn-cancel:hover {
  border-color: var(--border-light);
  color: var(--bone);
}

.reset-modal .btn-confirm-reset {
  background: var(--red);
  border: none;
  border-radius: var(--radius);
  padding: 10px 24px;
  font-family: var(--font-body);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--white);
  cursor: pointer;
  transition: all var(--transition);
}

.reset-modal .btn-confirm-reset:hover {
  background: #d41830;
}

/* ═══ Tab Navigation ═══ */
.tab-nav {
  display: flex;
  gap: 2px;
  padding: 0 28px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.tab-nav::-webkit-scrollbar { display: none; }

.tab-btn {
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  background: none;
  border: none;
  padding: 12px 20px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: color var(--transition), border-color var(--transition);
  white-space: nowrap;
  position: relative;
}

.tab-btn:hover { color: var(--text-secondary); }

.tab-btn.active {
  color: var(--red);
  border-bottom-color: var(--red);
}

/* ═══ Tab Content ═══ */
.tab-content {
  flex: 1;
  padding: 24px 28px;
  max-width: 1440px;
  margin: 0 auto;
  width: 100%;
}

.tab-panel { display: none; animation: fadeIn 0.3s ease; }
.tab-panel.active { display: block; }

/* ═══ KPI Grid ═══ */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  transition: border-color var(--transition);
}

.kpi-card:hover { border-color: var(--border-light); }

.kpi-label {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.kpi-value {
  font-family: var(--font-display);
  font-size: 1.75rem;
  color: var(--bone);
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums lining-nums;
  line-height: 1.1;
}

.kpi-delta {
  font-size: 0.75rem;
  font-weight: 600;
  margin-top: 6px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.kpi-delta.up { color: var(--success); }
.kpi-delta.down { color: var(--danger); }
.kpi-delta.flat { color: var(--text-muted); }

/* ═══ Chart Cards ═══ */
.chart-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}

.chart-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
}

.chart-card.wide {
  grid-column: 1 / -1;
}

.chart-title {
  font-family: var(--font-display);
  font-size: 1rem;
  color: var(--bone);
  margin-bottom: 2px;
  letter-spacing: -0.01em;
}

.chart-subtitle {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.chart-container {
  position: relative;
  width: 100%;
  min-height: 250px;
}

.chart-container canvas {
  width: 100% !important;
}

/* ═══ Heatmap ═══ */
.heatmap-wrapper {
  position: relative;
  width: 100%;
  max-width: 800px;
  margin: 0 auto;
  background: var(--surface-2);
  border-radius: var(--radius);
  overflow: hidden;
}

.heatmap-wrapper canvas {
  width: 100%;
  height: auto;
  display: block;
}

/* ═══ Funnel Visual ═══ */
.funnel-visual {
  margin-bottom: 24px;
}

.funnel-step {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 4px;
}

.funnel-bar-wrapper {
  flex: 1;
  position: relative;
}

.funnel-bar {
  height: 44px;
  background: var(--red);
  border-radius: 0 var(--radius) var(--radius) 0;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 12px;
  transition: width 0.8s cubic-bezier(0.16, 1, 0.3, 1);
  min-width: 60px;
  position: relative;
}

.funnel-bar-label {
  color: var(--white);
  font-size: 0.8rem;
  font-weight: 700;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.funnel-step-name {
  width: 160px;
  flex-shrink: 0;
  text-align: right;
  font-size: 0.8rem;
  color: var(--text-secondary);
  font-weight: 600;
}

.funnel-dropoff {
  width: 80px;
  flex-shrink: 0;
  font-size: 0.75rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.funnel-bar.alt { background: var(--ember); }
.funnel-bar.alt2 { background: var(--orange); }

/* ═══ Engagement Stats ═══ */
.engagement-stats {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding-top: 8px;
}

.stat-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

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

.stat-label {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.stat-value {
  font-family: var(--font-display);
  font-size: 1.1rem;
  color: var(--bone);
  font-variant-numeric: tabular-nums;
}

.stat-value.danger { color: var(--red); }
.stat-value.warning { color: var(--warning); }

/* ═══ Paths List ═══ */
.paths-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.path-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--surface-2);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.path-rank {
  font-family: var(--font-display);
  font-size: 1.1rem;
  color: var(--red);
  width: 28px;
  text-align: center;
  flex-shrink: 0;
}

.path-steps {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.path-step-tag {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 4px 10px;
  background: var(--surface-3);
  border-radius: 4px;
  color: var(--text-secondary);
  white-space: nowrap;
}

.path-arrow {
  color: var(--text-muted);
  font-size: 0.7rem;
}

.path-count {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
  width: 80px;
  text-align: right;
}

/* ═══ Session List ═══ */
.session-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 500px;
  overflow-y: auto;
}

.session-item {
  padding: 14px 16px;
  background: var(--surface-2);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: border-color var(--transition);
}

.session-item:hover { border-color: var(--border-light); }
.session-item.rage { border-left: 3px solid var(--red); }

.session-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.session-badge {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 4px;
  background: var(--surface-3);
  color: var(--text-secondary);
}

.session-badge.rage-badge { background: rgba(236, 27, 52, 0.15); color: var(--red); }
.session-badge.returning { background: rgba(46, 204, 113, 0.15); color: var(--success); }
.session-badge.device-badge { background: rgba(232, 130, 26, 0.1); color: var(--orange); }

.session-timeline {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.timeline-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--border-light);
  transition: transform 0.15s ease;
}

.timeline-dot.page-view { background: var(--red); }
.timeline-dot.funnel { background: var(--ember); }
.timeline-dot.click { background: var(--ash); width: 5px; height: 5px; }
.timeline-dot.scroll { background: var(--text-muted); width: 5px; height: 5px; }
.timeline-dot.form { background: var(--success); }
.timeline-dot.rage { background: var(--danger); }
.timeline-dot.idle { background: var(--warning); }

.session-time {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

/* ═══ Leads Table ═══ */
.leads-toolbar {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 16px;
}

.lead-search {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 16px;
  font-family: var(--font-body);
  font-size: 0.9rem;
  color: var(--bone);
  outline: none;
  transition: border-color var(--transition);
}

.lead-search:focus { border-color: var(--red); }
.lead-search::placeholder { color: var(--text-muted); }

.btn-export {
  background: var(--red);
  border: none;
  border-radius: var(--radius);
  padding: 10px 20px;
  font-family: var(--font-body);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--white);
  cursor: pointer;
  transition: background var(--transition);
  white-space: nowrap;
}

.btn-export:hover { background: #d41830; }

.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
}

.leads-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.leads-table th {
  background: var(--surface-2);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 12px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  position: sticky;
  top: 0;
}

.leads-table td {
  padding: 10px 14px;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.leads-table tbody tr:hover td { background: var(--surface-2); }

.score-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 24px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--white);
}

.score-hot { background: var(--red); }
.score-warm { background: var(--ember); }
.score-med { background: var(--orange); }
.score-cool { background: var(--ash); }

.risk-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.05em;
}

.risk-very-high { background: rgba(236, 27, 52, 0.15); color: var(--red); }
.risk-high { background: rgba(196, 74, 10, 0.15); color: var(--ember); }
.risk-moderate { background: rgba(232, 130, 26, 0.15); color: var(--orange); }
.risk-not-classified { background: rgba(109, 111, 112, 0.15); color: var(--ash); }

/* ═══ Footer ═══ */
.dash-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 28px;
  border-top: 1px solid var(--border);
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* ═══ Animations ═══ */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ═══ Scrollbar ═══ */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--ash); }

/* ═══ Responsive ═══ */
@media (max-width: 768px) {
  .dash-header { padding: 12px 16px; }
  .header-right { gap: 8px; }
  .header-right .header-status,
  .header-right .header-date { display: none; }
  
  .tab-nav { padding: 0 16px; }
  .tab-btn { padding: 10px 14px; font-size: 0.8rem; }
  
  .tab-content { padding: 16px; }
  
  .kpi-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .kpi-value { font-size: 1.35rem; }
  
  .chart-row { grid-template-columns: 1fr; }
  
  .funnel-step-name { width: 100px; font-size: 0.7rem; }
  .funnel-dropoff { width: 60px; font-size: 0.65rem; }
  .funnel-bar { height: 34px; }
  
  .leads-toolbar { flex-direction: column; }
  
  .path-item { flex-direction: column; align-items: flex-start; }
  .path-count { width: auto; text-align: left; }
  
  .dash-footer { flex-direction: column; gap: 4px; text-align: center; }
}

@media (max-width: 480px) {
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .kpi-card { padding: 14px; }
  .kpi-value { font-size: 1.2rem; }
  .tab-btn { padding: 10px 10px; font-size: 0.75rem; }
}
