/* Historical Stats Popup Styles - Gold/Bronze Theme */
.hist-popup {
    position: fixed;
    width: 380px;
    background: #2d2d2d;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.3);
    z-index: 1000;
    font-size: 13px;
    overflow: hidden;
    border: 1px solid #444;
}

/* Popup Header - Gold/Bronze Gradient */
.hist-popup .popup-header {
    background: linear-gradient(135deg, #B8860B 0%, #CD853F 100%);
    color: white;
    padding: 12px 16px;
    cursor: move;
    display: flex;
    justify-content: space-between;
    align-items: center;
    user-select: none;
}

.hist-popup .popup-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    font-size: 14px;
}

.hist-popup .pitcher-name {
    color: #FFE4B5; /* Moccasin color for contrast */
    text-shadow: 0 1px 2px rgba(0,0,0,0.3);
}

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

.hist-popup .close-btn:hover {
    background: rgba(255,255,255,0.3);
    transform: scale(1.1);
}

/* Popup Body */
.hist-popup .popup-body {
    padding: 16px;
    color: #e0e0e0;
    background: #2d2d2d;
}

/* VS Team Section - Primary Gold Section */
.hist-popup .vs-team-section {
    background: rgba(184, 134, 11, 0.1);
    border: 1px solid rgba(184, 134, 11, 0.3);
    border-radius: 6px;
    padding: 12px;
    margin-bottom: 16px;
}

.hist-popup .section-title {
    color: #DAA520; /* Goldenrod */
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 12px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 6px;
}

/* VS Team Stats Grid */
.hist-popup .vs-team-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 12px;
}

.hist-popup .stat-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 8px;
    background: rgba(255,255,255,0.05);
    border-radius: 4px;
}

.hist-popup .stat-label {
    color: #b0b0b0;
    font-size: 12px;
}

.hist-popup .stat-value {
    font-weight: 600;
    font-size: 13px;
    color: #fff !important;
}

/* Special styling for record */
.hist-popup .record-display {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px;
    background: rgba(255,255,255,0.08);
    border-radius: 6px;
    margin-bottom: 10px;
}

.hist-popup .record-value {
    font-size: 18px;
    font-weight: bold;
    color: #FFD700;
    margin-right: 8px;
}

.hist-popup .win-pct {
    color: #DAA520;
    font-size: 12px;
}

/* Years Active */
.hist-popup .years-active {
    text-align: center;
    padding: 4px;
    background: rgba(255,255,255,0.03);
    border-radius: 4px;
    color: #9e9e9e;
    font-size: 11px;
    margin-top: 8px;
}

/* Recent Trend */
.hist-popup .recent-trend {
    display: flex;
    justify-content: space-between;
    padding: 8px;
    background: rgba(255,255,255,0.05);
    border-radius: 4px;
    margin-top: 8px;
}

.hist-popup .trend-label {
    color: #b0b0b0;
    font-size: 11px;
}

.hist-popup .trend-value {
    font-weight: 600;
    font-size: 12px;
}

.hist-popup .trend-value.improving {
    color: #4CAF50;
}

.hist-popup .trend-value.declining {
    color: #f44336;
}

.hist-popup .trend-value.stable {
    color: #FFC107;
}

/* Career Progression Section */
.hist-popup .progression-section {
    background: rgba(205, 133, 63, 0.08);
    border: 1px solid rgba(205, 133, 63, 0.2);
    border-radius: 6px;
    padding: 10px;
    margin-bottom: 16px;
}

.hist-popup .season-table {
    width: 100%;
    font-size: 11px;
}

.hist-popup .season-table thead {
    color: #DAA520;
    border-bottom: 1px solid rgba(205, 133, 63, 0.3);
}

.hist-popup .season-table th {
    padding: 4px;
    text-align: left;
    font-weight: 600;
    font-size: 10px;
    text-transform: uppercase;
}

.hist-popup .season-table td {
    padding: 4px;
    color: #e0e0e0;
}

.hist-popup .season-table tr:hover {
    background: rgba(255,255,255,0.03);
}

/* Career Totals Section */
.hist-popup .career-section {
    background: rgba(255,255,255,0.03);
    border-radius: 6px;
    padding: 10px;
    margin-bottom: 12px;
}

.hist-popup .career-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
}

.hist-popup .career-stat {
    text-align: center;
    padding: 6px;
    background: rgba(255,255,255,0.05);
    border-radius: 4px;
}

