/**
 * Elegant Real-time Odds Animations & Visual Effects
 * Professional styling for live odds updates
 */

/* Real-time Connection Status Indicator */
#realtime-status {
    position: fixed;
    top: 10px;
    right: 10px;
    z-index: 9999;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    color: white;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    backdrop-filter: blur(10px);
}

/* Odds Update Animations */
/* Update highlight: subtle ring outline that fades slowly (no text color change) */
.odds-better, .odds-worse { color: inherit !important; }

.odds-updating { position: relative; }
/* Disable ring to avoid border flash */
.odds-updating::after { content: none !important; }

@keyframes oddsRing {
    0%   { opacity: 1; transform: scale(1); }
    100% { opacity: 0; transform: scale(1.05); }
}

/* Removed slide animation - using simple blue fade only */

/* Odds Change Direction Indicators */
/* keep text color unchanged; ring indicates direction (overridden above) */



/* Smooth Transitions for All Odds Elements */
[data-outcome-id] {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 4px;
    padding: 4px 8px;
    display: inline-block;
    min-width: 60px;
    text-align: center;
}

/* Hover Effects */
/* Disable hover movement and shadow on odds */
[data-outcome-id]:hover {
    transform: none;
    box-shadow: none;
}

/* Loading State */
.odds-loading {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
    color: transparent;
}

@keyframes loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Immediate-load shimmer overlay that doesn't hide text */
.odds-shimmer {
    position: relative !important;
    isolation: isolate !important;
}
.odds-shimmer::after {
    content: '' !important;
    position: absolute !important;
    inset: 0 !important;
    border-radius: var(--pill-radius, 3px) !important;
    background: linear-gradient(90deg, rgba(240,240,240,0.8) 25%, rgba(224,224,224,0.8) 50%, rgba(240,240,240,0.8) 75%) !important;
    background-size: 200% 100% !important;
    animation: loading 1.2s infinite !important;
    pointer-events: none !important;
    z-index: 0 !important;
}
.odds-shimmer > * { position: relative !important; z-index: 1 !important; }

/* Container-level immediate shimmer for first paint */
.props-odds.props-is-loading .over-odds,
.props-odds.props-is-loading .under-odds,
.props-odds.props-is-loading [data-outcome-id] { position: relative; }

/* Disable previous shimmer overlays when using simple skeleton */
.props-odds.props-is-loading .over-odds::after,
.props-odds.props-is-loading .under-odds::after,
.props-odds.props-is-loading [data-outcome-id]::after { content: none !important; }

/* Full-table shimmer: apply to all table cells and headers while loading */
/* Shadcn-like simple skeleton: subtle pulse, no moving gradient */
@keyframes propsSkeletonPulse {
    0%, 100% { opacity: 0.85; }
    50%      { opacity: 1; }
}

/* Keep headers visible; only animate body cells */
/* Important: do NOT override sticky positioning for frozen columns while loading */
.props-odds.props-is-loading .props-comparison-table tbody td:not(.player-info):not(.game-info):not(.game-info-dup):not(.game-info-mobile),
.props-odds.props-is-loading .props-odds-table tbody td { position: relative; }

/* Hide body cell content to avoid ghosting */
.props-odds.props-is-loading .props-comparison-table tbody td > *,
.props-odds.props-is-loading .props-odds-table tbody td > * { visibility: hidden !important; }

/* Disable any old overlays on headers/cells */
.props-odds.props-is-loading .props-comparison-table td::after,
.props-odds.props-is-loading .props-odds-table td::after,
.props-odds.props-is-loading .props-comparison-table th::after,
.props-odds.props-is-loading .props-odds-table th::after { content: none !important; }

/* Player cell: avatar circle + two text bars */
/* Preserve sticky positioning on .player-info (no position override here) */
.props-odds.props-is-loading .player-info::before {
    content: '';
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    width: 26px; height: 26px;
    border-radius: 50%;
    background: #e9edf3;
    animation: propsSkeletonPulse 1.2s ease-in-out infinite;
}
.props-odds.props-is-loading .player-info::after {
    content: '';
    position: absolute;
    left: 46px; right: 24px;
    top: calc(50% - 10px);
    height: 10px;
    border-radius: 6px;
    background: #eef2f7;
    animation: propsSkeletonPulse 1.2s ease-in-out infinite;
    box-shadow: 0 14px 0 0 #eef2f7;
}

