/**
 * Brotherhood Paper - Fan-Out Prediction Tool
 * Scoped CSS - All styles prefixed with .bh-fanout-
 * Brand Colors: Navy #1B2130, Gold #D4AF37, Beige #E8E9EA, Green #6E815C
 */

/* ========================================
   CSS Variables (scoped to container)
======================================== */
.bh-fanout-container {
  --bh-navy: #1B2130;
  --bh-gold: #D4AF37;
  --bh-beige: #E8E9EA;
  --bh-green: #6E815C;
  --bh-white: #FFFFFF;
  --bh-black: #000000;
  --bh-gray-100: #F7F8F9;
  --bh-gray-200: #E5E7EB;
  --bh-gray-300: #D1D5DB;
  --bh-gray-400: #9CA3AF;
  --bh-gray-600: #4B5563;
  --bh-orange: #D97706;
  --bh-red: #DC2626;
  
  --bh-font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  --bh-radius-sm: 4px;
  --bh-radius-md: 8px;
  --bh-radius-lg: 12px;
  --bh-shadow-sm: 0 1px 2px rgba(27, 33, 48, 0.08);
  --bh-shadow-md: 0 4px 12px rgba(27, 33, 48, 0.12);
  --bh-shadow-lg: 0 8px 24px rgba(27, 33, 48, 0.16);
  --bh-transition: 0.2s ease;
}

/* ========================================
   Base Container
======================================== */
.bh-fanout-container {
  font-family: var(--bh-font-family);
  color: var(--bh-navy);
  line-height: 1.5;
  box-sizing: border-box;
  max-width: 900px;
  margin: 0 auto;
  padding: 0;
}

.bh-fanout-container *,
.bh-fanout-container *::before,
.bh-fanout-container *::after {
  box-sizing: border-box;
}

/* ========================================
   Members Only Card
======================================== */
.bh-fanout-locked {
  background: linear-gradient(135deg, var(--bh-navy) 0%, #2D3444 100%);
  border-radius: var(--bh-radius-lg);
  padding: 48px 32px;
  text-align: center;
  color: var(--bh-white);
  box-shadow: var(--bh-shadow-lg);
}

.bh-fanout-locked-icon {
  width: 64px;
  height: 64px;
  margin: 0 auto 24px;
  background: rgba(212, 175, 55, 0.15);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.bh-fanout-locked-icon svg {
  width: 32px;
  height: 32px;
  color: var(--bh-gold);
}

.bh-fanout-locked h2 {
  font-size: 24px;
  font-weight: 600;
  margin: 0 0 12px;
  color: var(--bh-white);
}

.bh-fanout-locked p {
  font-size: 16px;
  color: var(--bh-gray-300);
  margin: 0 0 24px;
}

.bh-fanout-locked-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--bh-gold);
  color: var(--bh-navy);
  font-size: 16px;
  font-weight: 600;
  padding: 12px 28px;
  border-radius: var(--bh-radius-md);
  text-decoration: none;
  transition: var(--bh-transition);
}

.bh-fanout-locked-btn:hover {
  background: #E5C04A;
  transform: translateY(-1px);
  box-shadow: var(--bh-shadow-md);
}

/* ========================================
   Calculator Card
======================================== */
.bh-fanout-card {
  background: var(--bh-white);
  border-radius: var(--bh-radius-lg);
  box-shadow: var(--bh-shadow-md);
  overflow: hidden;
}

