/* CSS Custom Properties for dynamic scaling */
:root {
    --dashboard-scale: 1;
    --dashboard-width: 100vw;
    --dashboard-height: 100vh;
    --base-font-size: 16px;
    --scaled-font-size: calc(var(--base-font-size) * var(--dashboard-scale));
    --compact-header-height: 5.2rem;
    --graph-scale: 1; /* Dynamic graph scaling */
    --graph-height: 500px; /* Dynamic graph height */
}

/* Container Query Support */
.responsive-dashboard {
    container-type: size;
    container-name: dashboard;
}

/* Adaptive font scaling based on ResizeObserver */
html {
    font-size: var(--scaled-font-size);
}

/* Professional scaling for all dashboard components */
.container {
    transform-origin: top left;
    transition: transform 0.2s ease-out;
    max-width: 100vw;
    max-height: 100vh;
    overflow: hidden;
    box-sizing: border-box;
}

/* DISABLE ALL RESPONSIVE OVERRIDES - LET ORIGINAL CSS HANDLE PROGRESS BAR */

/* REMOVED - LET ORIGINAL CSS HANDLE PROGRESS FILL */

/* REMOVED - LET ORIGINAL CSS HANDLE CONTAINER TRANSFORMS */

/* REMOVED - LET ORIGINAL CSS HANDLE TACTICAL PROGRESS */

/* Ensure dashboard components fit within bounds with scaled header */
.dashboard {
    /* Account for scaled header (69% bigger) + space for fixed progress bar at bottom */
    max-height: calc(100vh - calc(var(--compact-header-height) * 1.69) - 60px); /* Account for 1.69x scaled header */
    overflow: hidden;
    /* Add top margin to account for scaled header */
    margin-top: 2rem;
}

.tactical-progress {
    /* Don't override - let original fixed positioning handle this */
    /* Remove height constraints that interfere with fixed positioning */
    max-height: none !important;
    overflow: visible !important;
    height: auto !important;
    /* Ensure container doesn't affect fixed positioned children */
    position: relative !important;
    transform: none !important;
}

/* REMOVED - LET ORIGINAL STYLES.CSS HANDLE PROGRESS BAR */

/* REMOVED - LET ORIGINAL STYLES.CSS HANDLE PROGRESS BAR */

/* REMOVED - LET ORIGINAL STYLES.CSS HANDLE SOLDIER */

/* ================================================================
   CONTAINER QUERY RESPONSIVE BREAKPOINTS
   Modern CSS approach for component-based responsiveness
   ================================================================ */

/* Extra Small Containers */
@container dashboard (max-width: 575px) {
    .dashboard-split {
        flex-direction: column;
    }
    
    .left-panel {
        width: 100%;
        order: 2;
    }
    
    .right-panel {
        order: 1;
    }
    
    .platform-cards-row {
        flex-direction: column;
    }
    
    .stats-cards-grid {
        flex-direction: column;
    }
    
    .tactical-progress {
        padding: 0.5rem 1rem;
    }
}

/* Small Containers */
@container dashboard (min-width: 576px) and (max-width: 767px) {
    .dashboard-split {
        flex-direction: column;
    }
    
    .platform-cards-row {
        /* Keep original flex layout */
    }
    
    .stats-cards-grid {
        /* Keep original flex layout */
    }
}

/* Medium Containers */
@container dashboard (min-width: 768px) and (max-width: 991px) {
    .dashboard-split {
        flex-direction: column;
    }
    
    .left-panel {
        width: 100%;
        max-height: 40vh;
        overflow-y: auto;
    }
    
    .platform-cards-row {
        /* Keep original flex layout */
    }
}

/* Large Containers */
@container dashboard (min-width: 992px) and (max-width: 1199px) {
    .left-panel {
        width: 20rem;
        min-width: 18rem;
    }
    
    .platform-cards-row {
        /* Keep original flex layout */
    }
}

/* Extra Large Containers */
@container dashboard (min-width: 1200px) {
    .left-panel {
        width: 24rem;
        min-width: 20rem;
    }
    
    .platform-cards-row {
        /* Keep original flex layout */
    }
}

