/* Custom styles for Steam Stats Tracker */

body {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

main {
    flex: 1;
}

.card {
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    transition: box-shadow 0.3s ease;
}

.card:hover {
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

.navbar-brand {
    font-weight: bold;
}

.badge {
    font-size: 0.9em;
}

.table-responsive {
    max-height: none;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* Prevent horizontal scroll on mobile when not needed */
@media (max-width: 576px) {
    .table-responsive {
        margin: 0 -0.75rem;
        padding: 0 0.75rem;
    }
    
    .table td, .table th {
        padding: 0.5rem 0.4rem;
        font-size: 0.875rem;
    }
}

/* Chart container for responsive sizing */
.chart-container {
    position: relative;
    width: 100%;
    min-height: 300px;
    max-height: 500px;
}

/* Mobile-first responsive chart sizing */
@media (max-width: 576px) {
    .chart-container {
        min-height: 250px;
        max-height: 350px;
    }
    
    /* Improve card spacing on mobile */
    .card-body {
        padding: 0.75rem;
    }
    
    /* Stats cards responsive */
    .col-md-2, .col-md-3 {
        margin-bottom: 0.5rem;
    }
}

@media (min-width: 577px) and (max-width: 768px) {
    .chart-container {
        min-height: 280px;
        max-height: 400px;
    }
}

@media (min-width: 769px) {
    .chart-container {
        min-height: 300px;
        max-height: 500px;
    }
}

/* Ensure canvas fills container */
.chart-container canvas {
    width: 100% !important;
    height: 100% !important;
}

/* Mobile-friendly touch targets */
@media (max-width: 576px) {
    .btn {
        min-height: 38px;
        padding: 0.375rem 0.75rem;
    }
    
    .btn-sm {
        min-height: 32px;
    }
    
    /* Better navbar on mobile */
    .navbar-brand {
        font-size: 1rem;
    }
    
    /* Page title sizing */
    h1 {
        font-size: 1.5rem;
    }
    
    /* Footer spacing */
    footer {
        padding: 0.75rem 0;
    }
    
    footer p {
        font-size: 0.875rem;
    }
}

/* Ensure game cards in publisher view are responsive */
@media (max-width: 576px) {
    .col-md-4.mb-3 {
        padding-left: 0.5rem;
        padding-right: 0.5rem;
    }
}

/* Period picker buttons */
.period-picker {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    margin-bottom: 0.75rem;
}

.period-picker .btn {
    padding: 0.25rem 0.5rem;
    font-size: 0.8rem;
    border-radius: 4px;
}

.period-picker .btn.active {
    background-color: #0d6efd;
    color: white;
    border-color: #0d6efd;
}

/* Date range display */
.date-range-display {
    font-size: 0.85rem;
    color: #6c757d;
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

@media (max-width: 576px) {
    .date-range-display {
        width: 100%;
        margin-top: 0.5rem;
        justify-content: center;
    }
}

/* Range navigator (mini chart with selection) */
.range-navigator {
    position: relative;
    height: 60px;
    margin-top: 0.75rem;
    border-top: 1px solid #dee2e6;
    padding-top: 0.5rem;
}

.range-navigator-chart {
    position: absolute;
    top: 8px;
    left: 0;
    right: 0;
    height: 50px;
}

.range-navigator-chart canvas {
    width: 100% !important;
    height: 50px !important;
}

/* Selection overlay */
.range-selection-overlay {
    position: absolute;
    top: 8px;
    left: 0;
    right: 0;
    height: 50px;
    pointer-events: none;
}

.range-selection-mask-left,
.range-selection-mask-right {
    position: absolute;
    top: 0;
    height: 100%;
    background: rgba(255, 255, 255, 0.75);
    pointer-events: auto;
}

.range-selection-mask-left {
    left: 0;
}

.range-selection-mask-right {
    right: 0;
}

.range-selection-window {
    position: absolute;
    top: 0;
    height: 100%;
    border: 2px solid #1a73e8;
    border-radius: 3px;
    background: transparent;
    cursor: grab;
    pointer-events: auto;
    box-sizing: border-box;
}

.range-selection-window:active {
    cursor: grabbing;
}

.range-selection-handle {
    position: absolute;
    top: 0;
    width: 8px;
    height: 100%;
    background: #1a73e8;
    cursor: ew-resize;
    pointer-events: auto;
}

.range-selection-handle-left {
    left: -2px;
    border-radius: 3px 0 0 3px;
}

.range-selection-handle-right {
    right: -2px;
    border-radius: 0 3px 3px 0;
}

.range-selection-handle::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 2px;
    height: 16px;
    background: rgba(255, 255, 255, 0.8);
    border-radius: 1px;
}

/* Date labels below navigator */
.range-navigator-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.7rem;
    color: #6c757d;
    margin-top: 2px;
    padding: 0 2px;
}

@media (max-width: 576px) {
    .range-navigator {
        height: 50px;
    }
    
    .range-navigator-chart,
    .range-selection-overlay {
        height: 40px;
    }
    
    .range-navigator-chart canvas {
        height: 40px !important;
    }
    
    .range-navigator-labels {
        font-size: 0.65rem;
    }
}

/* Chart header with controls */
.chart-header {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid rgba(0,0,0,0.125);
    background: #f8f9fa;
}

.chart-header h5 {
    margin: 0;
    font-size: 1rem;
}

@media (max-width: 576px) {
    .chart-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
    
    .period-picker {
        width: 100%;
    }
    
    .period-picker .btn {
        flex: 1;
        min-width: 40px;
    }
}


/* Chart containers.
   Chart.js is configured with maintainAspectRatio:false so charts fill their
   parent. That REQUIRES the parent to have an explicit height - a height
   attribute on the canvas itself sends it into a growth loop (observed at
   7812px tall with zero width, drawing an empty axis). */
.chart-box {
    position: relative;
    height: 340px;
    width: 100%;
}
.chart-box-tall {
    height: 460px;
}
@media (max-width: 768px) {
    .chart-box { height: 260px; }
    .chart-box-tall { height: 320px; }
}