.bh-fanout-header {
  background: linear-gradient(135deg, var(--bh-navy) 0%, #2D3444 100%);
  padding: 28px 32px;
  color: var(--bh-white);
}

.bh-fanout-header h2 {
  font-size: 22px;
  font-weight: 600;
  margin: 0 0 8px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.bh-fanout-header h2 svg {
  color: var(--bh-gold);
}

.bh-fanout-header p {
  font-size: 14px;
  color: var(--bh-gray-300);
  margin: 0;
}

.bh-fanout-body {
  padding: 32px;
}

/* ========================================
   Sections
======================================== */
.bh-fanout-section {
  margin-bottom: 28px;
  padding-bottom: 28px;
  border-bottom: 1px solid var(--bh-gray-200);
}

.bh-fanout-section:last-of-type {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: none;
}

.bh-fanout-section-title {
  font-size: 14px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--bh-gold);
  margin: 0 0 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.bh-fanout-section-title span {
  background: var(--bh-navy);
  color: var(--bh-white);
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
}

/* ========================================
   Form Grid
======================================== */
.bh-fanout-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
}

.bh-fanout-grid-3 {
  grid-template-columns: repeat(3, 1fr);
}

.bh-fanout-grid-full {
  grid-column: 1 / -1;
}

@media (max-width: 640px) {
  .bh-fanout-grid,
  .bh-fanout-grid-3 {
    grid-template-columns: 1fr;
  }
}

/* ========================================
   Form Controls
======================================== */
.bh-fanout-field {
  display: flex;
  flex-direction: column;
}

.bh-fanout-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--bh-gray-600);
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.bh-fanout-label .bh-fanout-tooltip {
  cursor: help;
  color: var(--bh-gray-400);
}

.bh-fanout-select,
.bh-fanout-input {
  width: 100%;
  height: 42px;
  padding: 0 14px;
  font-size: 14px;
  font-family: var(--bh-font-family);
  color: var(--bh-navy);
  background: var(--bh-white);
  border: 1px solid var(--bh-gray-300);
  border-radius: var(--bh-radius-sm);
  transition: var(--bh-transition);
  appearance: none;
}

.bh-fanout-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%234B5563' d='M2.5 4.5L6 8l3.5-3.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
  cursor: pointer;
}

.bh-fanout-select:focus,
.bh-fanout-input:focus {
  outline: none;
  border-color: var(--bh-gold);
  box-shadow: 0 0 0 3px rgba(212, 175, 55, 0.15);
}

.bh-fanout-select:disabled,
.bh-fanout-input:disabled {
  background: var(--bh-gray-100);
  cursor: not-allowed;
  opacity: 0.7;
}

.bh-fanout-input-group {
  display: flex;
  gap: 8px;
}

.bh-fanout-input-group .bh-fanout-input {
  flex: 1;
}

.bh-fanout-input-addon {
  display: flex;
  align-items: center;
  padding: 0 12px;
  background: var(--bh-gray-100);
  border: 1px solid var(--bh-gray-300);
  border-radius: var(--bh-radius-sm);
  font-size: 13px;
  color: var(--bh-gray-600);
}

/* ========================================
   Checkbox
======================================== */
.bh-fanout-checkbox-wrap {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  background: #FEF3C7;
  border: 1px solid #F59E0B;
  border-radius: var(--bh-radius-sm);
  cursor: pointer;
}

.bh-fanout-checkbox-wrap input {
  width: 18px;
  height: 18px;
  margin: 0;
  cursor: pointer;
  accent-color: var(--bh-gold);
}

.bh-fanout-checkbox-label {
  font-size: 13px;
  color: var(--bh-navy);
  line-height: 1.4;
}

.bh-fanout-checkbox-label strong {
  display: block;
  margin-bottom: 2px;
}

/* ========================================
   Direction Selection
======================================== */
.bh-fanout-direction-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.bh-fanout-direction-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 16px;
  background: var(--bh-gray-100);
  border: 2px solid var(--bh-gray-300);
  border-radius: var(--bh-radius-md);
  cursor: pointer;
  transition: var(--bh-transition);
  text-align: center;
}

.bh-fanout-direction-btn:hover {
  border-color: var(--bh-gold);
  background: var(--bh-white);
}

.bh-fanout-direction-btn.active {
  border-color: var(--bh-gold);
  background: rgba(212, 175, 55, 0.08);
}

.bh-fanout-direction-btn svg {
  width: 32px;
  height: 32px;
  color: var(--bh-navy);
}