/* Game cell: two compact bars */
/* Preserve sticky positioning on .game-info variants (no position override here) */
.props-odds.props-is-loading .game-info::before,
.props-odds.props-is-loading .game-info-dup::before,
.props-odds.props-is-loading .game-info-mobile::before {
    content: '';
    position: absolute;
    left: 10px; right: 10px; top: 10px;
    height: 8px; border-radius: 4px;
    background: #eef2f7;
    animation: propsSkeletonPulse 1.2s ease-in-out infinite;
}
.props-odds.props-is-loading .game-info::after,
.props-odds.props-is-loading .game-info-dup::after,
.props-odds.props-is-loading .game-info-mobile::after {
    content: '';
    position: absolute;
    left: 10px; top: 24px; width: 70px;
    height: 8px; border-radius: 4px;
    background: #eef2f7;
    animation: propsSkeletonPulse 1.2s ease-in-out infinite;
}

/* Line + market: stacked bars centered */
.props-odds.props-is-loading .line-with-market { position: relative; }
.props-odds.props-is-loading .line-with-market::before {
    content: '';
    position: absolute;
    left: 50%; transform: translateX(-50%);
    top: 8px; width: 48px; height: 10px;
    border-radius: 6px; background: #eef2f7;
    animation: propsSkeletonPulse 1.2s ease-in-out infinite;
}
.props-odds.props-is-loading .line-with-market::after {
    content: '';
    position: absolute;
    left: 50%; transform: translateX(-50%);
    top: 24px; width: 64px; height: 8px;
    border-radius: 5px; background: #eef2f7;
    animation: propsSkeletonPulse 1.2s ease-in-out infinite;
}

/* Odds cells: centered rounded pill placeholder */
.props-odds.props-is-loading .odds-cell,
.props-odds.props-is-loading .over-odds,
.props-odds.props-is-loading .under-odds { position: relative; }
.props-odds.props-is-loading .odds-cell::before,
.props-odds.props-is-loading .over-odds::before,
.props-odds.props-is-loading .under-odds::before {
    content: '';
    position: absolute;
    left: 50%; top: 50%; transform: translate(-50%, -50%);
    width: 64px; height: 18px;
    border-radius: 999px; background: #eef2f7;
    animation: propsSkeletonPulse 1.2s ease-in-out infinite;
}

/* Sportsbook and time: single small bar */
.props-odds.props-is-loading .sportsbook,
.props-odds.props-is-loading .updated-at { position: relative; }
.props-odds.props-is-loading .sportsbook::before,
.props-odds.props-is-loading .updated-at::before {
    content: '';
    position: absolute;
    left: 50%; transform: translateX(-50%);
    top: 50%; transform: translate(-50%, -50%);
    width: 80px; height: 10px;
    border-radius: 6px; background: #eef2f7;
    animation: propsSkeletonPulse 1.2s ease-in-out infinite;
}

