/* BrokerAI iOS-Style Design System */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
  /* iOS System Colors */
  --blue: #007AFF;
  --blue-hover: #0071E3;
  --green: #34C759;
  --orange: #FF9500;
  --red: #FF3B30;
  --purple: #AF52DE;
  --teal: #5AC8FA;
  --indigo: #5856D6;

  /* System Backgrounds */
  --bg-primary: #F2F2F7;
  --bg-card: #FFFFFF;
  --bg-secondary: #F2F2F7;
  --bg-grouped: #EFEFF4;

  /* System Grays */
  --gray-1: #8E8E93;
  --gray-2: #AEAEB2;
  --gray-3: #C7C7CC;
  --gray-4: #D1D1D6;
  --gray-5: #E5E5EA;
  --gray-6: #F2F2F7;

  /* Text */
  --text-primary: #000000;
  --text-secondary: #3C3C43;
  --text-tertiary: #8E8E93;
  --text-quaternary: #C7C7CC;

  /* Shadows (iOS layered) */
  --shadow-card: 0 0 0 1px rgba(0,0,0,0.04), 0 2px 8px rgba(0,0,0,0.04), 0 8px 24px rgba(0,0,0,0.06);
  --shadow-elevated: 0 0 0 1px rgba(0,0,0,0.05), 0 4px 16px rgba(0,0,0,0.08), 0 16px 48px rgba(0,0,0,0.10);
  --shadow-modal: 0 0 0 1px rgba(0,0,0,0.06), 0 8px 32px rgba(0,0,0,0.12), 0 32px 80px rgba(0,0,0,0.16);

  /* Border Radius */
  --radius-card: 16px;
  --radius-button: 12px;
  --radius-input: 10px;
  --radius-badge: 8px;
  --radius-pill: 100px;

  /* Frosted Glass */
  --glass-bg: rgba(255,255,255,0.72);
  --glass-border: rgba(255,255,255,0.5);
  --glass-blur: blur(20px);

  /* Transitions */
  --transition-fast: 0.15s ease;
  --transition: 0.2s ease;
  --spring: cubic-bezier(0.34, 1.56, 0.64, 1);

  /* Broker accent (overrideable) */
  --accent: var(--blue);
  --accent-hover: var(--blue-hover);
}

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

html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  scroll-behavior: smooth;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'SF Pro Display', sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.5;
  font-size: 16px;
}

/* Frosted Glass Nav */
.nav-glass {
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  background: var(--glass-bg);
  border-bottom: 1px solid var(--glass-border);
  position: sticky;
  top: 0;
  z-index: 100;
}

/* iOS Card */
.card {
  background: var(--bg-card);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}

.card-elevated {
  box-shadow: var(--shadow-elevated);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius-button);
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
  white-space: nowrap;
  user-select: none;
  -webkit-user-select: none;
}

.btn:active {
  transform: scale(0.97);
  transition: transform 0.08s ease;
}

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

.btn-primary:hover {
  background: var(--accent-hover);
  box-shadow: 0 4px 16px rgba(0, 122, 255, 0.3);
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--gray-5);
  color: var(--text-primary);
}

.btn-secondary:hover {
  background: var(--gray-4);
}

.btn-ghost {
  background: transparent;
  color: var(--accent);
}

.btn-ghost:hover {
  background: rgba(0, 122, 255, 0.08);
}

.btn-danger {
  background: var(--red);
  color: white;
}

.btn-danger:hover {
  background: #E0352B;
}

.btn-lg {
  padding: 14px 28px;
  font-size: 16px;
  border-radius: 14px;
}

.btn-sm {
  padding: 6px 14px;
  font-size: 13px;
  border-radius: 8px;
}

/* Spring animation on interactive elements */
.spring {
  transition: transform 0.4s var(--spring);
}

.spring:hover {
  transform: scale(1.02);
}

/* Inputs */
.input {
  width: 100%;
  padding: 11px 14px;
  border: 1.5px solid var(--gray-4);
  border-radius: var(--radius-input);
  font-family: inherit;
  font-size: 15px;
  color: var(--text-primary);
  background: white;
  transition: all var(--transition);
  outline: none;
}

.input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(0, 122, 255, 0.12);
}

.input::placeholder {
  color: var(--text-tertiary);
}

.input-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

/* iOS Segmented Control */
.segmented {
  display: inline-flex;
  background: var(--gray-5);
  border-radius: 10px;
  padding: 2px;
  gap: 2px;
  position: relative;
}

.segmented-item {
  padding: 6px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  color: var(--text-tertiary);
  transition: all var(--transition);
  user-select: none;
  -webkit-user-select: none;
  border: none;
  background: none;
  font-family: inherit;
}

.segmented-item.active {
  background: white;
  color: var(--text-primary);
  box-shadow: 0 1px 4px rgba(0,0,0,0.12), 0 0 0 0.5px rgba(0,0,0,0.04);
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.2px;
}

