/* ═══════════════════════════════════════════════════════════════════════════
   Business Beaker Design System
   Loaded AFTER inline <style> for cascade override.
   Matches the landing page typography, color, and interaction patterns.
   ═══════════════════════════════════════════════════════════════════════════ */

/* ─── Design Tokens ─────────────────────────────────────────────────────── */
:root {
  --bb-red:       #E8453C;
  --bb-red-dark:  #c73429;
  --bb-red-light: #ff6b5e;
  --bb-red-bg:    #fff5f4;
  --bb-red-dim:   rgba(232,69,60,0.12);
  --bb-ink:       #111111;
  --bb-ink-2:     #444444;
  --bb-ink-3:     #777777;
  --bb-ink-4:     #aaaaaa;
  --bb-line:      #e8e8e8;
  --bb-surface:   #ffffff;
  --bb-surface-2: #f8f8f8;
  --bb-dark:      #0f0f0f;
  --bb-dark-2:    #1a1a1a;

  --bb-shadow-sm:  0 1px 3px rgba(0,0,0,0.05);
  --bb-shadow-md:  0 4px 16px rgba(0,0,0,0.07);
  --bb-shadow-lg:  0 8px 28px rgba(0,0,0,0.10);
  --bb-shadow-red: 0 4px 14px rgba(232,69,60,0.25);

  --bb-radius-sm:   8px;
  --bb-radius-md:   12px;
  --bb-radius-lg:   16px;
  --bb-radius-xl:   20px;
  --bb-radius-pill: 100px;
}

/* ─── Global Smoothing ──────────────────────────────────────────────────── */
body {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

::selection {
  background: rgba(232,69,60,0.15);
  color: var(--bb-ink);
}

/* ─── Typography: Fraunces for Headings ─────────────────────────────────── */
body h1,
body h2,
body h3 {
  font-family: 'Fraunces', Georgia, serif;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

body .page-header h1,
body .page-title {
  font-family: 'Fraunces', Georgia, serif;
  font-size: 1.75rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

body .card-title,
body .section-header h3 {
  font-family: 'Fraunces', Georgia, serif;
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

body .welcome-card h2 {
  font-family: 'Fraunces', Georgia, serif;
  font-size: 1.5rem;
  font-weight: 600;
}

body .stat-value {
  font-family: 'Fraunces', Georgia, serif;
  font-size: 2.2rem;
  font-weight: 600;
  letter-spacing: -0.03em;
}

body .score-value {
  font-family: 'Fraunces', Georgia, serif;
}

body .plan-price,
body .tw-price,
body .upgrade-plan .plan-price {
  font-family: 'Fraunces', Georgia, serif;
  letter-spacing: -0.02em;
}

/* ─── Section Labels (landing page pattern) ─────────────────────────────── */
body .nav-section-label,
body .nav-section-title {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--bb-ink-4);
}

/* ─── Card Enhancements ─────────────────────────────────────────────────── */
body .card,
body .stat-card,
body .practice-card,
body .checklist-card,
body .welcome-card,
body .score-card,
body .blueprint-card {
  border-radius: var(--bb-radius-lg);
  border-color: var(--bb-line);
  transition: border-color 0.25s ease, box-shadow 0.25s ease, transform 0.25s ease;
}

body .card:hover,
body .practice-card:hover,
body .blueprint-card:hover {
  border-color: rgba(232,69,60,0.25);
  box-shadow: var(--bb-shadow-md);
}

/* Stat cards — red top accent on hover */
body .stat-card {
  border-radius: var(--bb-radius-lg);
  position: relative;
  overflow: hidden;
  transition: border-color 0.25s ease, box-shadow 0.25s ease, transform 0.25s ease;
}

body .stat-card::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--bb-red), var(--bb-red-light));
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.35s ease;
}

body .stat-card:hover {
  border-color: rgba(232,69,60,0.25);
  box-shadow: var(--bb-shadow-md);
  transform: translateY(-2px);
}

