/**
 * Output Page Professional Styling
 * Following patterns from Bloomberg Terminal, Moody's Analytics, and S&P Capital IQ
 * for professional, data-dense financial tools
 */

/* ===================================================
   1. TOTAL CREDIT SPREAD - PROMINENT DISPLAY
   =================================================== */

.total-credit-spread {
    /* Changed from light green to bold white on gradient green background */
    background: linear-gradient(135deg, #1a7f46 0%, #2d9960 50%, #1a7f46 100%);
    color: #ffffff;
    font-weight: 900;
    font-size: 2rem;
    padding: 30px 40px;
    text-align: center;
    border-radius: 12px;
    margin: 20px 0;
    /* Added shadow effects for emphasis */
    box-shadow: 0 8px 24px rgba(26, 127, 70, 0.35),
                0 4px 12px rgba(0, 0, 0, 0.15);
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    letter-spacing: 0.5px;
    position: relative;
    overflow: hidden;
}

.total-credit-spread::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(
        45deg,
        transparent 30%,
        rgba(255, 255, 255, 0.1) 50%,
        transparent 70%
    );
    animation: shimmer 3s infinite;
}

@keyframes shimmer {
    0% { transform: translateX(-100%) translateY(-100%) rotate(45deg); }
    100% { transform: translateX(100%) translateY(100%) rotate(45deg); }
}

.total-credit-spread .label {
    font-size: 0.9rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    opacity: 0.95;
    margin-bottom: 8px;
    display: block;
}

.total-credit-spread .value {
    font-size: 3.5rem;
    font-weight: 900;
    line-height: 1;
    position: relative;
    z-index: 1;
}

.total-credit-spread .bps {
    font-size: 1.2rem;
    font-weight: 700;
    opacity: 0.9;
    margin-top: 8px;
    display: block;
}

/* ===================================================
   2. SECTION HEADERS - TWO-TONE GRADIENT
   =================================================== */

.section-header {
    /* Two-tone green gradient matching landing page */
    background: linear-gradient(90deg, #0f4d2e 0%, #1a7f46 50%, #2d9960 100%);
    color: #ffffff;
    text-align: center;
    padding: 18px 24px;
    font-size: 1.5rem;
    font-weight: 800;
    border-radius: 8px;
    margin: 32px 0 20px 0;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    box-shadow: 0 4px 12px rgba(15, 77, 46, 0.25);
    position: relative;
}

.section-header::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 80%;
    height: 3px;
    background: linear-gradient(90deg, transparent, #ffffff, transparent);
    opacity: 0.3;
}

/* ===================================================
   3. FINANCIAL METRICS GRID
   =================================================== */

.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 18px;
    padding: 24px 0;
    margin-bottom: 20px;
}

.metric-card {
    background: #ffffff;
    border: 1px solid #e1efe6;
    border-radius: 10px;
    padding: 20px;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.metric-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: currentColor;
    opacity: 0.6;
}

.metric-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.12);
    border-color: currentColor;
}

.metric-label {
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #666;
    margin-bottom: 8px;
}

.metric-value {
    font-size: 2rem;
    font-weight: 800;
    /* Tabular numbers for consistency */
    font-variant-numeric: tabular-nums;
    line-height: 1.2;
    margin-bottom: 4px;
}

.metric-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 16px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 8px;
}