/* ================================================================
   SIZE CLASS FALLBACKS for browsers without container query support
   ================================================================ */

.size-xs .dashboard-split {
    flex-direction: column;
}

.size-xs .platform-cards-row {
    flex-direction: column;
}

.size-sm .dashboard-split {
    flex-direction: column;
}

.size-sm .platform-cards-row {
    /* Keep original flex layout */
}

.size-md .dashboard-split {
    flex-direction: column;
}

.size-md .left-panel {
    max-height: 40vh;
    overflow-y: auto;
}

.size-lg .left-panel,
.size-xl .left-panel {
    width: 24rem;
}

/* ================================================================
   COMPONENT-SPECIFIC RESPONSIVE BEHAVIOR
   ================================================================ */

/* Tactical Progress Bar - Adaptive sizing */
.tactical-progress {
    container-type: inline-size;
    container-name: progress;
}

@container progress (max-width: 600px) {
    .progress-bar {
        height: 6px;
    }
    
    .soldier-container {
        width: 2.5rem;
        height: 3.5rem;
    }
    
    .loading-text {
        font-size: 0.875rem;
    }
}

/* Chart Container - Adaptive behavior with proper containment */
.chart-container {
    container-type: size;
    container-name: chart;
    overflow: hidden;
    max-height: 100%;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
}

/* Ensure charts respect container boundaries */
.grafana-chart {
    max-width: 100% !important;
    max-height: 100% !important;
    overflow: hidden !important;
    box-sizing: border-box !important;
}

/* Chart content should be contained */
.chart-container iframe,
.chart-container canvas,
.chart-container svg {
    max-width: 100% !important;
    max-height: 100% !important;
    object-fit: contain;
}

@container chart (max-width: 500px) {
    .graph-tabs-container {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.25rem;
    }
    
    .graph-tab {
        padding: 0.5rem;
        font-size: 0.75rem;
    }
    
    .graph-tab span {
        display: none;
    }
}

@container chart (min-width: 501px) and (max-width: 800px) {
    .graph-tabs-container {
        grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    }
}

/* ================================================================
   HIGH-DPI AND LARGE DISPLAY OPTIMIZATION
   ================================================================ */

/* 1440p Monitor (2560x1440) */
@media (min-width: 2560px) and (max-width: 3839px) {
    :root {
        --base-font-size: 17px;
    }
}

/* 4K TV/Monitor (3840x2160) */
@media (min-width: 3840px) and (max-width: 5119px) {
    :root {
        --base-font-size: 19px;
    }
    
    .container {
        padding: 0.5rem; /* Add padding to prevent edge cutoff */
    }
}

/* Ultra-wide displays (5120px+) */
@media (min-width: 5120px) and (max-width: 7679px) {
    :root {
        --base-font-size: 21px;
    }
    
    .container {
        max-width: 95vw; /* Constrain width on ultra-wide */
        margin: 0 auto;
    }
}

/* 8K displays (7680px+) */
@media (min-width: 7680px) {
    :root {
        --base-font-size: 25px;
    }
    
    .container {
        max-width: 90vw; /* Further constrain for 8K */
        margin: 0 auto;
        padding: 1rem;
    }
}

/* High DPI displays (Retina, etc.) */
@media (min-resolution: 2dppx) {
    :root {
        --base-font-size: calc(var(--base-font-size) * 1.1);
    }
}

/* ================================================================
   ACCESSIBILITY AND REDUCED MOTION
   ================================================================ */