body .stat-card:hover::after {
  transform: scaleX(1);
}

/* Welcome card — premium border */
body .welcome-card {
  border-width: 2px;
  border-radius: var(--bb-radius-xl);
}

/* Tier chips — pill style */
body .tier-chip {
  border-radius: var(--bb-radius-md);
  transition: all 0.2s ease;
}

body .tier-chip:hover {
  border-color: var(--bb-red);
  background: var(--bb-red-bg);
}

/* Resource items */
body .resource-item {
  border-radius: var(--bb-radius-md);
  transition: all 0.2s ease;
}

body .resource-item:hover {
  border-color: var(--bb-red);
  box-shadow: var(--bb-shadow-sm);
  transform: translateY(-1px);
}

/* ─── Button Enhancements ───────────────────────────────────────────────── */
body .btn-primary,
body .next-step-btn.primary,
body .upgrade-btn:not(.outline),
body .pricing-btn.solid,
body .chat-send,
body .trial-wall-cta {
  border-radius: 10px;
  font-weight: 600;
  transition: all 0.2s ease;
  box-shadow: 0 2px 8px rgba(232,69,60,0.15);
}

body .btn-primary:hover,
body .next-step-btn.primary:hover,
body .upgrade-btn:not(.outline):hover,
body .pricing-btn.solid:hover,
body .chat-send:hover:not(:disabled),
body .trial-wall-cta:hover {
  box-shadow: var(--bb-shadow-red);
  transform: translateY(-1px);
}

body .btn-secondary,
body .next-step-btn.secondary,
body .pricing-btn.outline {
  border-radius: 10px;
  transition: all 0.2s ease;
}

body .btn-secondary:hover,
body .next-step-btn.secondary:hover,
body .pricing-btn.outline:hover {
  border-color: var(--bb-red);
  color: var(--bb-red);
  background: var(--bb-red-bg);
}

/* Edit links — landing page underline style */
body .edit-link {
  font-weight: 600;
  transition: color 0.18s ease;
}

body .edit-link:hover {
  color: var(--bb-red-dark);
}

/* ─── Sidebar Enhancements ──────────────────────────────────────────────── */
body .sidebar {
  border-right-color: var(--bb-line);
}

body .sidebar-logo,
body .sidebar .logo {
  letter-spacing: -0.02em;
}

body .nav-item,
body .sidebar-link,
body .nav-link {
  border-radius: var(--bb-radius-sm);
  transition: all 0.18s ease;
}

body .nav-item.active,
body .sidebar-link.active,
body .nav-link.active {
  background: var(--bb-red-bg);
  color: var(--bb-red);
  font-weight: 600;
}

body .nav-item:hover:not(.active),
body .sidebar-link:hover:not(.active),
body .nav-link:hover:not(.active) {
  background: var(--bb-surface-2);
  color: var(--bb-ink);
}

/* Sidebar footer coach info */
body .coach-info {
  border-radius: var(--bb-radius-sm);
  transition: background 0.18s ease;
}

body .coach-avatar {
  background: var(--bb-red);
  font-weight: 700;
}

/* ─── Form Enhancements ─────────────────────────────────────────────────── */
body .form-input,
body .form-textarea,
body .chat-input,
body select.form-input,
body input[type="text"],
body input[type="email"],
body input[type="password"],
body input[type="number"],
body textarea {
  border-radius: 10px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

body .form-input:focus,
body .form-textarea:focus,
body .chat-input:focus,
body select.form-input:focus,
body input[type="text"]:focus,
body input[type="email"]:focus,
body input[type="password"]:focus,
body textarea:focus {
  border-color: var(--bb-red);
  box-shadow: 0 0 0 3px rgba(232,69,60,0.08);
  outline: none;
}

/* Toggle switch — ensure red active */
body .toggle input:checked + .toggle-slider {
  background: var(--bb-red);
}

/* ─── Table Enhancements ────────────────────────────────────────────────── */
body table th {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--bb-ink-3);
}

body table tbody tr {
  transition: background 0.15s ease;
}

