/* FINTEL Popup Styles - Light Mode Polish */
:root {
  --card-bg: #f8f9fa;
  --card-border: rgba(0,0,0,0.06);
  --card-shadow: 0 4px 20px rgba(0,0,0,0.08);

  /* slightly stronger track for visibility */
  --track: #e2e8f0;

  --label: #6b7280;
  --text: #111827;

  --good: #4ade80;  /* green-400 */
  --warn: #fbbf24;  /* amber-400 */
  --bad:  #f87171;  /* red-400 */

  --good-tint: #dcfce7;
  --warn-tint: #fef3c7;
  --bad-tint:  #fee2e2;
}

.fintel-popup {
    position: fixed;
    width: 380px;
    background: #f7f7f9;
    border-radius: 14px;
    box-shadow:
      0 1px 2px rgba(0,0,0,.06),
      0 8px 24px rgba(0,0,0,.10);
    z-index: 1000;
    font-family: 'Inter', 'SF Pro Display', system-ui, -apple-system, sans-serif;
    font-size: 13px;
    overflow: hidden;
    border: 1px solid rgba(0,0,0,.08);
    color: var(--text);
    display: none; /* Hidden by default */
}

/* Custom Weights Active Indicator - Glowing Green Border */
.fintel-popup.custom-weights-active {
    border: 2px solid #10b981 !important;
    box-shadow: 0 0 20px rgba(16, 185, 129, 0.5),
                0 0 40px rgba(16, 185, 129, 0.3),
                0 1px 2px rgba(0,0,0,.06),
                0 8px 24px rgba(0,0,0,.10) !important;
}

/* Custom Weights Badge - Hidden by default */
.custom-weights-popup-badge {
    display: none;
    background: #10b981;
    color: white;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    margin-bottom: 12px;
    text-align: center;
    letter-spacing: 0.3px;
    box-shadow: 0 2px 6px rgba(16, 185, 129, 0.3);
}

/* Show badge only when custom weights are active */
.fintel-popup.custom-weights-active .custom-weights-popup-badge {
    display: block;
}

/* Popup Header - Clean White */
.fintel-popup .popup-header {
    background: #ffffff;
    color: var(--text);
    padding: 12px 16px;
    cursor: move;
    display: flex;
    justify-content: space-between;
    align-items: center;
    user-select: none;
    border-bottom: 2px solid var(--card-border);
}

/* Match exact styling from stats/hist */
.fintel-popup .popup-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    font-size: 14px;
}

.fintel-popup .pitcher-name {
    color: var(--text);
    text-shadow: none;
}

.fintel-popup .close-btn {
    width: 24px;
    height: 24px;
    background: rgba(0,0,0,0.06);
    border: none;
    border-radius: 50%;
    color: var(--text);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    font-size: 16px;
    line-height: 1;
}

.fintel-popup .close-btn:hover {
    background: rgba(0,0,0,0.1);
    transform: scale(1.1);
}

/* Popup Body */
.fintel-popup .popup-body {
    padding: 12px;
    color: var(--text);
    background: var(--card-bg);
    max-height: none;  /* Changed from 600px */
    overflow-y: visible;  /* Changed from auto */
}

/* FINTEL™ SCORE Label */
.fintel-score-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--label);
    opacity: 0.85;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
    text-align: center;
    font-family: 'JetBrains Mono', monospace;
}

/* Light Mode Score Bar Implementation */
.score-gradient-container {
    position: relative;
    width: 100%;
    height: 20px;
    background: var(--track);
    border-radius: 8px;
    overflow: hidden;
    margin: 8px 0;
    border: 1px solid var(--card-border);
}

.score-gradient-bar {
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    border-radius: 8px;
    transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
    border: 0;
}

/* Pastel Color System - No Glow */
.score-gradient-bar.score-red {
    background: var(--bad);
}

.score-gradient-bar.score-orange {
    background: var(--warn);
}

.score-gradient-bar.score-yellow {
    background: var(--warn);
}

.score-gradient-bar.score-green {
    background: var(--good);
}

.score-value {
    position: absolute;
    right: 8px;
    top: -28px;
    font-size: 18px;
    font-weight: 600;
    color: var(--text);
    letter-spacing: 0.3px;
}

/* Component display matching stats popup style */
.fintel-components {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 16px;
}

.component-item {
    background: #ffffff;
    border-radius: 8px;
    padding: 10px;
    border: 1px solid var(--card-border);
    transition: all 0.15s ease;
}

.component-item:hover {
    background: rgba(0,0,0,0.02);
}

.component-header {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 4px;
}

.component-icon {
    font-size: 16px;
    opacity: 0.4;
}

.component-name {
    color: var(--text);
    font-size: 12px;
    font-weight: 600;
    flex: 1;
    letter-spacing: 0.2px;
}

.component-weight {
    color: var(--label);
    font-size: 11px;
    letter-spacing: 0.3px;
    font-weight: 500;
    opacity: 0.85;
}