.bh-fanout-direction-btn span {
  font-size: 13px;
  font-weight: 500;
  color: var(--bh-navy);
}

/* ========================================
   Calculate Button
======================================== */
.bh-fanout-calculate {
  width: 100%;
  height: 52px;
  margin-top: 24px;
  font-size: 16px;
  font-weight: 600;
  font-family: var(--bh-font-family);
  color: var(--bh-navy);
  background: var(--bh-gold);
  border: none;
  border-radius: var(--bh-radius-md);
  cursor: pointer;
  transition: var(--bh-transition);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.bh-fanout-calculate:hover {
  background: #E5C04A;
  transform: translateY(-1px);
  box-shadow: var(--bh-shadow-md);
}

.bh-fanout-calculate:active {
  transform: translateY(0);
}

.bh-fanout-calculate:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

/* ========================================
   Results Panel
======================================== */
.bh-fanout-results {
  margin-top: 32px;
  padding-top: 32px;
  border-top: 2px solid var(--bh-navy);
  display: none;
}

.bh-fanout-results.visible {
  display: block;
  animation: bh-fadeIn 0.3s ease;
}

@keyframes bh-fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.bh-fanout-results-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
}

.bh-fanout-results-header h3 {
  font-size: 18px;
  font-weight: 600;
  color: var(--bh-navy);
  margin: 0;
}

/* ========================================
   Metrics Grid
======================================== */
.bh-fanout-metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

@media (max-width: 640px) {
  .bh-fanout-metrics {
    grid-template-columns: 1fr;
  }
}

.bh-fanout-metric {
  background: var(--bh-gray-100);
  border-radius: var(--bh-radius-md);
  padding: 20px;
  text-align: center;
}

.bh-fanout-metric-label {
  font-size: 12px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--bh-gray-600);
  margin-bottom: 8px;
}

.bh-fanout-metric-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--bh-navy);
  line-height: 1.2;
}

.bh-fanout-metric-value small {
  font-size: 16px;
  font-weight: 500;
  color: var(--bh-gray-600);
}

.bh-fanout-metric-sub {
  font-size: 13px;
  color: var(--bh-gray-600);
  margin-top: 4px;
}

/* ========================================
   Risk Badge
======================================== */
.bh-fanout-risk-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.bh-fanout-risk-badge.risk-low {
  background: rgba(110, 129, 92, 0.15);
  color: var(--bh-green);
}

.bh-fanout-risk-badge.risk-medium {
  background: rgba(212, 175, 55, 0.15);
  color: #B8860B;
}

.bh-fanout-risk-badge.risk-high {
  background: rgba(217, 119, 6, 0.15);
  color: var(--bh-orange);
}

.bh-fanout-risk-badge.risk-critical {
  background: rgba(220, 38, 38, 0.15);
  color: var(--bh-red);
}

