/* ================================================================
   Lead-Qual Agent — Design System ("Carhartt meets Stripe")
   Professional · Trustworthy · Trade-Friendly
   ================================================================ */

/* ── Fonts ────────────────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Oswald:wght@500;600;700&display=swap');

/* ── CSS Custom Properties ───────────────────────────────────── */
:root {
  /* Brand Colors */
  --lq-charcoal:       #2D2A24;
  --lq-charcoal-100:   #F0EFEC;
  --lq-charcoal-200:   #D6D3CE;
  --lq-charcoal-300:   #ABA6A0;
  --lq-charcoal-400:   #7A7570;

  --lq-orange:         #C84B1F;
  --lq-orange-hover:   #A83C14;
  --lq-orange-100:     #FDF0EA;
  --lq-orange-200:     #F5D6C8;

  --lq-amber:          #E8A020;
  --lq-amber-100:      #FEF7E6;
  --lq-amber-200:      #F5E0A8;

  --lq-green:          #3A7D44;
  --lq-green-100:      #E8F4EA;
  --lq-green-800:      #1C4A26;

  --lq-red:            #C23B22;
  --lq-red-100:        #FDE8E4;

  --lq-blue:           #2B6CB0;
  --lq-blue-100:       #E2EDF7;

  --lq-purple:         #6B46C1;

  /* Neutrals */
  --lq-warm-bg:        #F7F5F0;
  --lq-surface:        #FFFFFF;
  --lq-border:         #E2DDD6;
  --lq-text:           #1A1714;
  --lq-text-secondary: #6B6560;
  --lq-text-muted:     #9C9690;

  /* Typography */
  --lq-font-heading:   'Oswald', 'Inter', system-ui, sans-serif;
  --lq-font-body:      'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --lq-font-mono:      'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;

  /* Spacing & Effects */
  --lq-radius-sm:      4px;
  --lq-radius:         8px;
  --lq-radius-lg:      12px;
  --lq-shadow:         0 1px 3px rgba(45, 42, 36, 0.08), 0 1px 2px rgba(45, 42, 36, 0.06);
  --lq-shadow-md:      0 4px 6px rgba(45, 42, 36, 0.07), 0 2px 4px rgba(45, 42, 36, 0.06);
  --lq-shadow-lg:      0 10px 15px rgba(45, 42, 36, 0.08), 0 4px 6px rgba(45, 42, 36, 0.05);
}