.badge-blue { background: rgba(0, 122, 255, 0.12); color: var(--blue); }
.badge-green { background: rgba(52, 199, 89, 0.12); color: #1A9640; }
.badge-orange { background: rgba(255, 149, 0, 0.12); color: #B06A00; }
.badge-red { background: rgba(255, 59, 48, 0.12); color: #C0302A; }
.badge-gray { background: var(--gray-5); color: var(--gray-1); }
.badge-purple { background: rgba(175, 82, 222, 0.12); color: #7B3DBF; }

/* Modal Sheet */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition);
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.modal-sheet {
  background: white;
  border-radius: 20px;
  box-shadow: var(--shadow-modal);
  width: 100%;
  max-width: 520px;
  transform: translateY(20px) scale(0.97);
  transition: transform 0.3s var(--spring);
  overflow: hidden;
}

.modal-overlay.open .modal-sheet {
  transform: translateY(0) scale(1);
}

.modal-drag-handle {
  width: 36px;
  height: 4px;
  background: var(--gray-4);
  border-radius: 2px;
  margin: 12px auto 0;
}

/* Toast Notification (Dynamic Island style) */
.toast-container {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}

.toast {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 12px 20px;
  border-radius: var(--radius-pill);
  font-size: 14px;
  font-weight: 600;
  color: white;
  pointer-events: auto;
  animation: toastIn 0.4s var(--spring) forwards;
  box-shadow: 0 4px 24px rgba(0,0,0,0.2);
  max-width: 380px;
}

.toast.removing {
  animation: toastOut 0.3s ease forwards;
}

.toast-success { background: #1C1C1E; }
.toast-error { background: var(--red); }
.toast-warning { background: var(--orange); }
.toast-info { background: var(--blue); }

@keyframes toastIn {
  from { opacity: 0; transform: translateY(-16px) scale(0.9); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes toastOut {
  from { opacity: 1; transform: translateY(0) scale(1); }
  to { opacity: 0; transform: translateY(-12px) scale(0.9); }
}

/* Risk Score Circle */
.risk-circle {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
}

.risk-low { background: rgba(52, 199, 89, 0.12); color: #1A9640; border: 2px solid rgba(52, 199, 89, 0.3); }
.risk-moderate { background: rgba(255, 149, 0, 0.12); color: #B06A00; border: 2px solid rgba(255, 149, 0, 0.3); }
.risk-high { background: rgba(255, 59, 48, 0.12); color: #C0302A; border: 2px solid rgba(255, 59, 48, 0.3); }

/* Table */
.table-ios {
  width: 100%;
  border-collapse: collapse;
}

.table-ios th {
  text-align: left;
  padding: 10px 16px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--gray-5);
}

.table-ios td {
  padding: 14px 16px;
  font-size: 14px;
  border-bottom: 1px solid var(--gray-6);
  vertical-align: middle;
}

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

.table-ios tbody tr {
  transition: background var(--transition-fast);
}

.table-ios tbody tr:hover {
  background: var(--bg-primary);
}

/* Sidebar */
.sidebar {
  width: 256px;
  min-height: 100vh;
  background: white;
  border-right: 1px solid var(--gray-5);
  display: flex;
  flex-direction: column;
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  z-index: 50;
  transition: width 0.25s ease;
}

.sidebar.collapsed {
  width: 64px;
}

.sidebar-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  border-radius: 10px;
  margin: 2px 8px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
}

.sidebar-item:hover {
  background: var(--bg-primary);
  color: var(--text-primary);
}

.sidebar-item.active {
  background: rgba(0, 122, 255, 0.1);
  color: var(--accent);
  font-weight: 600;
}

.sidebar-icon {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
}

/* Progress Steps */
.progress-dots {
  display: flex;
  align-items: center;
  gap: 8px;
}

.progress-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--gray-4);
  transition: all 0.3s var(--spring);
}

.progress-dot.active {
  width: 24px;
  border-radius: 4px;
  background: var(--accent);
}

.progress-dot.done {
  background: var(--green);
}

/* Stat Cards */
.stat-card {
  background: white;
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  padding: 20px;
}

.stat-value {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.5px;
  color: var(--text-primary);
}

.stat-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-tertiary);
  margin-top: 4px;
}

.stat-change {
  font-size: 12px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 6px;
  margin-top: 8px;
  display: inline-block;
}

.stat-change.up { background: rgba(52, 199, 89, 0.12); color: #1A9640; }
.stat-change.down { background: rgba(255, 59, 48, 0.12); color: #C0302A; }

/* Quote Cards */
.quote-card {
  background: white;
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  border: 2px solid transparent;
  transition: all 0.25s ease;
  cursor: pointer;
  overflow: hidden;
}

.quote-card:hover {
  box-shadow: var(--shadow-elevated);
  transform: translateY(-2px);
}

.quote-card.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(0, 122, 255, 0.12), var(--shadow-elevated);
}

.quote-card.recommended {
  border-color: var(--green);
}

/* Coverage Selection Cards */
.coverage-card {
  background: white;
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  padding: 20px;
  border: 2px solid transparent;
  cursor: pointer;
  transition: all 0.2s var(--spring);
  text-align: center;
}

.coverage-card:hover {
  box-shadow: var(--shadow-elevated);
  transform: translateY(-2px);
}

.coverage-card.selected {
  border-color: var(--accent);
  background: rgba(0, 122, 255, 0.04);
}

/* Loading Spinner */
.spinner {
  width: 20px;
  height: 20px;
  border: 2.5px solid var(--gray-4);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.spinner-lg {
  width: 40px;
  height: 40px;
  border-width: 3.5px;
}

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

/* Accordion (iOS FAQ style) */
.accordion-item {
  border-bottom: 1px solid var(--gray-5);
}

.accordion-trigger {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 0;
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  text-align: left;
}

.accordion-trigger .chevron {
  transition: transform var(--transition);
  flex-shrink: 0;
}

.accordion-item.open .accordion-trigger .chevron {
  transform: rotate(180deg);
}

.accordion-content {
  overflow: hidden;
  max-height: 0;
  transition: max-height 0.35s ease, padding 0.35s ease;
}

.accordion-item.open .accordion-content {
  max-height: 400px;
}

.accordion-body {
  padding-bottom: 18px;
  color: var(--text-secondary);
  font-size: 15px;
  line-height: 1.7;
}

/* Carrier Logo Placeholder */
.carrier-logo {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--bg-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-tertiary);
  flex-shrink: 0;
  overflow: hidden;
}

/* Score Bar */
.score-bar {
  height: 6px;
  background: var(--gray-5);
  border-radius: 3px;
  overflow: hidden;
}

.score-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.8s var(--spring);
}

/* Animated checklist */
.checklist-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--gray-6);
  animation: fadeInUp 0.4s ease forwards;
  opacity: 0;
}

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

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

/* Premium display */
.premium-amount {
  font-size: 32px;
  font-weight: 700;
  letter-spacing: -1px;
  color: var(--text-primary);
}

.premium-period {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-tertiary);
}

