/* SportsIQ - Complementary Dark Theme Styles */
html {
    scroll-behavior: smooth;
    overflow-y: scroll;
}

/* Custom Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: #0f172a; }
::-webkit-scrollbar-thumb { background: #4f46e5; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #6366f1; }

/* Firefox Scrollbar */
* { scrollbar-width: thin; scrollbar-color: #4f46e5 #0f172a; }

/* Selection */
::selection {
    background: rgba(99, 102, 241, 0.3);
    color: white;
}

/* Focus Visible */
:focus-visible {
    outline: 2px solid #6366f1;
    outline-offset: 2px;
}

/* Table */
table { border-collapse: collapse; width: 100%; }

/* Tabular Numbers for scores/odds */
.tabular-nums { font-variant-numeric: tabular-nums; }

/* View transition */
.view-content { animation: viewFadeIn 0.3s ease-out; }
@keyframes viewFadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Tooltip */
[data-tooltip] { position: relative; }
[data-tooltip]:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%);
    background: #1e293b;
    color: white;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 11px;
    white-space: nowrap;
    z-index: 50;
    border: 1px solid rgba(99, 102, 241, 0.2);
    pointer-events: none;
}

/* Multi-line truncate */
.truncate-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Prevent image flicker */
img { image-rendering: auto; max-width: 100%; height: auto; }

/* Betting Tips Styles */
.palpite-pick {
    background: linear-gradient(135deg, rgba(34, 197, 94, 0.2), rgba(34, 197, 94, 0.08));
    border: 1px solid rgba(34, 197, 94, 0.4);
    box-shadow: 0 0 8px rgba(34, 197, 94, 0.15);
}

.confidence-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 9999px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.5px;
}

.market-section + .market-section {
    padding-top: 12px;
    margin-top: 12px;
    border-top: 1px solid rgba(99, 102, 241, 0.1);
}

.pick-glow {
    animation: pickGlow 2s ease-in-out infinite alternate;
}
@keyframes pickGlow {
    from { box-shadow: 0 0 5px rgba(34, 197, 94, 0.2); }
    to { box-shadow: 0 0 15px rgba(34, 197, 94, 0.35); }
}

/* ========== RESPONSIVE IMPROVEMENTS ========== */

/* Base - Mobile first touch targets */
button, a, .nav-item, .card-hover {
    min-height: 44px;
}

/* Safe area padding for notched phones */
body {
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
    padding-bottom: env(safe-area-inset-bottom);
}

/* Very small screens (< 360px) */
@media (max-width: 359px) {
    .glass { padding-left: 0.5rem; padding-right: 0.5rem; }
    .glass.rounded-xl { border-radius: 0.5rem; }
    header.sticky { left: 0; }
}

/* Mobile small (< 640px) */
@media (max-width: 639px) {
    /* Sidebar full width overlay */
    #sidebar {
        width: 85vw;
        max-width: 280px;
    }
    
    /* Smaller touch areas but still accessible */
    .nav-item {
        padding: 0.75rem 1rem;
        min-height: 44px;
    }
    
    /* Adjust main content padding */
    main .p-4 { padding: 0.75rem; }
    
    /* Live match cards - stack vertically on very small screens */
    .live-card .flex.items-center.gap-2.sm\:gap-4 {
        gap: 0.5rem;
    }
    
    /* Make score numbers slightly smaller */
    .live-score-num {
        font-size: 1.25rem;
    }
    
    /* Tables need horizontal scroll */
    .glass.rounded-xl.overflow-hidden,
    #standingsTable {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    /* Modal full height on mobile */
    #matchDetailModal > div {
        max-width: 100%;
        max-height: 100vh;
        border-radius: 0;
        margin: 0;
        height: 100vh;
    }
    
    /* Ensure grids don't overflow */
    .grid {
        margin-left: 0;
        margin-right: 0;
    }
    
    /* Predictions cards - full width */
    #predictionsList .glass {
        width: 100%;
    }
}

/* Tablet (640px - 1023px) */
@media (min-width: 640px) and (max-width: 1023px) {
    /* Live cards can be side by side */
}

/* Large screens (>= 1024px) */
@media (min-width: 1024px) {
    /* Restore sidebar width */
    #sidebar {
        width: 16rem;
    }
}

/* Landscape mobile phones */
@media (max-height: 500px) and (orientation: landscape) {
    #matchDetailModal > div {
        max-height: 95vh;
    }
    
    .glass.rounded-xl {
        padding: 0.5rem;
    }
    
    /* Reduce vertical padding in landscape */
    .p-4 { padding: 0.5rem 1rem; }
    .p-6 { padding: 0.75rem 1.5rem; }
}

/* ========== RESPONSIVE COMPONENT FIXES ========== */

/* Sidebar - Prevent content shift */
#sidebar {
    will-change: transform;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
}

/* Overlay interaction */
#mobileOverlay {
    -webkit-tap-highlight-color: transparent;
}

/* Ensure match cards don't overflow on mobile */
.live-card {
    max-width: 100%;
    overflow: hidden;
    word-break: break-word;
}

/* Responsive images */
img[src*="team"] {
    max-width: 40px;
    max-height: 40px;
}

/* Modal - smooth open/close */
#matchDetailModal {
    -webkit-overflow-scrolling: touch;
}

#matchDetailModal > div {
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

/* Fix grid overflow on mobile */
[id^="view-"] > .grid {
    max-width: 100%;
    overflow: hidden;
}

/* Ensure buttons have proper touch targets */
button.p-2, 
.page-nav button {
    min-width: 44px;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* H2H inputs on mobile */
#h2hTeam1,
#h2hTeam2 {
    width: 100%;
}

/* Standings table responsive */
#standingsTable table {
    font-size: 0.75rem;
    min-width: 600px;
}

#standingsTable > div {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* Odds grid responsive */
.odds-grid {
    display: grid;
    gap: 0.5rem;
}

/* Dark mode scrollbar on mobile */
@media (max-width: 639px) {
    ::-webkit-scrollbar { width: 4px; }
    ::-webkit-scrollbar-thumb { background: rgba(79, 70, 229, 0.6); }
}

/* Active state for mobile touch */
@media (hover: none) {
    .card-hover:active {
        transform: scale(0.98);
        transition: transform 0.1s;
    }
    
    .nav-item:active {
        background: rgba(99, 102, 241, 0.3);
    }
}

/* Print styles */
@media print {
    #sidebar, #mobileOverlay, .glass { 
        position: static; 
        background: white;
        color: black;
    }
    main { margin-left: 0; }
}

/* Prefers reduced motion */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .pulse-live { animation: none; opacity: 1; }
    .slide-in { animation: none; opacity: 1; }
    .fade-in { animation: none; opacity: 1; }
    .pick-glow { animation: none; }
}

/* High contrast mode */
@media (prefers-contrast: high) {
    .glass, .glass-light {
        border-color: rgba(255, 255, 255, 0.5);
    }
    
    .text-dark-400 { color: #94a3b8; }
    .text-dark-500 { color: #94a3b8; }
}
