/* ============================================
   LineupIQ Responsive Styles
   ============================================ */

/* Container Queries for Panel Responsiveness */
.panel-right {
    container-type: inline-size;
    container-name: lineup-panel;
}

.panel-left {
    container-type: inline-size;
    container-name: player-panel;
}

/* Lineup Panel Responsive */
@container lineup-panel (max-width: 480px) {
    .lineup-panel-toolbar .btn-text {
        display: none;
    }

    .lineup-panel-toolbar .btn i {
        margin: 0 !important;
    }

    #lineupQuickFilter {
        width: 140px !important;
    }
}

@container lineup-panel (max-width: 380px) {
    #lineupQuickFilter {
        width: 100px !important;
    }
}

@container lineup-panel (max-width: 580px) {
    #contestEntryStats {
        display: none;
    }
}

@container lineup-panel (max-width: 420px) {
    .player-filter-indicator {
        margin-left: 0.5rem;
        padding-left: 0.5rem;
    }

    .entry-filter-indicator {
        margin-left: 0.5rem;
    }

        .entry-filter-indicator .badge {
            max-width: 120px;
            overflow: hidden;
            text-overflow: ellipsis;
        }
}

/* Player Panel Responsive */
@container player-panel (max-width: 580px) {
    .player-grid-header .btn-text {
        display: none;
    }

    .player-grid-header .btn i {
        margin: 0 !important;
    }

    #generateLineupsBtn {
        min-width: auto !important;
    }
}

/* Contest Build Header Responsive */
@container player-panel (max-width: 750px) {
    .contest-build-header .btn-text {
        display: none;
    }

    .contest-build-header .btn i {
        margin: 0 !important;
    }
}

@container player-panel (max-width: 650px) {
    .contest-build-header .stat-label {
        display: none;
    }

    .contest-header-stats {
        gap: 0.75rem;
    }

    .contest-header-stat .stat-value {
        padding: 0.2rem 0.5rem;
        background: var(--liq-bg-tertiary);
        border-radius: 4px;
        font-size: 0.8rem;
    }
}

@container player-panel (max-width: 550px) {
    .contest-header-stats {
        display: none;
    }
}

@container player-panel (max-width: 450px) {
    .contest-research-label strong {
        font-size: 0.85rem;
    }

    .contest-research-label i {
        font-size: 0.9rem;
    }
}

/* Mobile Panel Tabs (hidden on desktop) */
.mobile-panel-tabs {
    display: none;
}