/* Pricing cards */
.pricing-card {
  background: white;
  border-radius: 20px;
  box-shadow: var(--shadow-card);
  padding: 32px;
  position: relative;
  transition: all 0.25s ease;
}

.pricing-card:hover {
  box-shadow: var(--shadow-elevated);
  transform: translateY(-4px);
}

.pricing-card.featured {
  background: var(--accent);
  color: white;
}

.pricing-card .popular-badge {
  position: absolute;
  top: -12px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--orange);
  color: white;
  padding: 4px 16px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.5px;
}

/* Renewal urgency colors */
.urgency-critical { color: var(--red); }
.urgency-high { color: var(--orange); }
.urgency-medium { color: #F5A623; }
.urgency-low { color: var(--green); }

/* Mobile responsive */
@media (max-width: 768px) {
  .sidebar {
    width: 100%;
    height: auto;
    min-height: unset;
    position: fixed;
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    flex-direction: row;
    border-right: none;
    border-top: 1px solid var(--gray-5);
    z-index: 100;
  }

  .modal-sheet {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    max-width: 100%;
    border-radius: 20px 20px 0 0;
    transform: translateY(100%);
  }

  .modal-overlay.open .modal-sheet {
    transform: translateY(0);
  }

  .premium-amount {
    font-size: 26px;
  }

  .stat-value {
    font-size: 24px;
  }
}

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

/* Selection */
::selection { background: rgba(0, 122, 255, 0.2); }

/* Focus ring */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Utility classes */
.text-accent { color: var(--accent); }
.text-success { color: var(--green); }
.text-danger { color: var(--red); }
.text-warning { color: var(--orange); }
.text-muted { color: var(--text-tertiary); }
.text-secondary { color: var(--text-secondary); }

.bg-accent { background: var(--accent); }
.bg-success { background: var(--green); }
.bg-danger { background: var(--red); }

.rounded-card { border-radius: var(--radius-card); }
.rounded-pill { border-radius: var(--radius-pill); }

.shadow-card { box-shadow: var(--shadow-card); }
.shadow-elevated { box-shadow: var(--shadow-elevated); }

.glass {
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
}

/* Divider */
.divider {
  height: 1px;
  background: var(--gray-5);
  margin: 16px 0;
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-tertiary);
}

.empty-state-icon {
  font-size: 48px;
  margin-bottom: 16px;
  opacity: 0.5;
}

/* Alert */
.alert {
  padding: 14px 16px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 500;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.alert-blue { background: rgba(0, 122, 255, 0.08); color: #005EC2; }
.alert-green { background: rgba(52, 199, 89, 0.08); color: #1A7A40; }
.alert-orange { background: rgba(255, 149, 0, 0.08); color: #8A5000; }
.alert-red { background: rgba(255, 59, 48, 0.08); color: #A0201A; }