@media (prefers-reduced-motion: reduce) {
    .container {
        transition: none;
    }
    
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ================================================================
   PERFORMANCE OPTIMIZATIONS
   ================================================================ */

/* GPU acceleration for smooth scaling */
.container,
.dashboard,
.left-panel,
.right-panel {
    will-change: transform;
    backface-visibility: hidden;
    transform-style: preserve-3d;
}

/* Optimize rendering during resize */
.responsive-dashboard.resizing * {
    pointer-events: none;
    user-select: none;
}

/* ================================================================
   ENHANCED GRID AND FLEXBOX INTEGRATION
   ================================================================ */

/* Ensure flexbox layouts work with responsive scaling */
.dashboard-split {
    min-height: 0; /* Allow flex items to shrink */
}

.left-panel {
    min-width: 0; /* Prevent overflow */
}

.right-panel {
    min-width: 0; /* Prevent overflow */
    flex: 1;
    max-height: 100%;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* Weekly chart container specific constraints */
.weekly-chart-container {
    flex: 1;
    min-height: 0; /* Allow shrinking */
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* Platform cards - preserve original flex layout */
.platform-cards-row {
    /* Don't override - let original CSS handle this */
}

.stats-cards-grid {
    /* Don't override - let original CSS handle this */
}

/* ================================================================
   UNIFIED HEADER SCALING - Scale entire header bar as one unit
   ================================================================ */

/* Scale the entire header as one unit by 60% total (30% more than previous 1.3) */
.header {
    /* Use CSS transform to scale the entire header uniformly */
    transform: scale(1.69) !important; /* 30% increase from 1.3 = 1.69 */
    transform-origin: top center !important; /* Center the scaling */
    /* Keep original compact sizing but scale it up */
    padding: 0.75rem 2rem !important;
    min-height: 4rem !important;
    /* Adjust positioning to prevent overlap */
    margin-bottom: 2rem !important; /* Increased space for larger scaling */
}

/* Ensure logo maintains its original layout within the scaled header */
.logo {
    /* Keep original styling - scaling will happen at header level */
}

.logo-image {
    max-height: 3rem !important; /* Original size - will be scaled by header */
    width: auto !important;
}

.logo h1 {
    font-size: 1.0rem !important; /* Much smaller text relative to logo */
    margin: 0 !important;
    line-height: 1.1 !important;
}

.logo p {
    font-size: 0.4rem !important; /* Much smaller subtitle relative to logo */
    margin: 0.25rem 0 0 0 !important;
}

/* ================================================================
   ENHANCED TOTAL PLAYERS READABILITY ONLY
   ================================================================ */

/* Make ONLY the main Total Players much larger and more readable */
#total-players-value {
    font-size: clamp(4rem, 8vw, 12rem) !important; /* Much larger, responsive */
    font-weight: 900 !important;
    line-height: 0.9 !important;
    text-shadow: 0 0 20px rgba(255, 255, 255, 0.3) !important;
    letter-spacing: -0.02em !important;
    margin: 1rem 0 !important;
}

/* Make ONLY the Total Players label larger */
.stats-card .stats-label {
    font-size: clamp(1.2rem, 2.5vw, 3rem) !important; /* Larger label */
    font-weight: 700 !important;
    text-transform: uppercase !important;
    letter-spacing: 0.1em !important;
    margin-top: 1rem !important;
}

/* Enhanced icon for total players ONLY */
.stats-card .stats-icon i {
    font-size: clamp(2.5rem, 5vw, 6rem) !important;
    text-shadow: 0 0 15px rgba(148, 138, 103, 0.5) !important;
}

/* Keep platform cards at normal size */
.stat-card__header {
    /* Remove overrides - keep original size */
}

.stat-card__subheader {
    /* Remove overrides - keep original size */
}

/* ================================================================
   MOBILE-FRIENDLY MEDIA QUERIES
   Optimized for phones and tablets with touch interfaces
   ================================================================ */

/* Mobile Portrait (320px - 480px) */
@media (max-width: 480px) {
    .container {
        overflow-y: auto;
        overflow-x: hidden;
        height: auto;
        min-height: 100vh;
    }

    .header {
        transform: scale(1) !important;
        padding: 0.5rem 1rem !important;
        margin-bottom: 0.5rem !important;
    }

    .logo-image {
        max-height: 2rem !important;
    }

    .logo h1 {
        font-size: 0.75rem !important;
    }

    .logo p {
        font-size: 0.5rem !important;
    }

    .dashboard {
        padding: 0.25rem !important;
        margin-top: 0 !important;
        max-height: none !important;
    }

    .dashboard-split {
        display: flex !important;
        flex-direction: column !important;
        gap: 0.5rem !important;
    }

    .left-panel,
    .right-panel {
        width: 100% !important;
        padding: 0.5rem !important;
    }

    .stats-card {
        padding: 0.75rem !important;
    }

    .stats-number {
        font-size: 2rem !important;
    }

    .stats-label {
        font-size: 0.85rem !important;
    }

    .stats-cards-container {
        padding: 0.75rem !important;
        gap: 0.5rem !important;
    }

    .platform-cards-row {
        flex-wrap: wrap !important;
        gap: 0.5rem !important;
    }
    
    .game-stats-row {
        flex-wrap: wrap !important;
        gap: 0.5rem !important;
        grid-template-columns: 1fr !important;
    }

    .stat-card {
        min-width: calc(50% - 0.25rem) !important;
        padding: 0.5rem !important;
        flex: 1 1 calc(50% - 0.25rem) !important;
    }

    .stat-card__header {
        font-size: 1.25rem !important;
    }

    .stat-card__subheader {
        font-size: 0.65rem !important;
    }

    .stat-card__icon {
        font-size: 1.25rem !important;
    }

    .chart-card {
        padding: 0.5rem !important;
        max-height: none !important;
        min-height: 250px !important;
    }

    .chart-header h3 {
        font-size: 1rem !important;
    }

    .graph-tabs {
        gap: 0.25rem !important;
        flex-wrap: wrap !important;
    }

    .graph-tab {
        padding: 0.5rem 0.75rem !important;
        font-size: 0.7rem !important;
        min-width: auto !important;
    }

    .auto-rotate-toggle {
        font-size: 0.7rem !important;
    }

    .toggle-slider {
        width: 32px !important;
        height: 18px !important;
    }

    .toggle-slider:before {
        width: 14px !important;
        height: 14px !important;
    }

    .tactical-progress {
        padding: 0.5rem !important;
        height: 40px !important;
    }

    .loading-text {
        font-size: 0.7rem !important;
    }

    .soldier-container {
        display: none !important;
    }
}

/* Mobile Landscape & Small Tablets (481px - 767px) */
@media (min-width: 481px) and (max-width: 767px) {
    .container {
        overflow-y: auto;
        overflow-x: hidden;
        height: auto;
        min-height: 100vh;
    }

    .header {
        transform: scale(1.2) !important;
        margin-bottom: 1rem !important;
    }

    .dashboard {
        padding: 0.5rem !important;
        max-height: none !important;
        overflow: visible !important;
    }

    .dashboard-split {
        display: flex !important;
        flex-direction: column !important;
        gap: 1rem !important;
        height: auto !important;
    }

    .left-panel,
    .right-panel {
        width: 100% !important;
        height: auto !important;
        overflow: visible !important;
    }

    .right-panel {
        min-height: 400px !important;
        display: flex !important;
        flex-direction: column !important;
    }

    .stats-cards-container {
        height: auto !important;
        overflow: visible !important;
    }

    .platform-cards-row {
        display: grid !important;
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 0.75rem !important;
        flex-wrap: nowrap !important;
    }
    
    .game-stats-row {
        display: grid !important;
        grid-template-columns: 1fr !important;
        gap: 0.75rem !important;
        flex-wrap: nowrap !important;
    }

    .stat-card {
        flex: none !important;
        width: 100% !important;
        min-width: 0 !important;
        height: auto !important;
        min-height: 80px !important;
    }

    .stat-card__header {
        font-size: clamp(1rem, 4vw, 1.4rem) !important;
    }

    .stat-card__subheader {
        font-size: clamp(0.6rem, 2.5vw, 0.85rem) !important;
        white-space: normal !important;
        word-wrap: break-word !important;
        overflow: visible !important;
    }

    .chart-card {
        min-height: 400px !important;
        max-height: 500px !important;
        overflow: hidden !important;
        padding: 0.75rem !important;
        display: flex !important;
        flex-direction: column !important;
    }

    .chart-header {
        flex-shrink: 0 !important;
    }

    .chart-container {
        min-height: 320px !important;
        height: 320px !important;
        flex: 1 !important;
        overflow: hidden !important;
        display: flex !important;
    }

    .grafana-chart {
        width: 100% !important;
        height: 100% !important;
        min-height: 320px !important;
    }

    .graph-tab {
        padding: 0.65rem 1rem !important;
        font-size: 0.8rem !important;
    }

    .soldier-container {
        width: 40px !important;
        height: 60px !important;
    }
}

/* Tablets (768px - 1024px) */
@media (min-width: 768px) and (max-width: 1024px) {
    .container {
        overflow-y: auto;
        height: auto;
        min-height: 100vh;
    }

    .dashboard {
        padding: 0.75rem !important;
        max-height: none !important;
        overflow: visible !important;
    }

    .dashboard-split {
        display: flex !important;
        flex-direction: column !important;
        gap: 1.5rem !important;
        height: auto !important;
    }

    .left-panel,
    .right-panel {
        width: 100% !important;
        max-width: 100% !important;
        height: auto !important;
        overflow: visible !important;
    }

    .right-panel {
        min-height: 500px !important;
        display: flex !important;
        flex-direction: column !important;
    }

    .stats-cards-container {
        height: auto !important;
        overflow: visible !important;
    }

    .platform-cards-row {
        display: grid !important;
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 0.75rem !important;
        width: 100% !important;
    }
    
    .game-stats-row {
        display: grid !important;
        grid-template-columns: 1fr !important;
        gap: 0.75rem !important;
        width: 100% !important;
    }

    .stat-card {
        flex: none !important;
        min-width: 0 !important;
        width: 100% !important;
    }

    .stat-card__header {
        font-size: clamp(1rem, 3vw, 1.5rem) !important;
    }

    .stat-card__subheader {
        font-size: clamp(0.65rem, 2vw, 0.9rem) !important;
        white-space: normal !important;
        word-wrap: break-word !important;
    }

    .chart-card {
        min-height: 450px !important;
        max-height: 600px !important;
        overflow: hidden !important;
        display: flex !important;
        flex-direction: column !important;
    }

    .chart-header {
        flex-shrink: 0 !important;
    }

    .chart-container {
        min-height: 350px !important;
        height: 350px !important;
        flex: 1 !important;
        overflow: hidden !important;
        display: flex !important;
    }

    .grafana-chart {
        width: 100% !important;
        height: 100% !important;
        min-height: 350px !important;
    }
}

/* Touch Device Optimizations */
@media (hover: none) and (pointer: coarse) {
    /* Increase touch targets for better mobile UX */
    .graph-tab {
        min-height: 44px !important;
        padding: 0.75rem 1rem !important;
    }

    .auto-rotate-toggle {
        min-height: 44px !important;
        padding: 0.5rem !important;
    }

    .toggle-slider {
        width: 48px !important;
        height: 26px !important;
    }

    .toggle-slider:before {
        width: 22px !important;
        height: 22px !important;
    }

    .stat-card {
        transition: none !important;
    }

    .chart-card:hover {
        transform: none !important;
    }

    /* Remove hover effects on touch devices */
    .stat-card:hover {
        transform: none !important;
    }

    /* Improve scrolling on mobile */
    .chart-container {
        -webkit-overflow-scrolling: touch !important;
    }
}

/* Landscape mode specific fixes */
@media (max-height: 600px) and (orientation: landscape) {
    .header {
        transform: scale(0.9) !important;
        padding: 0.5rem 1rem !important;
        margin-bottom: 0.5rem !important;
    }

    .dashboard {
        margin-top: 0 !important;
    }

    .tactical-progress {
        display: none !important;
    }

    .stats-card {
        padding: 0.5rem !important;
    }

    .chart-card {
        min-height: 200px !important;
    }
}
.container {
    height: 100vh;
    min-height: 100vh;
    overflow-y: auto;
    overflow-x: hidden;
}

.header {
    transform: scale(clamp(0.8, 0.5 + 0.0005 * 100vh, 1.2));
    padding: clamp(0.3rem, 1vh, 1rem) clamp(0.6rem, 2vw, 2rem);
    margin-bottom: clamp(0, 0.5vh, 1rem);
}

.dashboard {
    max-height: none;
    overflow: visible;
    padding: clamp(0.25rem, 1vw, 1rem);
}

.dashboard-split {
    height: auto;
    min-height: auto;
    gap: clamp(0.5rem, 1.5vw, 2rem);
}

.left-panel, .right-panel {
    height: auto;
    overflow: visible;
}

.left-panel {
    padding: clamp(0.25rem, 1vw, 1rem);
}

.right-panel {
    display: flex;
    flex-direction: column;
    padding: clamp(0.25rem, 1vw, 1rem);
}

.right-panel .chart-card {
    max-height: none;
    height: auto;
    min-height: auto;
    flex-direction: column;
    padding: clamp(0.5rem, 2vw, 1.5rem);
}

.chart-container {
    min-height: clamp(250px, 35vh, 450px);
    height: clamp(300px, 60vh, 700px);
    max-height: min(80vh, 700px);
    overflow: hidden;
    position: relative;
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    padding: 0;
    margin: 0;
}

.chart-container iframe,
.chart-container .grafana-chart {
    width: 100%;
    height: 100%;
    border: none;
    display: block;
    transform: scale(clamp(0.85, 0.8 + 0.00015 * 100vh, 1));
    transform-origin: center center;
}

.stats-card {
    min-height: clamp(70px, 10vh, 100px);
    padding: clamp(0.4rem, 1.5vw, 1rem);
}

.stats-cards-container {
    padding: clamp(0.5rem, 1.5vw, 1.2rem);
}

.stats-section-title h2 {
    font-size: clamp(0.9rem, 2.5vw, 1.4rem);
    margin: clamp(0.25rem, 1vh, 0.5rem) 0;
}

.stat-card__header {
    font-size: clamp(0.9rem, 2.5vw, 1.8rem);
}

.stat-card__subheader {
    font-size: clamp(0.5rem, 1.5vw, 0.9rem);
}

/* ================================================================
   MOBILE DEVICES - Hide graph on phones
   ================================================================ */

@media (max-width: 767px) {
    /* Hide the entire right panel with graph on mobile */
    .right-panel {
        display: none !important;
    }
    
    /* Make left panel full width */
    .dashboard-split {
        grid-template-columns: 1fr !important;
        display: block !important;
    }
    
    .left-panel {
        width: 100% !important;
        max-width: 100% !important;
    }
    
    /* Adjust stats cards for mobile */
    .platform-cards-row {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 0.5rem !important;
    }
    
    .game-stats-row {
        grid-template-columns: 1fr !important;
        gap: 0.5rem !important;
    }
    
    .stat-card {
        min-width: 0 !important;
    }
    
    /* Show mobile message where graph would be */
    .right-panel::before {
        content: 'Graph view not available on mobile devices';
        display: block;
        text-align: center;
        padding: 2rem;
        color: rgba(148, 138, 103, 0.6);
        font-size: 0.9rem;
        text-transform: uppercase;
        letter-spacing: 1px;
    }
}

/* Small tablets - show graph but compact */
@media (min-width: 768px) and (max-width: 1024px) {
    .dashboard-split {
        display: flex;
        flex-direction: column;
        gap: 1rem;
    }
    
    .left-panel,
    .right-panel {
        width: 100%;
    }
    
    .platform-cards-row {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .game-stats-row {
        grid-template-columns: 1fr;
    }
}

@media (max-height: 500px) {
    .header {
        transform: scale(0.7);
        margin-bottom: 0;
    }
    
    .stats-card {
        min-height: 60px;
        padding: 0.3rem;
    }
    
    .chart-container {
        height: clamp(200px, 50vh, 300px);
        min-height: 200px;
    }
    
    .game-stats-section {
        display: none;
    }
    
    .tactical-progress {
        display: none;
    }
}

/* Portrait tablets and larger phones in landscape */
@media (min-width: 768px) and (max-width: 1024px) and (orientation: landscape) {
    .chart-container {
        height: clamp(250px, 55vh, 400px);
    }
}
