/* HaulPulse — Shared Styles */

/* ── Tokens ── */
:root {
  --primary:    #0A1628;
  --accent:     #FF3D5A;
  --secondary:  #10B981;
  --surface:    #F8FAFC;
  --text-body:  #1E293B;
  --text-muted: #64748B;
  --border:     #E2E8F0;
  --white:      #FFFFFF;
  --navy-mid:   #1B2D4F;
  --amber:      #F59E0B;
  --amber-bg:   #FFF7E6;
  --red:        #EF4444;
  --red-bg:     #FEF2F2;
  --green-bg:   #ECFDF5;
  --gray-bg:    #F1F5F9;
  --font:       'Inter', system-ui, -apple-system, sans-serif;
  --radius:     10px;
  --shadow-sm:  0 1px 3px rgba(0,0,0,.06);
  --shadow-md:  0 4px 12px rgba(0,0,0,.08);
}

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

html { font-size: 15px; }

body {
  font-family: var(--font);
  color: var(--text-body);
  background: var(--surface);
  line-height: 1.6;
  min-height: 100vh;
}

/* ── Typography ── */
h1 { font-size: 28px; font-weight: 800; color: var(--primary); }
h2 { font-size: 20px; font-weight: 700; color: var(--primary); }
h3 { font-size: 16px; font-weight: 600; color: var(--primary); }
p  { color: var(--text-body); }
small { font-size: 12px; color: var(--text-muted); }

/* ── Header / Nav ── */
.hp-header {
  background: var(--primary);
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 0 28px;
  height: 56px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 1px 0 rgba(255,255,255,.06);
}

.hp-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  flex-shrink: 0;
}

.hp-logo-text {
  font-size: 15px;
  font-weight: 800;
  color: #fff;
  letter-spacing: -0.3px;
}

.hp-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 1;
}

.hp-nav a {
  color: rgba(255,255,255,.55);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: 6px;
  transition: color .15s, background .15s;
}

.hp-nav a:hover {
  color: #fff;
  background: rgba(255,255,255,.08);
}

.hp-nav a.active {
  color: var(--accent);
  background: rgba(255,61,90,.12);
  border-bottom: 2px solid var(--accent);
  border-radius: 0;
}

.hp-header-right {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-shrink: 0;
}

.hp-user {
  font-size: 12px;
  color: rgba(255,255,255,.6);
  display: flex;
  align-items: center;
  gap: 6px;
}

.pulse-dot {
  width: 7px;
  height: 7px;
  background: var(--secondary);
  border-radius: 50%;
  display: inline-block;
  animation: pulse-anim 2s infinite;
}

@keyframes pulse-anim {
  0%, 100% { opacity: 1; }
  50% { opacity: .4; }
}

.btn-logout {
  background: transparent;
  border: 1px solid rgba(255,255,255,.2);
  color: rgba(255,255,255,.6);
  font-size: 12px;
  font-weight: 500;
  padding: 5px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-family: var(--font);
  transition: all .15s;
}
.btn-logout:hover {
  background: rgba(255,255,255,.08);
  color: #fff;
}

/* ── Layout ── */
.page-wrap {
  max-width: 1280px;
  margin: 0 auto;
  padding: 28px 28px 48px;
}

.page-wrap-full {
  padding: 28px 28px 48px;
}

/* ── Cards ── */
.card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  padding: 20px 24px;
}

