@import url('https://fonts.googleapis.com/css2?family=Manrope:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  --bg-primary: #0a0e17;
  --bg-secondary: #0f1520;
  --bg-card: #141c2b;
  --bg-card-hover: #1a2436;
  --bg-elevated: #1e2940;
  --border: rgba(255, 255, 255, 0.06);
  --border-accent: rgba(59, 130, 246, 0.2);
  --accent: #3b82f6;
  --accent-light: #60a5fa;
  --accent-dim: #2563eb;
  --accent-glow: rgba(59, 130, 246, 0.15);
  --success: #10b981;
  --success-dim: #059669;
  --warning: #f59e0b;
  --danger: #ef4444;
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --font-display: 'Manrope', sans-serif;
  --font-body: 'Manrope', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

* { box-sizing: border-box; }

body {
  font-family: var(--font-body);
  background: var(--bg-primary);
  color: var(--text-primary);
  margin: 0;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* Layout */
.app-layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 260px;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  padding: 1.5rem 0;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  overflow-y: auto;
  z-index: 40;
  transition: transform 0.3s ease;
}

.sidebar-brand {
  padding: 0 1.5rem 1.5rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1rem;
}

.sidebar-brand h1 {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.sidebar-brand span {
  color: var(--accent-light);
}

.sidebar-brand small {
  display: block;
  color: var(--text-muted);
  font-size: 0.75rem;
  margin-top: 0.25rem;
}

.sidebar-nav {
  list-style: none;
  padding: 0;
  margin: 0;
}

.sidebar-nav li a {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.625rem 1.5rem;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.9375rem;
  font-weight: 500;
  transition: all 0.2s;
  border-left: 3px solid transparent;
}

.sidebar-nav li a:hover {
  color: var(--text-primary);
  background: var(--accent-glow);
  border-left-color: var(--accent);
}

.sidebar-nav li a.active {
  color: var(--accent-light);
  background: var(--accent-glow);
  border-left-color: var(--accent);
}

.sidebar-nav li a svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.main-content {
  margin-left: 260px;
  flex: 1;
  min-height: 100vh;
}

.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 2rem;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 30;
}

.top-bar h2 {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 700;
}

.top-bar-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.content-area {
  padding: 2rem;
}

/* Cards */
.bs-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem;
  transition: all 0.25s ease;
}

.bs-card:hover {
  border-color: var(--border-accent);
  background: var(--bg-card-hover);
}

/* Stats Grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.25rem;
}

.stat-card .stat-value {
  font-size: 2rem;
  font-weight: 800;
  font-family: var(--font-display);
  color: var(--text-primary);
}

.stat-card .stat-label {
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

/* Tables */
.bs-table {
  width: 100%;
  border-collapse: collapse;
}

.bs-table thead th {
  text-align: left;
  padding: 0.75rem 1rem;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}

.bs-table tbody td {
  padding: 0.75rem 1rem;
  font-size: 0.9375rem;
  border-bottom: 1px solid var(--border);
  color: var(--text-secondary);
}

.bs-table tbody tr:hover td {
  background: var(--accent-glow);
  color: var(--text-primary);
}

/* Buttons */
/* button_to forms should be inline in flex layouts */
form.button_to { display: inline; margin: 0; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.625rem 1.25rem;
  font-weight: 600;
  font-size: 0.875rem;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
  font-family: var(--font-body);
}

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

.btn-primary:hover {
  background: var(--accent-dim);
  box-shadow: 0 4px 16px rgba(59, 130, 246, 0.3);
}

.btn-secondary {
  background: transparent;
  color: var(--text-primary);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  border-color: var(--accent);
  background: var(--accent-glow);
}

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

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

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

.btn-success:hover {
  background: var(--success-dim);
}

.btn-sm {
  padding: 0.375rem 0.75rem;
  font-size: 0.8125rem;
}

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

.form-group label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 0.375rem;
}

.form-control {
  width: 100%;
  padding: 0.625rem 0.875rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 0.9375rem;
  transition: border-color 0.2s;
}

.form-control:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.form-control::placeholder {
  color: var(--text-muted);
}

select.form-control {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%2394a3b8' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  padding-right: 2rem;
}

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

.form-check input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

textarea.form-control {
  min-height: 100px;
  resize: vertical;
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.625rem;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 6px;
}

.badge-green { background: rgba(16, 185, 129, 0.15); color: var(--success); }
.badge-blue { background: rgba(59, 130, 246, 0.15); color: var(--accent-light); }
.badge-amber { background: rgba(245, 158, 11, 0.15); color: var(--warning); }
.badge-orange { background: rgba(249, 115, 22, 0.15); color: #f97316; }
.badge-red { background: rgba(239, 68, 68, 0.15); color: var(--danger); }
.badge-gray { background: rgba(100, 116, 139, 0.15); color: var(--text-muted); }

/* Score display */
.score-ring {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  font-weight: 800;
  font-family: var(--font-display);
  position: relative;
}

.score-ring::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  padding: 4px;
  background: conic-gradient(var(--ring-color, var(--accent)) calc(var(--score, 0) * 3.6deg), var(--border) 0);
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
}

