/* 
 * Common CSS styles shared between allindices.html and correlation.html
 * Contains: gradients, glass effects, AG-Grid styling, animations, and utility classes
 */

/* Import Inter font */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

/* Orange color theme variables */
:root {
    --orange-400: #ff9a56;
    --orange-500: #ffb347;
    --orange-600: #ff7b54;
    --orange-100: #ffd27f;
    --red-pastel: #ffb3ba;
}

/* Apply Inter font globally */
* {
    font-family: 'Inter', ui-sans-serif, system-ui, sans-serif;
}

/* Background gradients */
.bg-orange-gradient {
    background: linear-gradient(135deg, #ff9a56 0%, #ffb347 50%, #ffd27f 100%);
}

.text-gradient-orange {
    background: linear-gradient(135deg, #ff7b54, #ff9a56);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Glass effect for cards and containers */
.glass-effect {
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.3);
    transform: translateZ(0);
    will-change: transform;
}

/* Custom AG-Grid styling with compact headers */
.ag-theme-alpine {
    --ag-header-background-color: #f8fafc;
    --ag-odd-row-background-color: #f9fafb;
    --ag-header-foreground-color: #374151;
    --ag-border-color: #e5e7eb;
    --ag-header-height: 28px; /* Further reduced for more compact design */
    --ag-row-height: 36px; /* Reduced row height for more compact design */
    --ag-font-size: 13px; /* Slightly smaller font */
}

/* Additional header spacing reduction with bold headers */
.ag-theme-alpine .ag-header-cell {
    padding: 4px 8px !important; /* Reduced padding */
}

.ag-theme-alpine .ag-header-cell-text {
    font-weight: 700 !important; /* Bold headers */
}

/* Keep original cell styling */
.ag-theme-alpine .ag-cell {
    padding: 4px 8px !important;
}

/* Popup styling */
.popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.popup-overlay.active {
    opacity: 1;
    visibility: visible;
}

.popup-content {
    background: white;
    border-radius: 16px;
    padding: 24px;
    max-width: 792px;
    width: 90%;
    max-height: 86vh;
    overflow-y: auto;
    transform: scale(0.9);
    transition: transform 0.3s ease;
}

.popup-overlay.active .popup-content {
    transform: scale(1);
}

/* Loading animation */
.loading-spinner {
    border: 3px solid #f3f4f6;
    border-top: 3px solid #ff9a56;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes flash {
    0%, 50% { opacity: 1; }
    25%, 75% { opacity: 0.3; }
}

/* Status indicators */
.status-online {
    background-color: #10b981;
}

.status-offline {
    background-color: #ef4444;
}

/* High IV warning dot */
.high-iv-dot {
    width: 12px;
    height: 12px;
    background-color: var(--red-pastel);
    border-radius: 50%;
    animation: flash 2s infinite;
}

.status-warning {
    background-color: #f59e0b;
}

/* Index cards styling (for allindices.html) */
.index-card {
    transition: all 0.3s ease;
    cursor: pointer;
}

/* Force minimal spacing between region groups in Available Indices */
#indicesCardsContainer .region-group {
    margin-bottom: 2px !important;
}

#indicesCardsContainer .region-group + .region-group {
    margin-top: 0 !important;
}

.index-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 25px rgba(0,0,0,0.1);
}

.index-card.selected {
    border-color: #3b82f6 !important; /* blue-500 */
    border-width: 2px;
    background-color: rgba(239, 246, 255, 0.5); /* blue-50 with opacity */
}

/* Darker shades for selected cards */
.index-card.selected.bg-green-50 { background-color: #d1fae5 !important; } /* green-100 */
.index-card.selected.bg-blue-50 { background-color: #dbeafe !important; } /* blue-100 */
.index-card.selected.bg-purple-50 { background-color: #e9d5ff !important; } /* purple-100 */

/* Persistent raised effect */
.index-card.selected {
    transform: translateY(-0.25rem) !important;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05) !important;
}

/* Risk level indicators */
.risk-low { background: linear-gradient(135deg, #10b981, #34d399); }
.risk-medium { background: linear-gradient(135deg, #f59e0b, #fbbf24); }
.risk-high { background: linear-gradient(135deg, #ef4444, #f87171); }

/* More robust clipping fix for index cards container */
#indicesCardsContainer > div {
    padding: 8px 0 0 0;
    margin: -8px 0 0 0;
    overflow: visible !important;
}

/* Ensure card container allows overflow */
#indicesCardsContainer > div > div:last-child {
    overflow: visible !important;
}

/* Add padding to prevent hover clipping */
#indicesCardsContainer > div {
    padding-top: 4px;
    margin-top: -4px;
}

/* Ensure region headers sit above cards */
#indicesCardsContainer > div > div:first-child {
    position: relative;
    z-index: 1;
}

/* Prevent cards from intercepting clicks meant for headers */
#indicesCardsContainer > div > div:last-child {
    pointer-events: none;
}

/* Re-enable pointer events for cards themselves */
.index-card {
    pointer-events: auto;
}

/* Responsive design adjustments */
@media (max-width: 768px) {
    .popup-content {
        max-width: 95%;
        margin: 20px;
    }
    
    .ag-theme-alpine {
        --ag-header-height: 28px;
        --ag-row-height: 38px;
    }
    
    .ag-theme-alpine .ag-header-cell,
    .ag-theme-alpine .ag-cell {
        padding: 2px 4px !important;
    }
}

/* Utility classes for consistent spacing */
.section-spacing {
    margin-bottom: 2rem;
}

.card-spacing {
    gap: 1.5rem;
}

.stat-box-hover {
    transform: scale(1.05);
    transition: transform 0.2s ease;
}

/* Focus states for accessibility */
button:focus,
select:focus {
    outline: 2px solid var(--orange-400);
    outline-offset: 2px;
}

/* Print styles */
@media print {
    .glass-effect {
        background: white;
        border: 1px solid #ccc;
    }
    
    .bg-orange-gradient {
        background: white;
    }
    
    .popup-overlay {
        display: none;
    }
}