.component-details {
    display: flex;
    align-items: center;
    gap: 10px;
}

.component-score-bar {
    flex: 1;
    height: 16px;
    background: var(--track);
    border-radius: 8px;
    overflow: hidden;
    position: relative;
    border: 1px solid var(--card-border);
}

.component-score-fill {
    height: 100%;
    border-radius: 8px;
    transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    border: 0;
}

/* Pastel Component Colors - No Glow */
.component-score-fill.good {
    background: var(--good);
}

.component-score-fill.average {
    background: var(--warn);
}

.component-score-fill.poor {
    background: var(--bad);
}

.component-score {
    font-size: 12px;
    font-weight: 600;
    min-width: 64px;
    text-align: right;
    letter-spacing: 0.3px;
    color: var(--text);
}

.component-points {
    color: var(--text);
    font-size: 11px;
    min-width: 64px;
    text-align: right;
    opacity: 0.75;
}

/* Light Mode Weighted Total Display */
.fintel-total {
    margin-top: 12px;
    padding: 12px;
    background: #f1f5f9;
    border-radius: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border: 1px solid var(--card-border);
}

.total-label {
    color: var(--label);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 500;
}

.total-value {
    font-size: 22px;
    font-weight: 700;
    color: var(--text);
}

/* Light Mode Tinted Tier Badge */
.fintel-tier {
    margin-top: 10px;
    padding: 8px 10px;
    border-radius: 999px;
    text-align: center;
    font-weight: 700;
    font-size: 12px;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    border: 1px solid var(--card-border);
}

.tier-elite {
    background: var(--good-tint);
    color: #166534;
}

.tier-strong {
    background: var(--good-tint);
    color: #166534;
}

.tier-average {
    background: var(--warn-tint);
    color: #92400e;
}

.tier-risky {
    background: var(--warn-tint);
    color: #92400e;
}

.tier-avoid {
    background: var(--bad-tint);
    color: #7f1d1d;
}