body table tbody tr:hover {
  background: var(--bb-surface-2);
}

/* ─── Tab Enhancements ──────────────────────────────────────────────────── */
body .tab {
  transition: all 0.18s ease;
}

body .tab.active {
  color: var(--bb-red);
  border-bottom-color: var(--bb-red);
  font-weight: 600;
}

body .tab:hover:not(.active) {
  color: var(--bb-ink);
}

/* ─── Badge Enhancements ────────────────────────────────────────────────── */
body .ai-badge {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border-radius: var(--bb-radius-pill);
  font-weight: 700;
}

body .trial-day-badge,
body .checklist-completion {
  border-radius: var(--bb-radius-pill);
}

/* ─── Toast Enhancement ─────────────────────────────────────────────────── */
body .toast {
  border-radius: var(--bb-radius-md);
  font-weight: 600;
  box-shadow: var(--bb-shadow-lg);
}

/* ─── Checklist Enhancement ─────────────────────────────────────────────── */
body .checklist-item {
  border-radius: var(--bb-radius-sm);
  transition: background 0.15s ease;
}

body .checklist-item:not(.done):hover {
  background: var(--bb-red-bg);
}

body .checklist-item.done .check-box {
  background: #22c55e;
  border-color: #22c55e;
  color: white;
}

/* ─── Trial Banner Enhancement ──────────────────────────────────────────── */
body .trial-banner {
  border-radius: var(--bb-radius-lg);
}

body .trial-progress-fill {
  border-radius: var(--bb-radius-pill);
  transition: width 0.5s ease;
}

/* ─── Trial Wall Enhancement ────────────────────────────────────────────── */
body .trial-wall-inner {
  border-radius: var(--bb-radius-xl);
  box-shadow: var(--bb-shadow-lg);
}

body .trial-wall-plan {
  border-radius: var(--bb-radius-lg);
  transition: all 0.2s ease;
}

body .trial-wall-plan:hover {
  border-color: var(--bb-red);
  transform: translateY(-2px);
  box-shadow: var(--bb-shadow-md);
}

body .trial-wall-plan.featured {
  border-color: var(--bb-red);
  background: var(--bb-red-bg);
}

/* ─── Upgrade CTA Enhancement ───────────────────────────────────────────── */
body .upgrade-plan {
  border-radius: var(--bb-radius-md);
  transition: all 0.2s ease;
}

body .upgrade-plan:hover {
  transform: translateY(-1px);
}

/* ─── Chat Enhancement ──────────────────────────────────────────────────── */
body .message {
  border-radius: var(--bb-radius-lg);
}

body .message.user {
  background: var(--bb-red);
  border-bottom-right-radius: 4px;
}

body .message.assistant {
  border-bottom-left-radius: 4px;
}

body .chat-input-wrap {
  border-top-color: var(--bb-line);
}