/* Mobile Responsive Styles */
@media (max-width: 768px) {
    /* Base container */
    .lineupiq-container {
        min-width: 0 !important;
        width: 100%;
    }

    /* Slate Tabs Mobile */
    .slate-tabs-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        -ms-overflow-style: none;
    }

        .slate-tabs-container::-webkit-scrollbar {
            display: none;
        }

    .slate-date-filter {
        border-right: none;
        margin-right: 0.5rem;
        padding-right: 0;
    }

    .slate-tabs-scroll-wrapper {
        flex: none;
        overflow: visible;
    }

    .slate-tabs-inner {
        overflow: visible;
        flex: none;
    }

    .slate-tabs-scroll-wrapper::before,
    .slate-tabs-scroll-wrapper::after {
        display: none;
    }

    .slate-tabs-settings {
        margin-left: 0.5rem;
    }

    /* Rule Type Tabs - Compact for mobile */
    .rule-type-tab-content span:not(.coming-soon-dot) {
        display: none;
    }

    .rule-type-tab-content i {
        font-size: 1rem;
    }

    /* Mobile Panel Tabs */
    .mobile-panel-tabs {
        display: flex;
        background: var(--liq-bg-secondary);
        border-bottom: 1px solid var(--liq-border-color);
        padding: 0.5rem;
        gap: 0.5rem;
        flex-shrink: 0;
    }

    .mobile-panel-tab {
        flex: 1;
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 0.5rem;
        padding: 0.75rem 1rem;
        border: 1px solid var(--liq-border-color);
        border-radius: 8px;
        background: var(--liq-bg-primary);
        color: var(--liq-text-secondary);
        font-weight: 500;
        cursor: pointer;
        transition: all 0.2s ease;
    }

        .mobile-panel-tab.active {
            background: var(--liq-accent-green);
            border-color: var(--liq-accent-green);
            color: white;
        }

        .mobile-panel-tab:not(.active):hover {
            background: var(--liq-bg-tertiary);
        }

    /* Workspace Layout */
    .build-workspace {
        height: calc(100vh - 110px);
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }

    .workspace-panel {
        width: 100% !important;
        min-width: 0 !important;
        flex: 1 !important;
        display: flex;
        flex-direction: column;
        min-height: 0;
        overflow: hidden;
    }

        .workspace-panel.panel-left {
            display: flex;
        }

        .workspace-panel.panel-right {
            display: none;
        }

    .build-workspace.show-lineups .workspace-panel.panel-left {
        display: none;
    }

    .build-workspace.show-lineups .workspace-panel.panel-right {
        display: flex;
    }

    .panel-divider {
        display: none;
    }

    /* Headers */
    .panel-header,
    .player-grid-header {
        flex-shrink: 0;
        flex-wrap: wrap;
        gap: 0.5rem;
        padding: 0.5rem 0.75rem;
        height: auto;
    }

    .player-grid-subheader {
        flex-direction: row;
        flex-wrap: nowrap;
        align-items: center;
        justify-content: space-between;
        padding: 0.4rem 0.75rem;
        gap: 0.5rem;
        height: auto;
        flex-shrink: 0;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

        .player-grid-subheader > div {
            flex-wrap: nowrap;
            flex-shrink: 0;
            gap: 0.35rem !important;
        }

        .player-grid-subheader .player-search {
            width: 110px !important;
            min-width: 90px;
            padding: 0.25rem 0.5rem;
            font-size: 0.8rem;
        }

    #positionFilterGroup {
        overflow-x: auto;
        flex-wrap: nowrap;
        -webkit-overflow-scrolling: touch;
    }

        #positionFilterGroup .btn {
            padding: 0.2rem 0.45rem;
            font-size: 0.75rem;
        }

    .player-grid-subheader > div:first-child > span.text-muted {
        display: none;
    }

    .player-grid-subheader .btn[style*="width: 32px"] {
        width: 26px !important;
        height: 24px !important;
        min-width: 26px;
    }

    #favoritesDropdownBtn {
        width: 26px !important;
        height: 24px !important;
    }

    .panel-content {
        flex: 1;
        min-height: 0;
        overflow: hidden;
    }

    #playerGrid,
    #lineupGrid,
    #contestEntriesGrid {
        height: 100% !important;
        width: 100% !important;
    }

    /* Rule Modal Mobile */
    .rule-modal-content {
        max-width: 100%;
        margin: 0.5rem;
    }

    .rule-constraint-row {
        font-size: 0.8125rem;
    }

    /* Contests Header Mobile */
    .contests-header {
        flex-wrap: wrap;
        gap: 0.75rem;
    }

        .contests-header > div:first-child {
            flex: 1;
            min-width: 0;
            flex-wrap: wrap;
            gap: 0.5rem !important;
        }

            /* Hide slate name on mobile - it's redundant info */
            .contests-header > div:first-child > span.text-muted.small {
                display: none;
            }

        /* Make badges smaller */
        .contests-header .badge {
            font-size: 0.7rem;
            padding: 0.2rem 0.4rem;
        }

        /* Right side controls */
        .contests-header > div:last-child {
            gap: 0.35rem !important;
        }

        /* Hide list view toggle on mobile - cards work better for touch */
        .contests-header #cardViewBtn,
        .contests-header #listViewBtn {
            display: none;
        }

        /* Also hide the parent btn-group if both children hidden */
        .contests-header .btn-group {
            display: none;
        }

        /* Hide "Filters" text, keep icon */
        .contests-header #contestFiltersBtn span {
            display: none;
        }

        /* Smaller buttons */
        .contests-header #contestFiltersBtn,
        .contests-header #refreshContestsBtn {
            padding: 0.35rem 0.5rem;
        }

    /* Contests workspace padding */
    .contests-workspace {
        padding: 1rem;
    }

    /* Contest cards grid - single column on small screens */
    .contests-grid {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }

    /* Contest card adjustments for mobile */
    .contest-card-header {
        padding: 0.75rem;
    }

    .contest-name {
        font-size: 0.85rem;
    }

    .contest-card-body {
        padding: 0.75rem;
    }

    .contest-stats {
        gap: 0.5rem;
    }

    .contest-stat .stat-value {
        font-size: 0.9rem;
    }

    .contest-stat .stat-label {
        font-size: 0.65rem;
    }

    .contest-card-footer {
        padding: 0.5rem 0.75rem;
    }

        .contest-card-footer .btn {
            font-size: 0.75rem;
            padding: 0.3rem 0.6rem;
        }

    /* Filter panel mobile adjustments */
    .contests-filters .filters-container {
        padding: 0.75rem;
    }

    .contests-filters .row.g-3 {
        --bs-gutter-y: 0.75rem;
    }

    .contests-filters .form-label {
        margin-bottom: 0.25rem;
    }
}