/* Score bar */
.score-bar {
  height: 8px;
  background: var(--bg-elevated);
  border-radius: 4px;
  overflow: hidden;
}

.score-bar-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.6s ease;
}

/* Flash messages */
.flash {
  padding: 0.875rem 1.25rem;
  border-radius: 8px;
  margin-bottom: 1.5rem;
  font-size: 0.9375rem;
  font-weight: 500;
}

.flash-notice {
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.2);
  color: var(--success);
}

.flash-alert {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.2);
  color: var(--danger);
}

/* Progress bar */
.progress-bar {
  width: 100%;
  height: 6px;
  background: var(--bg-elevated);
  border-radius: 3px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
  transition: width 0.3s ease;
}

/* Evaluator mobile-first checklist */
.checklist-nav {
  display: flex;
  gap: 0.5rem;
  padding: 1rem;
  overflow-x: auto;
  border-bottom: 1px solid var(--border);
  background: var(--bg-secondary);
  -webkit-overflow-scrolling: touch;
}

.checklist-nav a {
  white-space: nowrap;
  padding: 0.5rem 1rem;
  border-radius: 8px;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
  text-decoration: none;
  background: var(--bg-card);
  border: 1px solid var(--border);
  transition: all 0.2s;
}

.checklist-nav a.active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.checklist-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.25rem;
  margin-bottom: 0.75rem;
}

.checklist-item.critical {
  border-color: rgba(239, 68, 68, 0.3);
}

.checklist-item .item-code {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--accent-light);
  font-weight: 500;
}

.checklist-item .item-prompt {
  font-size: 0.9375rem;
  color: var(--text-primary);
  margin: 0.5rem 0;
  line-height: 1.5;
}

.checklist-item .item-badges {
  display: flex;
  gap: 0.375rem;
  margin-bottom: 0.75rem;
}

/* Star rating */
.star-rating {
  display: flex;
  gap: 0.25rem;
  flex-direction: row-reverse;
  justify-content: flex-end;
}

.star-rating input {
  display: none;
}

.star-rating label {
  cursor: pointer;
  font-size: 1.5rem;
  color: var(--text-muted);
  transition: color 0.15s;
}

.star-rating label:hover,
.star-rating label:hover ~ label,
.star-rating input:checked ~ label {
  color: var(--warning);
}

/* Boolean toggle */
.toggle-switch {
  display: flex;
  gap: 0.5rem;
}

.toggle-switch label {
  padding: 0.5rem 1.25rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-secondary);
  transition: all 0.2s;
}

.toggle-switch input:checked + label {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

.toggle-switch input {
  display: none;
}

/* Pagination */
.pagination {
  display: flex;
  gap: 0.25rem;
  align-items: center;
  margin-top: 1.5rem;
}

.pagination a, .pagination span {
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  font-size: 0.875rem;
  color: var(--text-secondary);
  text-decoration: none;
}

.pagination a:hover {
  background: var(--accent-glow);
  color: var(--accent-light);
}

.pagination .current {
  background: var(--accent);
  color: white;
}

/* Error messages */
.field-errors {
  color: var(--danger);
  font-size: 0.8125rem;
  margin-top: 0.25rem;
}

.error-list {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.2);
  border-radius: 8px;
  padding: 1rem;
  margin-bottom: 1.5rem;
}

.error-list h3 {
  color: var(--danger);
  font-size: 0.9375rem;
  margin-bottom: 0.5rem;
}

.error-list ul {
  list-style: disc;
  padding-left: 1.25rem;
  color: var(--danger);
  font-size: 0.875rem;
}

/* Grid layouts */
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }

/* Mobile responsive */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .main-content {
    margin-left: 0;
  }

  .content-area {
    padding: 1rem;
  }

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

  .grid-2, .grid-3 {
    grid-template-columns: 1fr;
  }

  .top-bar {
    padding: 1rem;
  }

  .bs-table {
    display: block;
    overflow-x: auto;
  }
}

/* Auth pages */
.auth-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-primary);
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 2.5rem;
}

.auth-card h1 {
  font-family: var(--font-display);
  font-size: 1.75rem;
  font-weight: 800;
  margin-bottom: 0.5rem;
}

.auth-card p {
  color: var(--text-muted);
  margin-bottom: 2rem;
  font-size: 0.9375rem;
}

/* Radar chart container */
.chart-container {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem;
}

/* Revenue opportunity card */
.opportunity-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.25rem;
}

.opportunity-card .opp-amount {
  font-size: 1.5rem;
  font-weight: 800;
  font-family: var(--font-display);
  color: var(--success);
}

/* Dropdown fix for Devise */
.field_with_errors {
  display: contents;
}