/* ========================================
   Direction Info
======================================== */
.bh-fanout-direction-info {
  background: var(--bh-beige);
  border-radius: var(--bh-radius-md);
  padding: 16px 20px;
  margin-bottom: 24px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.bh-fanout-direction-info svg {
  flex-shrink: 0;
  color: var(--bh-navy);
}

.bh-fanout-direction-info p {
  margin: 0;
  font-size: 14px;
  color: var(--bh-navy);
}

/* ========================================
   Technical Explanation
======================================== */
.bh-fanout-explanation {
  background: var(--bh-gray-100);
  border-radius: var(--bh-radius-md);
  padding: 20px;
  margin-bottom: 24px;
}

.bh-fanout-explanation h4 {
  font-size: 14px;
  font-weight: 600;
  color: var(--bh-navy);
  margin: 0 0 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.bh-fanout-explanation p {
  font-size: 13px;
  color: var(--bh-gray-600);
  margin: 0;
  line-height: 1.6;
}

/* ========================================
   Action Plan
======================================== */
.bh-fanout-actions {
  background: var(--bh-navy);
  border-radius: var(--bh-radius-md);
  padding: 24px;
  margin-bottom: 24px;
}

.bh-fanout-actions h4 {
  font-size: 15px;
  font-weight: 600;
  color: var(--bh-gold);
  margin: 0 0 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.bh-fanout-actions ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

.bh-fanout-actions li {
  position: relative;
  padding-left: 20px;
  margin-bottom: 10px;
  font-size: 14px;
  color: var(--bh-gray-200);
  line-height: 1.5;
}

.bh-fanout-actions li:last-child {
  margin-bottom: 0;
}

.bh-fanout-actions li::before {
  content: '';
  position: absolute;
  left: 0;
  top: 8px;
  width: 6px;
  height: 6px;
  background: var(--bh-gold);
  border-radius: 50%;
}

.bh-fanout-actions li.warning {
  color: #FCD34D;
}

.bh-fanout-actions li.warning::before {
  background: #FCD34D;
}

/* ========================================
   Warnings Box
======================================== */
.bh-fanout-warnings {
  background: #FEF3C7;
  border: 1px solid #F59E0B;
  border-radius: var(--bh-radius-md);
  padding: 16px 20px;
  margin-bottom: 24px;
}

.bh-fanout-warnings h4 {
  font-size: 14px;
  font-weight: 600;
  color: #92400E;
  margin: 0 0 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.bh-fanout-warnings ul {
  margin: 0;
  padding: 0 0 0 20px;
  list-style: disc;
}

.bh-fanout-warnings li {
  font-size: 13px;
  color: #92400E;
  margin-bottom: 6px;
  line-height: 1.5;
}

.bh-fanout-warnings li:last-child {
  margin-bottom: 0;
}

/* ========================================
   Input Summary Table
======================================== */
.bh-fanout-summary {
  background: var(--bh-white);
  border: 1px solid var(--bh-gray-200);
  border-radius: var(--bh-radius-md);
  overflow: hidden;
}

.bh-fanout-summary-header {
  background: var(--bh-gray-100);
  padding: 12px 16px;
  border-bottom: 1px solid var(--bh-gray-200);
}

.bh-fanout-summary-header h4 {
  font-size: 13px;
  font-weight: 600;
  color: var(--bh-navy);
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.bh-fanout-summary-table {
  width: 100%;
  border-collapse: collapse;
}

.bh-fanout-summary-table tr {
  border-bottom: 1px solid var(--bh-gray-200);
}

.bh-fanout-summary-table tr:last-child {
  border-bottom: none;
}

.bh-fanout-summary-table td {
  padding: 10px 16px;
  font-size: 13px;
}

.bh-fanout-summary-table td:first-child {
  color: var(--bh-gray-600);
  width: 45%;
}

.bh-fanout-summary-table td:last-child {
  color: var(--bh-navy);
  font-weight: 500;
}

/* ========================================
   Validation Error
======================================== */
.bh-fanout-error {
  background: #FEF2F2;
  border: 1px solid #FECACA;
  border-radius: var(--bh-radius-md);
  padding: 16px 20px;
  margin-top: 16px;
  display: none;
}

.bh-fanout-error.visible {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.bh-fanout-error svg {
  flex-shrink: 0;
  color: var(--bh-red);
}

.bh-fanout-error p {
  margin: 0;
  font-size: 14px;
  color: #B91C1C;
}

/* ========================================
   Loading State
======================================== */
.bh-fanout-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px;
}

.bh-fanout-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--bh-gray-200);
  border-top-color: var(--bh-gold);
  border-radius: 50%;
  animation: bh-spin 0.8s linear infinite;
}

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

/* ========================================
   Print Styles
======================================== */
@media print {
  .bh-fanout-container {
    max-width: 100%;
  }
  
  .bh-fanout-card {
    box-shadow: none;
    border: 1px solid #ccc;
  }
  
  .bh-fanout-calculate,
  .bh-fanout-section:not(.bh-fanout-results) {
    display: none;
  }
  
  .bh-fanout-results {
    display: block !important;
    border-top: none;
    padding-top: 0;
    margin-top: 0;
  }
}