/* Tablet Responsive */
@media (max-width: 992px) {
    /* Analysis Modal Responsive */
    .analysis-modal-content {
        width: 95%;
        height: 85vh;
    }

    .analysis-sidebar {
        width: 60px;
    }

    .analysis-nav-link span {
        display: none;
    }

    .analysis-nav-link {
        justify-content: center;
        padding: 0.75rem;
    }

        .analysis-nav-link i {
            margin: 0;
        }

    .analysis-row {
        grid-template-columns: 1fr;
    }

    .analysis-summary-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* Date Picker Mobile */
@media (max-width: 576px) {
    .date-picker-section {
        flex-direction: column;
        align-items: stretch;
    }

    .date-picker-controls {
        justify-content: center;
    }

    .slate-filters {
        justify-content: space-between;
    }

        .slate-filters .form-select {
            flex: 1;
            min-width: 0;
        }

    .game-type-filter-menu {
        right: auto;
        left: 0;
    }

    .analysis-summary-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Small Mobile */
@media (max-width: 640px) {
    /* Small screen adjustments */
}

/* Very Small Mobile */
@media (max-width: 480px) {
    /* Very small screen adjustments */
}

/* Import/Export Modal Responsive */
@media (max-width: 768px) {
    .import-mapping-section {
        flex-direction: column;
        align-items: stretch;
        gap: 1rem;
    }

    .import-mapping-grid {
        flex-direction: column;
        gap: 0.5rem;
    }

    .import-mapping-item {
        justify-content: space-between;
        width: 100%;
    }

        .import-mapping-item label {
            min-width: 80px;
        }

        .import-mapping-item select {
            flex: 1;
            margin-left: 0.5rem;
        }

    .import-summary {
        flex-direction: column;
        gap: 0.5rem;
        align-items: stretch;
        text-align: center;
    }
}

/* High DPI / Retina Display Adjustments */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .site-logo {
        image-rendering: -webkit-optimize-contrast;
        image-rendering: crisp-edges;
    }
}

/* Print Styles */
@media print {
    .lineupiq-container {
        background: white !important;
        color: black !important;
        min-width: auto;
    }

    .slate-tabs-container,
    .build-tabs-section,
    .panel-header,
    .player-grid-header,
    .player-grid-subheader,
    .lineup-panel-toolbar {
        display: none !important;
    }

    .build-workspace {
        height: auto !important;
        display: block !important;
    }

    .workspace-panel {
        display: block !important;
        min-width: auto !important;
        width: 100% !important;
        height: auto !important;
        overflow: visible !important;
    }

    .panel-content {
        height: auto !important;
        overflow: visible !important;
    }
}

/* Reduced Motion Preferences */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }

    .generation-progress-icon {
        animation: none !important;
    }

    #refreshProjectionsBtn i.spin-animation {
        animation: none !important;
    }

    .contest-state-live {
        animation: none !important;
    }
}

/* High Contrast Mode Support */
@media (prefers-contrast: high) {
    .lineupiq-container {
        --liq-border-color: #000000;
        --liq-text-secondary: #000000;
    }

    [data-bs-theme="dark"] .lineupiq-container {
        --liq-border-color: #ffffff;
        --liq-text-secondary: #ffffff;
    }
}

/* Dark Mode Preference Override */
@media (prefers-color-scheme: dark) {
    :root:not([data-bs-theme]) {
        --liq-bg-primary: #1a1d29;
        --liq-bg-secondary: #252834;
        --liq-bg-tertiary: #2d3142;
        --liq-bg-hover: rgba(255, 255, 255, 0.05);
        --liq-text-primary: #ffffff;
        --liq-text-secondary: #b0b3c1;
        --liq-border-color: #3d4152;
        --liq-shadow: rgba(0, 0, 0, 0.3);
        --liq-modal-backdrop: rgba(0, 0, 0, 0.85);
    }
}