.hist-popup .career-stat-label {
    color: #808080;
    font-size: 10px;
    margin-bottom: 2px;
    text-transform: uppercase;
}

.hist-popup .career-stat-value {
    font-size: 14px;
    font-weight: 600;
    color: #DAA520;
}

/* Best/Worst Matchups */
.hist-popup .matchups-section {
    background: rgba(184, 134, 11, 0.05);
    border-radius: 6px;
    padding: 10px;
}

.hist-popup .matchup-item {
    display: flex;
    justify-content: space-between;
    padding: 6px 8px;
    margin-bottom: 4px;
    background: rgba(255,255,255,0.03);
    border-radius: 4px;
}

.hist-popup .matchup-item.best {
    border-left: 3px solid #4CAF50;
}

.hist-popup .matchup-item.worst {
    border-left: 3px solid #f44336;
}

.hist-popup .matchup-team {
    font-weight: 600;
    color: #fff;
}

.hist-popup .matchup-stats {
    color: #b0b0b0;
    font-size: 11px;
}

/* Color coding for stats */
.hist-popup .good {
    color: #4CAF50 !important;
}

.hist-popup .average {
    color: #cfb72b !important;
}

.hist-popup .poor {
    color: #cf4c2b !important;
}

/* Loading State */
.hist-popup .loading {
    text-align: center;
    padding: 40px;
    color: #9e9e9e;
}

.hist-popup .loading-spinner {
    border: 3px solid #444;
    border-top: 3px solid #B8860B;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    animation: spin 1s linear infinite;
    margin: 0 auto 10px;
}

/* No Data State */
.hist-popup .no-data {
    text-align: center;
    padding: 30px;
    color: #808080;
    font-style: italic;
}

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

/* Multiple Windows - Different header colors */
.hist-popup:nth-of-type(2) .popup-header {
    background: linear-gradient(135deg, #CD853F 0%, #DEB887 100%);
}

.hist-popup:nth-of-type(3) .popup-header {
    background: linear-gradient(135deg, #8B7355 0%, #B8860B 100%);
}

/* Scrollbar styling for long content */
.hist-popup .popup-body {
    max-height: 500px;
    overflow-y: auto;
}

.hist-popup .popup-body::-webkit-scrollbar {
    width: 6px;
}

.hist-popup .popup-body::-webkit-scrollbar-track {
    background: rgba(0,0,0,0.1);
}

.hist-popup .popup-body::-webkit-scrollbar-thumb {
    background: rgba(184, 134, 11, 0.5);
    border-radius: 3px;
}

.hist-popup .popup-body::-webkit-scrollbar-thumb:hover {
    background: rgba(184, 134, 11, 0.7);
}

/* PHASE 2 MOBILE POPUP OPTIMIZATION */
@media (max-width: 768px) {
    .hist-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 */
    .hist-popup .close-btn {
        width: 44px !important;
        height: 44px !important;
        font-size: 24px !important;
        position: absolute !important;
        top: 10px !important;
        right: 10px !important;
        background: rgba(255, 255, 255, 0.9) !important;
        color: #333 !important;
        border-radius: 50% !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
    }
    
    .hist-popup .close-btn:hover {
        background: rgba(255, 255, 255, 1) !important;
        transform: scale(1.05) !important;
    }
    
    /* Scrollable popup body */
    .hist-popup .popup-body {
        max-height: calc(85vh - 80px) !important;
        overflow-y: auto !important;
        padding: 12px !important;
    }
    
    /* Responsive grid layouts */
    .hist-popup .vs-team-grid {
        grid-template-columns: 1fr !important;
        gap: 8px !important;
    }
    
    .hist-popup .career-grid {
        grid-template-columns: 1fr !important;
        gap: 8px !important;
    }
    
    /* PRIORITY 2 FIX: Adjust header for mobile and show full pitcher names */
    .hist-popup .popup-header {
        padding: 16px 60px 16px 16px !important; /* Extra right padding for close button */
    }
    
    .hist-popup .popup-title {
        font-size: 16px !important;
        white-space: nowrap !important;
        overflow: visible !important;
        text-overflow: unset !important;
        max-width: none !important;
    }
    
    .hist-popup .pitcher-name {
        white-space: nowrap !important;
        overflow: visible !important;
        text-overflow: unset !important;
        max-width: none !important;
    }
    
    /* Make tables more mobile-friendly */
    .hist-popup .season-table {
        font-size: 10px !important;
    }
    
    .hist-popup .season-table th,
    .hist-popup .season-table td {
        padding: 2px !important;
    }
}