/* Resize Handle (visual only, matching stats/hist) */
.fintel-popup .resize-handle {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 20px;
    height: 20px;
    cursor: se-resize;
    background: linear-gradient(135deg, transparent 50%, #666 50%);
    border-radius: 0 0 12px 0;
}

/* Multiple Windows - Light Tinted Headers */
.fintel-popup:nth-of-type(2) .popup-header {
    background: #ffffff;
}

.fintel-popup:nth-of-type(3) .popup-header {
    background: #ffffff;
}

.fintel-popup:nth-of-type(4) .popup-header {
    background: #ffffff;
}

.fintel-popup:nth-of-type(5) .popup-header {
    background: #ffffff;
}

/* Optional enhancement: tiny white "pills" for scores to pop on pastel bars */
.component-score.pill,
.score-value.pill {
    background: #ffffff;
    padding: 2px 6px;
    border-radius: 4px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

/* Light Mode Scrollbar styling */
.fintel-popup .popup-body::-webkit-scrollbar {
    width: 6px;
}

.fintel-popup .popup-body::-webkit-scrollbar-track {
    background: var(--track);
}

.fintel-popup .popup-body::-webkit-scrollbar-thumb {
    background: var(--label);
    border-radius: 3px;
    opacity: 0.3;
}

.fintel-popup .popup-body::-webkit-scrollbar-thumb:hover {
    opacity: 0.5;
}

/* Light Mode Loading State */
.fintel-popup .loading {
    text-align: center;
    padding: 40px;
    color: var(--label);
}

.fintel-popup .loading-spinner {
    border: 3px solid var(--track);
    border-top: 3px solid var(--good);
    border-radius: 50%;
    width: 30px;
    height: 30px;
    animation: spin 1s linear infinite;
    margin: 0 auto 10px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Light Mode Hover effects */
.fintel-popup:hover {
    box-shadow: var(--card-shadow);
}

/* Animation for popup appearance */
@keyframes popupFadeIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.fintel-popup {
    animation: popupFadeIn 0.3s ease-out;
}

/* PHASE 2 MOBILE POPUP OPTIMIZATION */
@media (max-width: 768px) {
    .fintel-popup {
        position: fixed !important;
        top: 50% !important;
        left: 50% !important;
        transform: translate(-50%, -50%) !important;
        width: 95vw !important;
        max-width: 400px !important;
        max-height: 85vh !important;
        overflow-y: auto !important;
        z-index: 10001 !important;
        margin: 0 !important;
    }
    
    /* Touch-friendly close button */
    .fintel-popup .close-btn {
        width: 44px !important;
        height: 44px !important;
        font-size: 24px !important;
        position: absolute !important;
        top: 10px !important;
        right: 10px !important;
        background: rgba(0, 0, 0, 0.1) !important;
        color: #333 !important;
        border-radius: 50% !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
    }
    
    .fintel-popup .close-btn:hover {
        background: rgba(0, 0, 0, 0.2) !important;
        transform: scale(1.05) !important;
    }
    
    /* Scrollable popup body */
    .fintel-popup .popup-body {
        max-height: calc(85vh - 80px) !important;
        overflow-y: auto !important;
        padding: 12px !important;
    }
    
    /* PRIORITY 1 & 2 FIX: Reorganize header layout for mobile */
    .fintel-popup .popup-header {
        padding: 10px 60px 10px 16px !important; /* Reduced padding */
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 2px !important;
    }
    
    .fintel-popup .popup-title {
        font-size: 16px !important;
        width: 100% !important;
        white-space: nowrap !important;
        overflow: visible !important;
        text-overflow: unset !important;
        max-width: none !important;
    }
    
    /* MOBILE-ONLY: TARGET the specific gaps BETWEEN colored sections */
    .fintel-popup .popup-body {
        padding: 8px !important; /* Keep normal outer padding */
    }
    
    /* COPY DESKTOP SPACING EXACTLY TO MOBILE */
    .fintel-components {
        gap: 8px !important; /* DESKTOP VALUE: 8px */
        margin-top: 16px !important; /* DESKTOP VALUE: 16px */
    }
    
    .component-item {
        padding: 10px !important; /* DESKTOP VALUE: 10px */
        /* Remove all margin overrides - use desktop defaults */
    }
    
    /* Keep reasonable spacing for readability inside sections */
    .component-header {
        margin-bottom: 4px !important; /* Keep header spacing */
        gap: 6px !important; /* Keep icon spacing */
    }
    
    .component-details {
        gap: 8px !important; /* Keep internal component spacing */
    }
    
    /* Minimal spacing for bottom sections */
    .fintel-total {
        margin-top: 2px !important; /* Minimal gap from last section */
        padding: 8px !important; /* Keep readable padding */
    }
    
    .fintel-tier {
        margin-top: 2px !important; /* Minimal gap from total */
        padding: 6px 8px !important; /* Keep readable padding */
    }
    
    .component-details {
        flex-direction: row !important;  /* Changed from column to row */
        gap: 8px !important;  /* Keep horizontal spacing */
        align-items: center !important;  /* Center align items */
    }
    
/* .component-score-bar {
        order: 1 !important;
    }
    
    .component-score,
    .component-points {
        order: 2 !important;
        text-align: center !important;
        min-width: auto !important;
    } */
}

/* Coors Field Warning - Park Factor 0 pts */
.component-item.coors-warning {
    background-color: rgba(244, 67, 54, 0.08) !important;
    border: 1px solid rgba(244, 67, 54, 0.2) !important;
    border-radius: 8px !important;
    padding: 12px !important;
    margin: 4px 0 !important;
    position: relative !important; /* For absolute positioning of warning icon */
}

.component-item.coors-warning .component-name,
.component-item.coors-warning .component-weight {
    color: #f44336 !important;
    font-weight: 600 !important;
}

.component-item.coors-warning .component-score,
.component-item.coors-warning .component-points {
    color: #f44336 !important;
    font-weight: 700 !important;
}

/* Warning icon - absolute positioning so it doesn't affect layout */
.warning-icon {
    position: absolute !important;
    top: 12px !important;
    right: 12px !important;
    font-size: 16px !important;
    line-height: 1 !important;
}

/* New classes for park-specific extreme colors */
.component-score-fill.excellent {
    background-color: #16a34a !important;
}

.component-score.excellent {
    color: #16a34a !important;
}

.component-score-fill.extreme-poor {
    background-color: #dc2626 !important;
}

.component-score.extreme-poor {
    color: #dc2626 !important;
}

/* History Component Disabled States and Badges */
.fintel-popup .component-disabled {
    opacity: 0.6;
    background: #f5f5f5 !important;
}

.fintel-popup .component-disabled .component-score-bar {
    background: #e0e0e0;
}

.fintel-popup .component-disabled .component-score-fill {
    background: #9e9e9e !important;
}

.fintel-popup .component-score-fill.disabled {
    background: #9e9e9e !important;
}

.fintel-popup .component-score.disabled {
    color: #757575 !important;
}

/* Badge Styles */
.fintel-popup .small-sample-badge,
.fintel-popup .no-data-badge,
.fintel-popup .poor-performance-badge,
.fintel-popup .unranked-badge {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    margin-top: 6px;
    width: 100%;
    text-align: center;
    font-weight: 500;
}

.fintel-popup .small-sample-badge {
    background: #ffc107;
    color: #333;
}

.fintel-popup .no-data-badge {
    background: #6c757d;
    color: white;
}

.fintel-popup .poor-performance-badge {
    background: #dc3545;
    color: white;
}

.fintel-popup .unranked-badge {
    background: #9e9e9e;
    color: white;
}

/* Mobile adjustments for badges */
@media (max-width: 768px) {
    .fintel-popup .small-sample-badge,
    .fintel-popup .no-data-badge,
    .fintel-popup .poor-performance-badge,
    .fintel-popup .unranked-badge {
        font-size: 10px;
        padding: 3px 6px;
    }
}