/* New Odds Notification Toast */
.odds-notification {
    position: fixed;
    top: 60px;
    right: 10px;
    z-index: 9998;
    background: linear-gradient(135deg, #3b82f6, #1d4ed8);
    color: white;
    padding: 12px 16px;
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(59, 130, 246, 0.3);
    transform: translateX(100%);
    transition: transform 0.3s ease;
    max-width: 300px;
    font-size: 14px;
    line-height: 1.4;
}

.odds-notification.show {
    transform: translateX(0);
}

.odds-notification .notification-title {
    font-weight: 600;
    margin-bottom: 4px;
}

.odds-notification .notification-body {
    opacity: 0.9;
    font-size: 12px;
}

/* Real-time Activity Indicator */
.realtime-activity {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: rgba(16, 185, 129, 0.9);
    color: white;
    padding: 8px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

.realtime-activity.active {
    opacity: 1;
    transform: translateY(0);
}

.realtime-activity::before {
    content: '';
    display: inline-block;
    width: 8px;
    height: 8px;
    background: #10b981;
    border-radius: 50%;
    margin-right: 8px;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Sportsbook Logo Integration */
.odds-container {
    display: flex;
    align-items: center;
    gap: 8px;
}

.sportsbook-logo {
    width: 20px;
    height: 20px;
    border-radius: 4px;
    object-fit: contain;
}

/* Mobile Responsive Adjustments */
@media (max-width: 768px) {
    #realtime-status {
        top: 5px;
        right: 5px;
        font-size: 11px;
        padding: 6px 10px;
    }
    
    .odds-notification {
        right: 5px;
        top: 45px;
        max-width: calc(100vw - 20px);
    }
    
    .realtime-activity {
        bottom: 10px;
        right: 10px;
        font-size: 11px;
        padding: 6px 10px;
    }
    
    [data-outcome-id]:hover {
        transform: none; /* Disable hover effects on mobile */
    }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    .odds-loading {
        background: linear-gradient(90deg, #374151 25%, #4b5563 50%, #374151 75%);
    }
}

/* Accessibility Improvements */
@media (prefers-reduced-motion: reduce) {
    .odds-updating::before,
    .best-odds,
    .cell-flash::after,
    .odds-pill-flash::after,
    .odds-loading {
        animation: none !important;
    }

    [data-outcome-id] {
        transition: none !important;
    }
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
    .odds-better {
        color: #000 !important;
        background: #00ff00 !important;
    }
    
    .odds-worse {
        color: #fff !important;
        background: #ff0000 !important;
    }
    
    .best-odds { box-shadow: inset 0 0 0 3px #000 !important; }
}

/* BIG odds change flash so it's very noticeable */
.odds-flash {
    animation: oddsFlash 1.2s ease-out;
}

@keyframes oddsFlash {
    0% {
        transform: scale(1.08);
        background-color: #dbeafe; /* light blue */
        box-shadow: 0 0 0 0 rgba(59,130,246,0.65), 0 0 0 4px rgba(59,130,246,0.35);
    }
    40% {
        transform: scale(1.04);
        box-shadow: 0 0 0 10px rgba(59,130,246,0);
    }
    100% {
        transform: none;
        background-color: transparent;
        box-shadow: none;
    }
}

/* Disable the old blue overlay to avoid clashing with best-odds background */
.odds-pill-flash::after { background: transparent !important; animation: none !important; }

/* Blue flash overlay confined to pill footprint (no layout change) */
.odds-pair .over-odds.odds-blue-flash,
.odds-pair .under-odds.odds-blue-flash {
    position: relative !important;
    isolation: isolate !important; /* confine overlay */
    display: inline-block !important;
}

/* Blue overlay for pills WITHOUT green background (non-best odds) */
.odds-pair .over-odds.odds-blue-flash:not(.best-odds)::before,
.odds-pair .under-odds.odds-blue-flash:not(.best-odds)::before {
    content: '' !important;
    position: absolute !important;
    /* Extend overlay to simulate padding for non-green pills */
    top: calc(var(--pill-pad-y, 2px) * -1) !important;
    left: calc(var(--pill-pad-x, 8px) * -1) !important;
    right: calc(var(--pill-pad-x, 8px) * -1) !important;
    bottom: calc(var(--pill-pad-y, 2px) * -1) !important;
    border-radius: var(--pill-radius, 3px) !important;
    background-color: rgba(0, 158, 255, 0.6) !important;
    pointer-events: none !important;
    animation: oddsBlueFadeOut 30s ease-out forwards !important;
    z-index: 0 !important; /* Behind text */
}

/* Blue overlay for pills WITH green background (best odds) */
.odds-pair .over-odds.odds-blue-flash.best-odds::before,
.odds-pair .under-odds.odds-blue-flash.best-odds::before {
    content: '' !important;
    position: absolute !important;
    /* Match exact pill boundaries - no extension */
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    border-radius: var(--pill-radius, 3px) !important;
    background-color: rgba(0, 158, 255, 0.6) !important;
    pointer-events: none !important;
    animation: oddsBlueFadeOut 30s ease-out forwards !important;
    z-index: 0 !important; /* Behind text */
}

/* Ensure text stays above blue overlay */
.odds-pair .over-odds.odds-blue-flash > *,
.odds-pair .under-odds.odds-blue-flash > * {
    position: relative !important;
    z-index: 1 !important;
}

@keyframes oddsBlueFadeOut {
    0%   { 
        opacity: 0.6; 
    }
    10%  { 
        opacity: 0.55; 
    }
    30%  { 
        opacity: 0.4; 
    }
    60%  { 
        opacity: 0.2; 
    }
    100% { 
        opacity: 0; 
    }
}

/* Whole-cell highlight + fade for updates (overlay approach to avoid bg overrides) */
.cell-flash {
    position: relative;
    overflow: hidden;
    /* Ensure contents render above the overlay */
    z-index: 0;
}
.cell-flash::after {
    content: "";
    position: absolute;
    inset: 0;
    background: rgba(59,130,246,0.35);
    pointer-events: none;
    animation: cellFadeOverlay 60s linear forwards;
    z-index: -1; /* place overlay behind cell contents */
}
/* Explicitly keep immediate children above the overlay */
.cell-flash > * { position: relative; z-index: 1; }
@keyframes cellFadeOverlay {
    0%   { opacity: 1; }
    60%  { opacity: 0.5; }
    100% { opacity: 0; }
}

/* Hide the fixed Live Odds status pill in the top-right */
#realtime-status { display: none !important; }
