/* Stats Popup Styles */
.stats-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 */
.popup-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 12px 16px;
    cursor: move;
    display: flex;
    justify-content: space-between;
    align-items: center;
    user-select: none;
}

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

.pitcher-name {
    color: #ffd700;
}

.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;
}

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

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

/* Primary L30 Section */
.primary-section {
    background: rgba(33, 150, 243, 0.1);
    border: 1px solid rgba(33, 150, 243, 0.3);
    border-radius: 6px;
    padding: 12px;
    margin-bottom: 16px;
}

.primary-section > div {
    margin-left: -5.35px;  /* Shift everything slightly left */
}

.primary-title {
    color: #64B5F6;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 12px;
    font-weight: 600;
}

/* Velocity Display */
.velocity-display {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
    padding: 8px;
    background: rgba(255,255,255,0.05);
    border-radius: 6px;
    width: 100%;           /* Add this */
    box-sizing: border-box; /* Add this */
}

.velo-icon {
    font-size: 24px;
}

.velo-value {
    font-size: 20px;
    font-weight: bold;
    color: #fff;
}

.velo-label {
    color: #9e9e9e;
    font-size: 11px;
}

.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin: 0 auto;  /* Add this to center the grid */
    width: 100%;     /* Add this to make it full width */
}

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

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

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

/* Color coding */
.stat-value.good, .advanced-value.good, .season-value.good {
    color: #4CAF50 !important;
}

.stat-value.average, .advanced-value.average, .season-value.average {
    color: #cfb72b !important;
}

.stat-value.poor, .advanced-value.poor, .season-value.poor {
    color: #cf4c2b !important;
}

/* Advanced Stats Row */
.advanced-row {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 8px;
    margin-top: 12px;
    margin-left: 0;   /* Add this */
    margin-right: 0;  /* Add this */
    width: 100%;      /* Add this */
}

.advanced-stat {
    text-align: center;
    padding: 8px;
    background: rgba(255,255,255,0.08);
    border-radius: 4px;
}

.advanced-label {
    color: #9e9e9e;
    font-size: 10px;
    margin-bottom: 4px;
}

.advanced-value {
    font-size: 16px;
    font-weight: bold;
}

/* Season Stats */
.season-stats {
    background: rgba(255,255,255,0.03);
    border-radius: 6px;
    padding: 10px;
}

.section-title {
    color: #9e9e9e;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 8px;
    padding-bottom: 4px;
    border-bottom: 1px solid #444;
}

.season-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.season-stat {
    text-align: center;
    padding: 2px;
}

.season-label {
    color: #808080;
    font-size: 10px;
    margin-bottom: 2px;
}

.season-value {
    font-size: 12px;
    font-weight: 600;
}

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

.loading-spinner {
    border: 3px solid #444;
    border-top: 3px solid #667eea;
    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); }
}

/* Resize Handle */
.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 */
.stats-popup:nth-of-type(2) .popup-header {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
}

.stats-popup:nth-of-type(3) .popup-header {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
}

/* PHASE 2 MOBILE POPUP OPTIMIZATION */
@media (max-width: 768px) {
    .stats-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 */
    .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;
    }
    
    .close-btn:hover {
        background: rgba(255, 255, 255, 1) !important;
        transform: scale(1.05) !important;
    }
    
    /* Scrollable popup body */
    .popup-body {
        max-height: calc(85vh - 80px) !important;
        overflow-y: auto !important;
        padding: 12px !important;
    }
    
    /* Responsive grid layouts */
    .stats-grid {
        grid-template-columns: 1fr !important;
        gap: 8px !important;
    }
    
    .advanced-row {
        grid-template-columns: 1fr !important;
        gap: 8px !important;
    }
    
    .season-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 6px !important;
    }
    
    /* PRIORITY 2 FIX: Adjust header for mobile and show full pitcher names */
    .popup-header {
        padding: 16px 60px 16px 16px !important; /* Extra right padding for close button */
    }
    
    .popup-title {
        font-size: 16px !important;
        white-space: nowrap !important;
        overflow: visible !important;
        text-overflow: unset !important;
        max-width: none !important;
    }
    
    .pitcher-name {
        white-space: nowrap !important;
        overflow: visible !important;
        text-overflow: unset !important;
        max-width: none !important;
    }
}