/* ─── Subtle Page Load Animations ───────────────────────────────────────── */
@keyframes bb-fade-up {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

body .page-header {
  animation: bb-fade-up 0.45s ease both;
}

body .stat-card,
body .card,
body .practice-card,
body .welcome-card,
body .checklist-card,
body .trial-banner,
body .score-card {
  animation: bb-fade-up 0.45s ease both;
}

body .stat-card:nth-child(1),
body .card:nth-child(1) { animation-delay: 0.06s; }
body .stat-card:nth-child(2),
body .card:nth-child(2) { animation-delay: 0.12s; }
body .stat-card:nth-child(3),
body .card:nth-child(3) { animation-delay: 0.18s; }
body .stat-card:nth-child(4),
body .card:nth-child(4) { animation-delay: 0.24s; }

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

body ::-webkit-scrollbar-track {
  background: transparent;
}

body ::-webkit-scrollbar-thumb {
  background: var(--bb-line);
  border-radius: 3px;
}

body ::-webkit-scrollbar-thumb:hover {
  background: var(--bb-ink-4);
}

/* ─── Focus Visible ─────────────────────────────────────────────────────── */
body :focus-visible {
  outline: 2px solid var(--bb-red);
  outline-offset: 2px;
}

/* ─── Topbar Enhancements (Client pages) ────────────────────────────────── */
body .topbar {
  border-bottom-color: var(--bb-line);
  backdrop-filter: blur(12px);
  background: rgba(255,255,255,0.96);
}

body .topbar-logo {
  font-weight: 700;
  letter-spacing: -0.02em;
}

/* ─── Knowledge Items ───────────────────────────────────────────────────── */
body .knowledge-item {
  transition: background 0.15s ease;
  padding: 14px 0;
}

body .knowledge-item:hover {
  background: var(--bb-surface-2);
}

/* ─── Pipeline/Kanban Enhancements ──────────────────────────────────────── */
body .pipeline-card,
body .deal-card,
body .outreach-card,
body .campaign-card {
  border-radius: var(--bb-radius-md);
  transition: all 0.2s ease;
}

body .pipeline-card:hover,
body .deal-card:hover {
  box-shadow: var(--bb-shadow-md);
  transform: translateY(-2px);
}

/* ─── Mobile Enhancements ───────────────────────────────────────────────── */
@media (max-width: 640px) {
  body .page-header h1,
  body .page-title {
    font-size: 1.4rem;
  }

  body .stat-value {
    font-size: 1.7rem;
  }

  body .card-title,
  body .section-header h3 {
    font-size: 1rem;
  }

  /* Better mobile sidebar drawer */
  body .sidebar.mobile-open {
    box-shadow: 4px 0 32px rgba(0,0,0,0.2);
  }

  /* Better mobile card radii */
  body .stat-card,
  body .card,
  body .practice-card,
  body .checklist-card {
    border-radius: var(--bb-radius-md);
  }

  /* Mobile header polish */
  body .mobile-header {
    border-bottom-color: var(--bb-line);
    backdrop-filter: blur(12px);
    background: rgba(255,255,255,0.96);
  }

  body .mobile-logo-link img {
    height: 24px;
    width: auto;
  }

  /* Client topbar nav — tighter on mobile */
  body .topbar {
    height: 52px;
    padding: 0 12px;
  }

  body .topbar-nav {
    gap: 2px;
  }

  body .nav-link {
    font-size: 0.78rem;
    padding: 5px 8px;
    border-radius: 6px;
  }

  body .topbar-right {
    gap: 6px;
  }

  body .user-name {
    font-size: 0.78rem;
    max-width: 80px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  /* Better mobile form fields */
  body .form-input,
  body .form-textarea,
  body .chat-input,
  body input[type="text"],
  body input[type="email"],
  body input[type="password"] {
    font-size: 16px; /* Prevents iOS zoom */
  }

  /* Mobile chat */
  body .chat-messages {
    padding: 16px;
  }

  body .message {
    max-width: 90%;
  }

  /* Mobile main content padding */
  body .main {
    padding: 20px 16px;
  }

  /* Mobile blueprints */
  body .blueprints-view {
    padding: 16px;
  }

  /* Mobile sidebar full-height nav */
  body .sidebar-overlay.open {
    backdrop-filter: blur(4px);
  }
}

@media (max-width: 900px) {
  /* Tablet: main-layout stack */
  body .main-layout {
    flex-direction: column;
  }

  body .main-layout > .sidebar {
    width: 100%;
    height: auto;
    position: relative;
    border-right: none;
    border-bottom: 1px solid var(--bb-line);
  }

  body .main-layout > .sidebar .sidebar-nav {
    flex-direction: row;
    overflow-x: auto;
    gap: 4px;
    padding: 12px;
  }
}

/* ─── Print Styles ──────────────────────────────────────────────────────── */
@media print {
  body .sidebar,
  body .mobile-header,
  body .topbar,
  body .trial-banner,
  body .upgrade-cta,
  body .trial-wall {
    display: none !important;
  }

  body .main {
    margin-left: 0 !important;
    padding: 0 !important;
  }
}
