/**
 * Interactive Card Hover Effects
 * Excel-like cell expansion on hover with enhanced borders
 */

/* Enable smooth page scrolling */
html {
    scroll-behavior: smooth;
}

/* Base card styling with smooth transitions */
.card {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid rgba(255, 255, 255, 0.1);
    position: relative;
    overflow: visible;
}

/* Enhanced hover state with border glow */
.card:hover {
    border: 2px solid rgba(29, 140, 248, 0.6);
    box-shadow: 0 8px 26px rgba(29, 140, 248, 0.3),
                0 0 0 1px rgba(29, 140, 248, 0.2);
    transform: translateY(-4px) scale(1.02);
    z-index: 100;
}

/* Touch device support - tap to expand */
.card.touch-expanded,
.card:active {
    border: 2px solid rgba(29, 140, 248, 0.6);
    box-shadow: 0 8px 26px rgba(29, 140, 248, 0.3),
                0 0 0 1px rgba(29, 140, 248, 0.2);
    transform: translateY(-4px) scale(1.02);
    z-index: 100;
}

/* Chart cards get extra emphasis */
.card-chart:hover,
.card-chart.touch-expanded {
    border: 2px solid rgba(0, 242, 195, 0.7);
    box-shadow: 0 12px 40px rgba(0, 242, 195, 0.4),
                0 0 0 2px rgba(0, 242, 195, 0.3);
}

/* Data table card hover */
.card:has(table):hover {
    border: 2px solid rgba(233, 30, 99, 0.6);
    box-shadow: 0 8px 26px rgba(233, 30, 99, 0.3);
}

/* Expandable height on hover - Excel-like behavior */
.card-expandable {
    max-height: 400px;
    overflow: visible; /* Changed from hidden to allow page scroll */
    transition: max-height 0.5s ease-in-out, transform 0.3s ease;
}

.card-expandable:hover,
.card-expandable.touch-expanded {
    max-height: none; /* Remove height constraint - let content determine height */
    overflow: visible; /* Keep content visible, page will scroll */
}

/* Card body smooth expansion */
.card-body {
    transition: padding 0.3s ease;
    overflow: visible; /* Allow content to flow naturally */
}

.card:hover .card-body,
.card.touch-expanded .card-body {
    padding: 1.5rem; /* Slight padding increase on hover/tap */
}

/* Enhanced border animation */
.card::before {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    background: linear-gradient(45deg, 
        rgba(29, 140, 248, 0.8),
        rgba(0, 242, 195, 0.8),
        rgba(233, 30, 99, 0.8));
    border-radius: 12px;
    opacity: 0;
    z-index: -1;
    transition: opacity 0.4s ease;
    filter: blur(8px);
}

.card:hover::before,
.card.touch-expanded::before {
    opacity: 0.6;
    animation: borderPulse 2s infinite;
}

@keyframes borderPulse {
    0%, 100% {
        opacity: 0.4;
    }
    50% {
        opacity: 0.8;
    }
}

/* Card header enhancement on hover */
.card-header {
    transition: background-color 0.3s ease, border-bottom 0.3s ease;
}

.card:hover .card-header {
    background-color: rgba(29, 140, 248, 0.15);
    border-bottom: 2px solid rgba(29, 140, 248, 0.5);
}

/* Chart container expansion */
.chart-container {
    transition: height 0.4s ease-in-out;
}

.card:hover .chart-container,
.card.touch-expanded .chart-container {
    height: 600px; /* Expands from default 500px */
}

/* Corner accent indicators */
.card::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 0 20px 20px 0;
    border-color: transparent rgba(29, 140, 248, 0.6) transparent transparent;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.card:hover::after {
    opacity: 1;
}

/* Prevent layout shift during hover */
.card-container {
    padding: 5px; /* Buffer space for expanded cards */
    overflow: visible; /* Allow cards to expand naturally */
}

/* Page header card special treatment */
.page-header-card:hover {
    border: 2px solid rgba(233, 30, 99, 0.6);
    box-shadow: 0 10px 35px rgba(233, 30, 99, 0.4);
    transform: translateY(-2px) scale(1.01);
}

/* Table cells interactive highlight */
.card:hover table tbody tr:hover {
    background-color: rgba(29, 140, 248, 0.15) !important;
    transform: scale(1.01);
    box-shadow: 0 2px 8px rgba(29, 140, 248, 0.3);
}

/* Smooth transition for all interactive elements */
.card * {
    transition: transform 0.2s ease, background-color 0.2s ease;
}

/* Focus state for accessibility */
.card:focus-within {
    border: 2px solid rgba(0, 242, 195, 0.8);
    box-shadow: 0 0 0 3px rgba(0, 242, 195, 0.3);
    outline: none;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .card:hover,
    .card.touch-expanded {
        transform: translateY(-2px) scale(1.01);
    }
    
    .card:hover .chart-container,
    .card.touch-expanded .chart-container {
        height: 550px; /* Smaller expansion on mobile */
    }
    
    /* Cards expand naturally on mobile - no max height constraint */
    .card-expandable {
        max-height: none;
    }
}

/* Touch device specific styles */
@media (hover: none) and (pointer: coarse) {
    /* Remove hover effects on true touch devices */
    .card {
        -webkit-tap-highlight-color: rgba(29, 140, 248, 0.2);
    }
    
    /* Ensure touch-expanded state is visible */
    .card.touch-expanded {
        border: 2px solid rgba(29, 140, 248, 0.8) !important;
    }
    
    /* Add subtle bounce animation on tap */
    .card:active {
        animation: cardTap 0.3s ease;
    }
    
    @keyframes cardTap {
        0% { transform: scale(1); }
        50% { transform: scale(0.98); }
        100% { transform: scale(1); }
    }
    
    /* Touch hint styling */
    .touch-hint {
        padding: 4px 8px;
        background: rgba(29, 140, 248, 0.15);
        border-radius: 4px;
        margin-left: 10px;
    }
}

/* Dark mode enhancement */
@media (prefers-color-scheme: dark) {
    .card {
        border-color: rgba(255, 255, 255, 0.15);
    }
    
    .card:hover {
        border-color: rgba(29, 140, 248, 0.8);
    }
}