.card-title {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
  margin-bottom: 14px;
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-family: var(--font);
  font-size: 14px;
  font-weight: 600;
  border-radius: 8px;
  cursor: pointer;
  border: none;
  padding: 10px 20px;
  min-height: 44px;
  text-decoration: none;
  transition: all .15s;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-primary:hover { background: #e6283e; }

.btn-success {
  background: var(--secondary);
  color: #fff;
}
.btn-success:hover { background: #0ea370; }

.btn-warning {
  background: transparent;
  border: 2px solid var(--amber);
  color: var(--amber);
}
.btn-warning:hover { background: var(--amber-bg); }

.btn-danger {
  background: transparent;
  border: none;
  color: var(--red);
  font-size: 13px;
  font-weight: 500;
  text-decoration: underline;
  min-height: auto;
  padding: 4px 8px;
}
.btn-danger:hover { color: #b91c1c; }

.btn-ghost {
  background: transparent;
  border: 2px solid var(--primary);
  color: var(--primary);
}
.btn-ghost:hover { background: var(--primary); color: #fff; }

.btn-sm {
  font-size: 12px;
  padding: 6px 14px;
  min-height: 34px;
}

.btn:disabled {
  opacity: .45;
  cursor: not-allowed;
}

/* ── Badges ── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 99px;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.badge-green  { background: var(--green-bg); color: var(--secondary); }
.badge-amber  { background: var(--amber-bg); color: #B45309; }
.badge-red    { background: var(--red-bg); color: var(--red); }
.badge-gray   { background: var(--gray-bg); color: var(--text-muted); }
.badge-navy   { background: #EEF2FF; color: var(--primary); }

/* ── Verdict badge ── */
.verdict {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  font-weight: 800;
  padding: 10px 18px;
  border-radius: 8px;
  letter-spacing: .04em;
}
.verdict-accept  { background: var(--green-bg); color: var(--secondary); border: 2px solid var(--secondary); }
.verdict-escalate { background: var(--amber-bg); color: #B45309; border: 2px solid var(--amber); }
.verdict-reject  { background: var(--red-bg); color: var(--red); border: 2px solid var(--red); }

/* ── Status pills ── */
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 99px;
  white-space: nowrap;
}

.status-free      { background: var(--green-bg); color: #065F46; }
.status-in_transit { background: #FFF7E6; color: #92400E; }
.status-cutoff    { background: var(--red-bg); color: var(--red); }
.status-maintenance { background: var(--gray-bg); color: var(--text-muted); }
.status-dispatched { background: #EEF2FF; color: #4338CA; }
.status-confirmed  { background: var(--green-bg); color: #065F46; }
.status-awaiting   { background: var(--amber-bg); color: #92400E; }
.status-escalated  { background: var(--red-bg); color: var(--red); }

/* ── Form elements ── */
.form-group { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.form-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--text-muted);
}

.form-input,
.form-select,
.form-textarea {
  font-family: var(--font);
  font-size: 14px;
  color: var(--text-body);
  background: var(--white);
  border: 1.5px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  width: 100%;
  transition: border-color .15s;
  outline: none;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(255,61,90,.1);
}

.form-textarea {
  resize: vertical;
  min-height: 140px;
  line-height: 1.5;
}

/* ── Toggle ── */
.toggle-group {
  display: flex;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.toggle-btn {
  flex: 1;
  text-align: center;
  padding: 9px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  background: var(--white);
  color: var(--text-muted);
  font-family: var(--font);
  transition: all .15s;
}

.toggle-btn.active {
  background: var(--primary);
  color: #fff;
}

.toggle-btn:not(:last-child) {
  border-right: 1.5px solid var(--border);
}

/* ── Table ── */
.hp-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.hp-table th {
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
  padding: 10px 14px;
  border-bottom: 2px solid var(--border);
  background: var(--surface);
  white-space: nowrap;
}

.hp-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.hp-table tbody tr:hover { background: #FAFBFC; }
.hp-table tbody tr:last-child td { border-bottom: none; }

/* ── Quote breakdown ── */
.quote-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}
.quote-row:last-child { border-bottom: none; }
.quote-row.total {
  font-size: 20px;
  font-weight: 800;
  color: var(--primary);
  padding-top: 12px;
}
.quote-row.rebate { color: var(--secondary); }

/* ── KPI tiles ── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.kpi-card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.kpi-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--text-muted);
}

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

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

/* ── Board grid ── */
.board-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

.trailer-card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  border-left: 4px solid transparent;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.trailer-card.status-free     { border-left-color: var(--secondary); background: #FAFFFE; }
.trailer-card.status-in_transit { border-left-color: var(--amber); background: #FFFDF7; }
.trailer-card.status-cutoff   { border-left-color: var(--red); background: #FFFAFA; }
.trailer-card.status-maintenance { border-left-color: #94A3B8; background: #F8F9FA; }

.trailer-num {
  font-size: 15px;
  font-weight: 700;
  color: var(--primary);
}

.trailer-size {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
}

.trailer-location {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.trailer-days {
  font-size: 11px;
  font-weight: 700;
  color: var(--red);
}

/* ── Alerts ── */
.alert {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 10px;
}

.alert-icon { font-size: 16px; flex-shrink: 0; margin-top: 1px; }
.alert-amber { background: var(--amber-bg); border: 1px solid #FCD34D; }
.alert-red   { background: var(--red-bg); border: 1px solid #FCA5A5; }
.alert-green { background: var(--green-bg); border: 1px solid #6EE7B7; }

/* ── Filter tabs ── */
.filter-tabs {
  display: flex;
  gap: 4px;
  border-bottom: 2px solid var(--border);
  margin-bottom: 20px;
}

.filter-tab {
  background: none;
  border: none;
  font-family: var(--font);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  padding: 10px 16px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all .15s;
}

.filter-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.filter-tab:hover:not(.active) { color: var(--text-body); }

/* ── Confidence bar ── */
.confidence-bar-wrap {
  background: var(--border);
  border-radius: 99px;
  height: 6px;
  overflow: hidden;
  margin-top: 4px;
}
.confidence-bar-fill {
  height: 100%;
  border-radius: 99px;
  transition: width .4s;
}
.conf-high   { background: var(--secondary); }
.conf-medium { background: var(--amber); }
.conf-low    { background: var(--red); }

/* ── Morning briefing card ── */
.brief-card {
  background: linear-gradient(135deg, var(--primary) 0%, #1B2D4F 100%);
  color: #fff;
  border-radius: var(--radius);
  padding: 24px 28px;
  margin-bottom: 24px;
}

.brief-greeting {
  font-size: 22px;
  font-weight: 800;
  margin-bottom: 4px;
}

.brief-date {
  font-size: 13px;
  color: rgba(255,255,255,.55);
  margin-bottom: 16px;
}

.brief-stats {
  font-size: 14px;
  color: rgba(255,255,255,.85);
  margin-bottom: 12px;
}

.brief-stat-inline {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(255,255,255,.1);
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 13px;
  font-weight: 600;
  margin-right: 8px;
  margin-bottom: 6px;
}

.brief-actions {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid rgba(255,255,255,.12);
  font-size: 13px;
  color: rgba(255,255,255,.7);
}

.brief-action-item {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 5px;
}

/* ── Demo banner ── */
.demo-banner {
  background: var(--navy-mid);
  color: rgba(255,255,255,.7);
  font-size: 11px;
  font-weight: 500;
  text-align: center;
  padding: 4px 12px;
  letter-spacing: .04em;
}

/* ── Login page ── */
.login-bg {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: linear-gradient(160deg, #0A1628 0%, #1B2D4F 50%, #0F2342 100%);
  padding: 24px;
}

.login-card {
  background: var(--white);
  border-radius: 16px;
  box-shadow: 0 24px 48px rgba(0,0,0,.25);
  padding: 40px 44px;
  width: 100%;
  max-width: 380px;
  text-align: center;
}

.login-logo-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin-bottom: 28px;
}

.login-logo-name {
  font-size: 22px;
  font-weight: 800;
  color: var(--primary);
  letter-spacing: -0.5px;
}

.login-tagline {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: -6px;
}

.login-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 6px;
}

.login-sub {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 28px;
}

.pin-input {
  font-size: 26px;
  font-weight: 700;
  text-align: center;
  letter-spacing: 8px;
  border: 2px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  width: 100%;
  font-family: var(--font);
  color: var(--primary);
  transition: border-color .15s;
  margin-bottom: 16px;
}
.pin-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(255,61,90,.12);
}

.login-error {
  font-size: 13px;
  color: var(--red);
  font-weight: 500;
  margin-bottom: 12px;
  min-height: 20px;
}

.login-demo-note {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

@keyframes shake {
  0%,100% { transform: translateX(0); }
  20%,60%  { transform: translateX(-8px); }
  40%,80%  { transform: translateX(8px); }
}
.shake { animation: shake .35s ease-in-out; }

/* ── Parsed results panel ── */
.parsed-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.parsed-row:last-child { border-bottom: none; }
.parsed-key {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-muted);
  min-width: 80px;
}
.parsed-val {
  font-weight: 600;
  color: var(--text-body);
  text-align: right;
  flex: 1;
}

/* ── Slot suggestion ── */
.slot-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 14px;
}
.slot-icon { font-size: 20px; }
.slot-main { font-weight: 700; color: var(--primary); }
.slot-sub  { font-size: 12px; color: var(--text-muted); }

/* ── WhatsApp reply box ── */
.wa-reply {
  background: #DCFCE7;
  border: 1px solid #86EFAC;
  border-radius: 10px;
  padding: 16px;
  font-size: 13px;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  line-height: 1.5;
  white-space: pre-wrap;
  color: #14532D;
  margin-top: 16px;
}

.wa-reply-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: #16A34A;
  margin-bottom: 8px;
}

/* ── Pipeline list ── */
.pipeline-list {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.pipeline-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}

.pipeline-item:last-child { border-bottom: none; }

.pipeline-time {
  font-size: 12px;
  font-weight: 700;
  color: var(--primary);
  min-width: 48px;
}

.pipeline-customer {
  font-weight: 600;
  color: var(--text-body);
  flex: 1;
}

.pipeline-route {
  font-size: 12px;
  color: var(--text-muted);
  min-width: 120px;
  text-align: right;
}

/* ── Divider ── */
.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 16px 0;
}

/* ── Summary stat tiles ── */
.stat-tiles {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}

.stat-tile {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  padding: 16px;
  text-align: center;
}

.stat-tile-num {
  font-size: 28px;
  font-weight: 800;
  line-height: 1;
  margin-bottom: 4px;
}

.stat-tile-label {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
}

/* ── Misc ── */
.text-muted { color: var(--text-muted); }
.text-green { color: var(--secondary); }
.text-red   { color: var(--red); }
.text-amber { color: var(--amber); }
.fw-700     { font-weight: 700; }
.fw-600     { font-weight: 600; }
.gap-8      { gap: 8px; }
.flex       { display: flex; }
.flex-col   { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.mb-4  { margin-bottom: 4px; }
.mb-8  { margin-bottom: 8px; }
.mb-12 { margin-bottom: 12px; }
.mb-16 { margin-bottom: 16px; }
.mb-20 { margin-bottom: 20px; }
.mb-24 { margin-bottom: 24px; }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #CBD5E1; border-radius: 99px; }

/* ── Responsive ── */
@media (max-width: 900px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .stat-tiles { grid-template-columns: repeat(2, 1fr); }
  .board-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 600px) {
  .hp-nav { display: none; }
  .page-wrap { padding: 16px; }
}