/* ── Base / Reset ────────────────────────────────────────────── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  font-family: var(--lq-font-body);
  background: var(--lq-warm-bg);
  color: var(--lq-text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { color: var(--lq-orange); transition: color 0.15s ease; }
a:hover { color: var(--lq-orange-hover); }

strong { color: var(--lq-text); font-weight: 600; }

/* ── Dashboard Layout ────────────────────────────────────────── */
.dashboard-body {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ──────────────────────────────────────────────────── */
.sidebar {
  width: 240px;
  min-width: 240px;
  background: var(--lq-charcoal) !important;
  background: linear-gradient(180deg, #2D2A24 0%, #221F1A 100%) !important;
  color: var(--lq-charcoal-200);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar-brand {
  font-family: var(--lq-font-heading);
  font-weight: 600;
  font-size: 1.15rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #fff;
  padding: 1.5rem 1.25rem 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-brand small {
  display: block;
  font-family: var(--lq-font-body);
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  font-size: 0.7rem;
  color: var(--lq-charcoal-300);
  margin-top: 0.2rem;
}

.sidebar-nav {
  flex: 1;
  padding: 0.75rem 0;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.7rem 1.25rem;
  color: var(--lq-charcoal-300);
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 500;
  border-left: 3px solid transparent;
  transition: background 0.15s ease, color 0.15s ease;
}

.sidebar-nav a:hover,
.sidebar-nav a.active {
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
  border-left-color: var(--lq-amber);
}

.sidebar-nav a .nav-icon {
  width: 1.25rem;
  text-align: center;
  font-size: 1rem;
  color: var(--lq-amber);
  opacity: 0.8;
  flex-shrink: 0;
}

.sidebar-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-footer a {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  color: var(--lq-charcoal-300);
  text-decoration: none;
  font-size: 0.85rem;
  padding: 0.4rem 0;
  transition: color 0.15s ease;
}

.sidebar-footer a:hover { color: #fff; }

/* ── Main Content ────────────────────────────────────────────── */
.main-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  background: var(--lq-surface);
  padding: 0.9rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--lq-border);
  box-shadow: 0 1px 2px rgba(45, 42, 36, 0.04);
}

.topbar h2 {
  font-family: var(--lq-font-heading);
  font-weight: 500;
  font-size: 1.25rem;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--lq-charcoal);
  margin: 0;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.topbar-right .business-name {
  color: var(--lq-text-muted);
  font-weight: 500;
  font-size: 0.85rem;
}

.content {
  flex: 1;
  padding: 1.5rem 2rem;
  overflow-y: auto;
}

/* ── Cards ────────────────────────────────────────────────────── */
.card {
  background: var(--lq-surface);
  border: 1px solid var(--lq-border);
  border-radius: var(--lq-radius);
  box-shadow: var(--lq-shadow);
  padding: 1.5rem;
  margin-bottom: 1.25rem;
  transition: box-shadow 0.2s ease;
}

.card:hover {
  box-shadow: var(--lq-shadow-md);
}

.card h3 {
  font-family: var(--lq-font-heading);
  font-weight: 500;
  font-size: 1.05rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--lq-charcoal);
  margin-bottom: 1rem;
}

/* ── Tables ───────────────────────────────────────────────────── */
.table-wrap {
  overflow-x: auto;
}

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

th {
  font-family: var(--lq-font-heading);
  font-weight: 500;
  font-size: 0.78rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--lq-text-secondary);
  padding: 0.65rem 0.75rem;
  border-bottom: 2px solid var(--lq-border);
  text-align: left;
  white-space: nowrap;
}

td {
  padding: 0.65rem 0.75rem;
  font-size: 0.88rem;
  border-bottom: 1px solid var(--lq-border);
  color: var(--lq-text);
}

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

tr:hover {
  background: var(--lq-charcoal-100);
}

/* ── Badges ────────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  font-family: var(--lq-font-body);
  font-weight: 600;
  font-size: 0.7rem;
  padding: 0.2rem 0.5rem;
  border-radius: var(--lq-radius-sm);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  white-space: nowrap;
}

.badge-new          { background: var(--lq-blue-100);     color: var(--lq-blue); }
.badge-qualifying   { background: var(--lq-amber-100);   color: #8B6914; }
.badge-qualified    { background: var(--lq-green-100);   color: var(--lq-green-800); }
.badge-booked       { background: #EDE9FE;               color: var(--lq-purple); }
.badge-completed    { background: var(--lq-green-100);   color: var(--lq-green-800); }
.badge-disqualified { background: var(--lq-red-100);     color: var(--lq-red); }
.badge-spam         { background: #E8E5E0;               color: var(--lq-text-secondary); }
.badge-no_show      { background: #FCE7F3;               color: #9D174D; }

.badge-pending      { background: var(--lq-amber-100);   color: #8B6914; }
.badge-confirmed    { background: var(--lq-blue-100);    color: var(--lq-blue); }
.badge-deposit_paid { background: var(--lq-green-100);   color: var(--lq-green-800); }
.badge-cancelled    { background: var(--lq-red-100);     color: var(--lq-red); }

/* Source badges */
.badge-sms          { background: #E0F2FE; color: #075985; }
.badge-email        { background: #F3E8FF; color: #6B21A8; }
.badge-web_form     { background: var(--lq-blue-100); color: var(--lq-blue); }
.badge-facebook     { background: #E0E7FF; color: #3730A3; }
.badge-nextdoor     { background: var(--lq-amber-100); color: #8B6914; }
.badge-voice        { background: #FCE7F3; color: #9D174D; }
.badge-manual       { background: #E8E5E0; color: var(--lq-text-secondary); }

/* ── Buttons ──────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-family: var(--lq-font-body);
  font-weight: 600;
  font-size: 0.85rem;
  padding: 0.55rem 1.25rem;
  border-radius: var(--lq-radius);
  border: 1px solid transparent;
  letter-spacing: 0.01em;
  transition: all 0.15s ease;
  line-height: 1.3;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn:active {
  transform: translateY(0);
}

.btn-primary {
  background: var(--lq-orange);
  border-color: var(--lq-orange);
  color: #fff;
  box-shadow: 0 2px 6px rgba(200, 75, 31, 0.25);
}

.btn-primary:hover {
  background: var(--lq-orange-hover);
  border-color: var(--lq-orange-hover);
  box-shadow: 0 4px 10px rgba(200, 75, 31, 0.35);
}

.btn-secondary {
  background: var(--lq-surface);
  border-color: var(--lq-border);
  color: var(--lq-text);
}

.btn-secondary:hover {
  background: var(--lq-charcoal-100);
  border-color: var(--lq-charcoal-300);
}

.btn-success {
  background: var(--lq-green);
  border-color: var(--lq-green);
  color: #fff;
}

.btn-success:hover {
  background: var(--lq-green-800);
  border-color: var(--lq-green-800);
}

.btn-danger {
  background: var(--lq-red);
  border-color: var(--lq-red);
  color: #fff;
}

.btn-danger:hover {
  background: #A32E1A;
  border-color: #A32E1A;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.btn-sm {
  padding: 0.3rem 0.7rem;
  font-size: 0.78rem;
  border-radius: var(--lq-radius-sm);
}

/* ── Forms ────────────────────────────────────────────────────── */
.form-group {
  margin-bottom: 1rem;
}

.form-group label {
  display: block;
  font-family: var(--lq-font-heading);
  font-weight: 500;
  font-size: 0.8rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--lq-text-secondary);
  margin-bottom: 0.3rem;
}

.form-group input[type="text"],
.form-group input[type="email"],
.form-group input[type="password"],
.form-group input[type="number"],
.form-group input[type="tel"],
.form-group input[type="date"],
.form-group textarea,
.form-group select {
  width: 100%;
  border: 1px solid var(--lq-border);
  border-radius: var(--lq-radius);
  padding: 0.55rem 0.75rem;
  font-family: var(--lq-font-body);
  font-size: 0.9rem;
  color: var(--lq-text);
  background: var(--lq-surface);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  outline: none;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
  border-color: var(--lq-orange);
  box-shadow: 0 0 0 3px rgba(200, 75, 31, 0.15);
}

.form-group textarea {
  min-height: 80px;
  resize: vertical;
}

.form-group .help-text {
  font-size: 0.78rem;
  color: var(--lq-text-muted);
  margin-top: 0.25rem;
  line-height: 1.4;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.form-check {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.form-check label {
  font-family: var(--lq-font-body);
  font-weight: 500;
  color: var(--lq-text);
  margin-bottom: 0;
  cursor: pointer;
}

.form-check input[type="checkbox"] {
  accent-color: var(--lq-orange);
  width: 1.05rem;
  height: 1.05rem;
  cursor: pointer;
  flex-shrink: 0;
}

/* ── Flash Messages ───────────────────────────────────────────── */
.flash {
  border-radius: var(--lq-radius);
  font-family: var(--lq-font-body);
  font-weight: 500;
  font-size: 0.88rem;
  padding: 0.75rem 1rem;
  border: 1px solid transparent;
  margin-bottom: 1rem;
}

.flash-success {
  background: var(--lq-green-100);
  color: var(--lq-green-800);
  border-color: #B5D8B9;
}

.flash-error {
  background: var(--lq-red-100);
  color: var(--lq-red);
  border-color: #F5C6BC;
}

.flash-info {
  background: var(--lq-blue-100);
  color: var(--lq-blue);
  border-color: #B8D4EF;
}

/* ── Stat Grid / Stat Cards ───────────────────────────────────── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: var(--lq-surface);
  border: 1px solid var(--lq-border);
  border-radius: var(--lq-radius);
  box-shadow: var(--lq-shadow);
  padding: 1.25rem;
  text-align: center;
  transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.stat-card:hover {
  box-shadow: var(--lq-shadow-md);
  transform: translateY(-1px);
}

.stat-card .value {
  font-family: var(--lq-font-heading);
  font-weight: 600;
  font-size: 1.8rem;
  color: var(--lq-charcoal);
  line-height: 1.1;
}

.stat-card .label {
  font-family: var(--lq-font-heading);
  font-weight: 500;
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--lq-text-muted);
  margin-top: 0.15rem;
}

/* ── Detail Grid ──────────────────────────────────────────────── */
.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem 1.5rem;
}

.detail-field .label {
  font-family: var(--lq-font-heading);
  font-weight: 500;
  font-size: 0.7rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--lq-text-muted);
  margin-bottom: 0.1rem;
}

.detail-field .value {
  font-family: var(--lq-font-body);
  font-weight: 500;
  font-size: 0.95rem;
  color: var(--lq-text);
}

/* ── Chat Bubbles ─────────────────────────────────────────────── */
.chat-log {
  max-height: 400px;
  overflow-y: auto;
  padding: 0.5rem 0;
}

.chat-msg {
  display: flex;
  margin-bottom: 0.75rem;
}

.chat-msg.bot { justify-content: flex-start; }
.chat-msg.user { justify-content: flex-end; }

.chat-bubble {
  max-width: 75%;
  padding: 0.6rem 1rem;
  border-radius: var(--lq-radius-lg);
  font-size: 0.88rem;
  line-height: 1.45;
}

.chat-msg.bot .chat-bubble {
  background: var(--lq-charcoal-100);
  color: var(--lq-text);
  border-bottom-left-radius: var(--lq-radius-sm);
}

.chat-msg.user .chat-bubble {
  background: var(--lq-orange);
  color: #fff;
  border-bottom-right-radius: var(--lq-radius-sm);
}

.chat-time {
  font-size: 0.65rem;
  color: var(--lq-text-muted);
  margin-top: 0.2rem;
}

/* ── Timeline ─────────────────────────────────────────────────── */
.timeline {
  position: relative;
  padding-left: 1.5rem;
}

.timeline::before {
  content: '';
  position: absolute;
  left: 0.45rem;
  top: 0.25rem;
  bottom: 0;
  width: 2px;
  background: var(--lq-border);
}

.timeline-item {
  position: relative;
  margin-bottom: 1rem;
}

.timeline-item::before {
  content: '';
  position: absolute;
  left: -1.3rem;
  top: 0.35rem;
  width: 0.6rem;
  height: 0.6rem;
  border-radius: 50%;
  background: var(--lq-orange);
  border: 2px solid var(--lq-surface);
}

.timeline-item .tl-time {
  color: var(--lq-text-muted);
  font-size: 0.72rem;
}

.timeline-item .tl-label {
  font-family: var(--lq-font-body);
  font-weight: 500;
  color: var(--lq-text);
  font-size: 0.88rem;
}

/* ── Toggle ────────────────────────────────────────────────────── */
.toggle-wrap {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.toggle {
  position: relative;
  width: 40px;
  height: 22px;
  background: var(--lq-charcoal-300);
  border-radius: 11px;
  cursor: pointer;
  transition: background 0.2s ease;
}

.toggle.active {
  background: var(--lq-green);
}

.toggle::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s ease;
}

.toggle.active::after {
  transform: translateX(18px);
}

/* ── Service Entry Rows ───────────────────────────────────────── */
.service-entry {
  display: flex;
  gap: 0.75rem;
  align-items: flex-end;
  margin-bottom: 0.75rem;
  flex-wrap: wrap;
}

.service-entry .form-group {
  margin-bottom: 0;
}

.service-entry input {
  border: 1px solid var(--lq-border);
  border-radius: var(--lq-radius);
  font-family: var(--lq-font-body);
  font-size: 0.88rem;
  padding: 0.45rem 0.65rem;
  color: var(--lq-text);
  width: 100%;
}

/* ── Select Dropdown ──────────────────────────────────────────── */
select[name="status"] {
  border: 1px solid var(--lq-border);
  border-radius: var(--lq-radius);
  font-family: var(--lq-font-body);
  font-size: 0.85rem;
  padding: 0.4rem 0.5rem;
  color: var(--lq-text);
  background: var(--lq-surface);
}

/* ── Empty State ──────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--lq-text-muted);
}

.empty-state p {
  font-size: 1rem;
  margin-bottom: 0.3rem;
}

/* ── Login Page ───────────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--lq-charcoal);
  background: linear-gradient(135deg, #2D2A24 0%, #3D352C 50%, #2D2A24 100%);
  padding: 1rem;
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--lq-surface);
  border-radius: var(--lq-radius-lg);
  box-shadow: var(--lq-shadow-lg);
  padding: 2.5rem;
}

.login-card .login-brand {
  font-family: var(--lq-font-heading);
  font-weight: 600;
  font-size: 1.3rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--lq-charcoal);
  text-align: center;
  margin-bottom: 0.25rem;
}

.login-card .login-subtitle {
  text-align: center;
  color: var(--lq-text-muted);
  font-size: 0.85rem;
  margin-bottom: 1.75rem;
}

.login-card .login-submit {
  width: 100%;
  padding: 0.7rem;
  font-size: 0.95rem;
  justify-content: center;
}

.login-card .login-footer {
  text-align: center;
  margin-top: 1.5rem;
  font-size: 0.8rem;
  color: var(--lq-text-muted);
}

/* ── Utility ──────────────────────────────────────────────────── */
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.flex-gap { gap: 0.75rem; }
.mb-1 { margin-bottom: 0.75rem; }
.mb-2 { margin-bottom: 1.5rem; }
.mt-1 { margin-top: 0.75rem; }
.text-muted { color: var(--lq-text-muted) !important; font-size: 0.85rem; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.w-full { width: 100%; }

/* ── Scrollbar ────────────────────────────────────────────────── */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--lq-warm-bg);
}

::-webkit-scrollbar-thumb {
  background: var(--lq-charcoal-300);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--lq-charcoal-400);
}

/* ── Responsive ───────────────────────────────────────────────── */
@media (max-width: 768px) {
  /* Dashboard sidebar collapses */
  .sidebar {
    width: 60px;
    min-width: 60px;
  }

  .sidebar-brand {
    padding: 1rem 0.5rem;
    text-align: center;
    font-size: 0;
  }

  .sidebar-brand small { display: none; }

  .sidebar-nav a {
    padding: 0.7rem 0.5rem;
    justify-content: center;
  }

  .sidebar-nav a .nav-text { display: none; }

  .sidebar-footer a {
    justify-content: center;
  }

  .sidebar-footer a .nav-text { display: none; }

  .content {
    padding: 1rem;
  }

  .topbar {
    padding: 0.7rem 1rem;
  }

  .topbar h2 {
    font-size: 1rem;
  }

  .stat-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .detail-grid {
    grid-template-columns: 1fr;
  }

  .form-row {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 480px) {
  .stat-grid {
    grid-template-columns: 1fr;
  }

  .content {
    padding: 0.75rem;
  }

  .card {
    padding: 1rem;
  }

  .topbar {
    padding: 0.5rem 0.75rem;
  }

  .topbar-right .business-name {
    display: none;
  }
}