/* Color-coded bands */
.metric-card.excellent {
    color: #0f6a38;
    background: linear-gradient(135deg, #f0fff4 0%, #dcfce7 100%);
}

.metric-card.excellent .metric-badge {
    background: #0f6a38;
    color: #ffffff;
}

.metric-card.strong {
    color: #15803d;
    background: linear-gradient(135deg, #f7fee7 0%, #ecfccb 100%);
}

.metric-card.strong .metric-badge {
    background: #15803d;
    color: #ffffff;
}

.metric-card.satisfactory {
    color: #ca8a04;
    background: linear-gradient(135deg, #fefce8 0%, #fef9c3 100%);
}

.metric-card.satisfactory .metric-badge {
    background: #ca8a04;
    color: #ffffff;
}

.metric-card.fair {
    color: #ea580c;
    background: linear-gradient(135deg, #fff7ed 0%, #fed7aa 100%);
}

.metric-card.fair .metric-badge {
    background: #ea580c;
    color: #ffffff;
}

.metric-card.weak {
    color: #dc2626;
    background: linear-gradient(135deg, #fef2f2 0%, #fecaca 100%);
}

.metric-card.weak .metric-badge {
    background: #dc2626;
    color: #ffffff;
}

.metric-card.vulnerable {
    color: #991b1b;
    background: linear-gradient(135deg, #fef2f2 0%, #fee2e2 100%);
}

.metric-card.vulnerable .metric-badge {
    background: #991b1b;
    color: #ffffff;
}

/* Disclosed-but-not-calculated metrics (neutral, no band) */
.metric-card.suppressed {
    color: #64748b;
    background: #f8fafc;
    border-style: dashed;
}

.metric-card.suppressed .metric-value {
    font-size: 1.1rem;
    font-weight: 700;
    color: #64748b;
}

.metric-card.suppressed .metric-reason {
    font-size: 0.85rem;
    color: #64748b;
    margin-bottom: 4px;
}

.metric-card.suppressed .metric-badge {
    background: #e2e8f0;
    color: #475569;
}

/* ===================================================
   4. KEY DRIVERS SECTION
   =================================================== */

.key-drivers-section {
    margin: 32px 0;
}

.key-drivers-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    margin-top: 20px;
}

.drivers-column {
    background: #ffffff;
    border: 2px solid #e1efe6;
    border-radius: 12px;
    padding: 24px;
}

.drivers-column.positives {
    border-color: #1a7f46;
    background: linear-gradient(135deg, #f0fff4 0%, #ffffff 100%);
}

.drivers-column.risks {
    border-color: #ea580c;
    background: linear-gradient(135deg, #fff7ed 0%, #ffffff 100%);
}

.drivers-column h3 {
    font-size: 1.2rem;
    font-weight: 800;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 2px solid currentColor;
}

.drivers-column.positives h3 {
    color: #1a7f46;
}

.drivers-column.risks h3 {
    color: #ea580c;
}

.driver-item {
    display: flex;
    align-items: flex-start;
    margin-bottom: 16px;
    padding: 12px;
    background: #ffffff;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.driver-item:hover {
    transform: translateX(4px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.driver-icon {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 900;
    font-size: 1.1rem;
    margin-right: 12px;
}

.drivers-column.positives .driver-icon {
    background: #1a7f46;
    color: #ffffff;
}

.drivers-column.risks .driver-icon {
    background: #ea580c;
    color: #ffffff;
}

.driver-text {
    flex: 1;
    font-size: 0.95rem;
    line-height: 1.6;
    color: #374151;
}

.overall-assessment {
    margin-top: 24px;
    padding: 20px;
    background: linear-gradient(135deg, #eef8f1 0%, #f7fbf8 100%);
    border: 2px solid #1a7f46;
    border-radius: 12px;
}

.overall-assessment h4 {
    font-size: 1rem;
    font-weight: 800;
    color: #0f4d2e;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.overall-assessment p {
    font-size: 0.95rem;
    line-height: 1.6;
    color: #374151;
    margin: 0;
}

/* ===================================================
   5. INPUT SUMMARY - COLLAPSIBLE ACCORDION
   =================================================== */

.input-summary-section {
    margin: 32px 0;
}

.accordion {
    border: 1px solid #e1efe6;
    border-radius: 12px;
    overflow: hidden;
    background: #ffffff;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.accordion-header {
    background: linear-gradient(90deg, #f7fbf8 0%, #eef8f1 100%);
    padding: 18px 24px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.3s ease;
    border-bottom: 1px solid #e1efe6;
}

.accordion-header:hover {
    background: linear-gradient(90deg, #eef8f1 0%, #dcf0e3 100%);
}

.accordion-header.active {
    background: linear-gradient(90deg, #1a7f46 0%, #2d9960 100%);
    color: #ffffff;
}

.accordion-title {
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: 0.3px;
}

.accordion-toggle {
    font-size: 1.5rem;
    font-weight: 700;
    transition: transform 0.3s ease;
}

.accordion-header.active .accordion-toggle {
    transform: rotate(180deg);
}

.accordion-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.4s ease-out, padding 0.4s ease-out;
    padding: 0 24px;
}

.accordion-content.active {
    max-height: 2000px;
    padding: 24px;
}

.inputs-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 16px;
}

.input-item {
    display: flex;
    flex-direction: column;
    padding: 12px;
    background: #f7fbf8;
    border-radius: 8px;
    border-left: 3px solid #1a7f46;
}

.input-label {
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #666;
    margin-bottom: 4px;
}

.input-value {
    font-size: 1rem;
    font-weight: 700;
    color: #123c26;
    font-variant-numeric: tabular-nums;
}

/* ===================================================
   6. MOBILE RESPONSIVE
   =================================================== */

@media (max-width: 768px) {
    /* Total Credit Spread */
    .total-credit-spread {
        padding: 20px 24px;
        font-size: 1.5rem;
    }
    
    .total-credit-spread .value {
        font-size: 2.5rem;
    }
    
    /* Section Headers */
    .section-header {
        font-size: 1.2rem;
        padding: 14px 18px;
    }
    
    /* Metrics Grid - Single Column */
    .metrics-grid {
        grid-template-columns: 1fr;
        gap: 14px;
        padding: 16px 0;
    }
    
    .metric-value {
        font-size: 1.75rem;
    }
    
    /* Key Drivers - Single Column */
    .key-drivers-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }
    
    .drivers-column {
        padding: 18px;
    }
    
    .driver-item {
        padding: 10px;
    }
    
    /* Inputs Grid - Single Column */
    .inputs-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    
    /* Accordion */
    .accordion-header {
        padding: 14px 18px;
    }
    
    .accordion-title {
        font-size: 1rem;
    }
    
    .accordion-content.active {
        padding: 18px;
    }
}

@media (max-width: 480px) {
    .total-credit-spread {
        padding: 16px 20px;
    }
    
    .total-credit-spread .value {
        font-size: 2rem;
    }
    
    .section-header {
        font-size: 1rem;
        padding: 12px 16px;
    }
    
    .metric-card {
        padding: 16px;
    }
    
    .drivers-column {
        padding: 14px;
    }
}

/* ===================================================
   7. UTILITY CLASSES
   =================================================== */

.text-tabular {
    font-variant-numeric: tabular-nums;
}

.shadow-professional {
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12),
                0 4px 12px rgba(0, 0, 0, 0.08);
}

.gradient-green {
    background: linear-gradient(135deg, #1a7f46 0%, #2d9960 100%);
}

.border-professional {
    border: 1px solid #e1efe6;
    border-radius: 8px;
}

/* ===================================================
   8. ANIMATIONS
   =================================================== */

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

.fade-in {
    animation: fadeIn 0.4s ease-out;
}

@keyframes slideDown {
    from {
        opacity: 0;
        max-height: 0;
    }
    to {
        opacity: 1;
        max-height: 2000px;
    }
}

/* ===================================================
   9. PROFESSIONAL TYPOGRAPHY
   =================================================== */

.professional-heading {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-weight: 800;
    letter-spacing: -0.02em;
    line-height: 1.2;
}

.professional-body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-size: 0.95rem;
    line-height: 1.6;
    color: #374151;
}

.professional-mono {
    font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, 'Courier New', monospace;
    font-variant-numeric: tabular-nums;
}

/* ===================================================
   10. PRINT STYLES
   =================================================== */

@media print {
    .total-credit-spread {
        background: #1a7f46;
        color: #ffffff;
        box-shadow: none;
        page-break-inside: avoid;
    }
    
    .section-header {
        background: #1a7f46;
        color: #ffffff;
        box-shadow: none;
        page-break-after: avoid;
    }
    
    .metric-card,
    .drivers-column,
    .overall-assessment {
        page-break-inside: avoid;
        box-shadow: none;
    }
    
    .accordion-content {
        max-height: none !important;
        padding: 24px !important;
    }
    
    .accordion-toggle {
        display: none;
    }
}

/* ===================================================
   11. MOBILE FIXES - ISSUES 3 & 4 (OBR Result Page)
   =================================================== */

@media (max-width: 768px) {
  /* Issue 3: Fix OBR mega number overflow */
  .obr-hero-result .obr-mega-number {
    font-size: 3rem;
  }
  
  .obr-hero-result .obr-range {
    font-size: 0.95rem;
  }
  
  .obr-hero-result .obr-super-card {
    padding: 24px 16px;
  }
  
  .component-pills {
    flex-direction: column;
    gap: 8px;
  }
  
  .pill-item {
    min-width: auto;
    width: 100%;
  }
  
  /* Issue 4: Fix content width overflow */
  .result-container {
    padding: 0;
    margin: 0;
  }
  
  .result-grid {
    width: 100%;
    max-width: 100vw;
    padding: 0 12px;
    gap: 16px;
    margin: 16px 0 40px;
  }
  
  .card {
    width: 100%;
    max-width: calc(100vw - 24px);
    margin: 0 auto;
  }
  
  .card__body {
    padding: 12px;
    overflow-x: auto;
  }
  
  /* Financial metrics grid to single column */
  .metrics-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  
  .metric-card {
    width: 100%;
  }
  
  /* Company info box mobile fix */
  section.container {
    padding: 0 12px;
    max-width: 100vw;
  }
  
  /* KV grid to vertical stack */
  .kv {
    grid-template-columns: 1fr;
    gap: 8px;
  }
  
  .kv div:nth-child(odd) {
    font-weight: 600;
  }
  
  /* PV calculation panels */
  .pv-inputs-grid {
    grid-template-columns: 1fr;
  }
  
  .pv-hero-card {
    padding: 24px 16px;
  }
  
  .pv-value {
    font-size: 2.5rem;
  }
  
  /* Prevent table overflow */
  .iteration-table-wrapper,
  .sensitivity-table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  
  .iteration-table,
  .sensitivity-table {
    min-width: 100%;
    font-size: 0.8rem;
  }
  
  .iteration-table th,
  .iteration-table td,
  .sensitivity-table th,
  .sensitivity-table td {
    padding: 8px 6px;
    white-space: nowrap;
  }
}
