/* Statistics Page Styling */

.stats-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
    min-width: 0;
    width: 100%;
    box-sizing: border-box;
}

.stats-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 30px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
}

.stats-header h1 {
    margin: 0;
    color: #fff;
    font-size: 24px;
    font-weight: 500;
}

.stats-header .update-time {
    color: #e0e0e0;
    font-size: 12px;
    margin-top: 8px;
}

.stats-header .strike-count {
    color: #ffd700;
    font-weight: bold;
    font-size: 18px;
}

/* Summary Cards */
.stats-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin-bottom: 30px;
}

.summary-card {
    background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    text-align: center;
}

.summary-card .label {
    color: #b0b0b0;
    font-size: 12px;
    text-transform: uppercase;
    margin-bottom: 8px;
}

.summary-card .value {
    color: #fff;
    font-size: 28px;
    font-weight: bold;
}

.summary-card .subvalue {
    color: #90caf9;
    font-size: 14px;
    margin-top: 4px;
}

/* Enhanced Table Styling */
.stats-table-container {
    background: #1a1a1a;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 30px;
    overflow-x: auto;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
    max-width: 100%;
    box-sizing: border-box;
}

.stats-table-title {
    color: #fff;
    font-size: 18px;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 2px solid #667eea;
}

.stats-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.stats-table th {
    background: linear-gradient(180deg, #2d2d2d 0%, #1f1f1f 100%);
    color: #e0e0e0;
    padding: 12px 8px;
    text-align: center;
    font-weight: 500;
    border-bottom: 2px solid #667eea;
    position: sticky;
    top: 0;
    z-index: 10;
}

.stats-table td {
    padding: 10px 8px;
    text-align: center;
    border-bottom: 1px solid #333;
    color: #d0d0d0;
}

.stats-table tr:hover {
    background: #252525;
}

.stats-table .station-name {
    font-weight: 500;
    color: #90caf9;
    text-align: left;
}

.stats-table .station-online {
    color: #4caf50;
}

.stats-table .station-offline {
    color: #f44336;
}

/* Efficiency Indicators */
.efficiency-cell {
    position: relative;
    padding: 4px !important;
}

.efficiency-bar {
    height: 20px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: bold;
    color: #fff;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
    min-width: 40px;
    margin: 0 auto;
    line-height: 20px;
}

.efficiency-bar.excellent {
    background: linear-gradient(90deg, #4caf50 0%, #66bb6a 100%);
}

.efficiency-bar.good {
    background: linear-gradient(90deg, #8bc34a 0%, #9ccc65 100%);
}

.efficiency-bar.fair {
    background: linear-gradient(90deg, #2196f3 0%, #42a5f5 100%);
}

.efficiency-bar.poor {
    background: linear-gradient(90deg, #ff9800 0%, #ffa726 100%);
}

.efficiency-bar.very-poor {
    background: linear-gradient(90deg, #f44336 0%, #ef5350 100%);
}

.efficiency-bar.no-data {
    background: linear-gradient(90deg, #616161 0%, #757575 100%);
    color: #bbb;
}

/* Chart Section */
.chart-container {
    background: #1a1a1a;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 30px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
}

.chart-title {
    color: #fff;
    font-size: 18px;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 2px solid #667eea;
}

.bar-chart {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.bar-chart-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.bar-chart-label {
    min-width: 100px;
    color: #90caf9;
    font-size: 13px;
    font-weight: 500;
}

.bar-chart-bar-container {
    flex: 1;
    background: #2d2d2d;
    border-radius: 4px;
    height: 30px;
    position: relative;
    overflow: hidden;
}

.bar-chart-bar {
    height: 100%;
    border-radius: 4px;
    background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding-right: 8px;
    transition: width 0.5s ease;
}

.bar-chart-value {
    color: #fff;
    font-size: 12px;
    font-weight: bold;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

/* Distance Comparison Grid */
.distance-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 15px;
    margin-bottom: 30px;
}

.distance-card {
    background: #1a1a1a;
    border-radius: 8px;
    padding: 15px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.distance-card-header {
    color: #667eea;
    font-size: 16px;
    font-weight: 500;
    margin-bottom: 12px;
    text-align: center;
}

.distance-metric {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid #2d2d2d;
}

.distance-metric:last-child {
    border-bottom: none;
}

.distance-metric .label {
    color: #b0b0b0;
    font-size: 12px;
}

.distance-metric .value {
    color: #fff;
    font-size: 14px;
    font-weight: 500;
}

/* Legend */
.efficiency-legend {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin: 20px 0;
    padding: 15px;
    background: #1a1a1a;
    border-radius: 8px;
    flex-wrap: wrap;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
}

.legend-color {
    width: 30px;
    height: 16px;
    border-radius: 3px;
}

.legend-label {
    color: #d0d0d0;
}

/* Coordinates styling */
.coords {
    font-family: 'Roboto Mono', monospace;
    font-size: 12px;
    color: #9e9e9e;
    text-align: left !important;
}

.coords-header {
    text-align: left !important;
}

/* TOA ratio styling */
.toa-ratio {
    font-size: 12px;
    color: #b0b0b0;
}

/* Responsive Design */
@media (max-width: 768px) {
    /* Override any parent min-width constraints */
    body {
        min-width: 0 !important;
    }

    .stats-container {
        padding: 10px;
        min-width: 0 !important;
        max-width: 100vw;
        width: 100%;
        overflow-x: hidden;
        box-sizing: border-box;
    }

    .stats-container > * {
        max-width: 100%;
        box-sizing: border-box;
    }

    .stats-header {
        padding: 15px;
        max-width: 100%;
        box-sizing: border-box;
    }

    .stats-header h1 {
        font-size: 18px;
        word-wrap: break-word;
    }

    .update-time {
        font-size: 11px;
        word-wrap: break-word;
    }

    .stats-summary {
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }

    .summary-card {
        padding: 12px;
    }

    .summary-card .value {
        font-size: 20px;
    }

    .unit-toggle-container {
        flex-direction: column;
        align-items: stretch;
    }

    .unit-toggle-left,
    .unit-toggle-right {
        width: 100%;
        justify-content: center;
    }

    .unit-toggle {
        width: 100%;
        justify-content: center;
    }

    .disclaimer-content {
        padding: 15px;
    }

    .efficiency-legend {
        gap: 10px;
        padding: 10px;
        max-width: 100%;
        box-sizing: border-box;
        justify-content: flex-start;
    }

    .legend-item {
        font-size: 11px;
    }

    .distance-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .chart-container,
    .stats-table-container {
        padding: 15px;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        max-width: 100%;
        box-sizing: border-box;
    }

    .stats-table-container {
        margin-left: 0;
        margin-right: 0;
        border-radius: 8px;
        width: 100%;
    }

    .stats-table {
        font-size: 10px;
        min-width: 800px;
        display: block;
        overflow-x: auto;
    }

    .stats-table thead,
    .stats-table tbody {
        display: table;
        width: 100%;
    }

    .stats-table th,
    .stats-table td {
        padding: 6px 3px;
        white-space: nowrap;
    }

    .station-name {
        min-width: 80px;
    }

    .coords {
        font-size: 10px;
        min-width: 90px;
    }

    .efficiency-bar {
        font-size: 9px;
        min-width: 35px;
    }

    .toa-ratio {
        font-size: 10px;
    }

    .station-flag {
        font-size: 14px;
        margin-right: 4px;
    }

    .bar-chart-label {
        min-width: 60px;
        font-size: 11px;
    }

    .tooltip .tooltiptext {
        width: 240px;
        margin-left: -120px;
        font-size: 11px;
    }
}

@media (max-width: 480px) {
    .stats-summary {
        grid-template-columns: 1fr;
    }

    .stats-header h1 {
        font-size: 16px;
    }

    .summary-card .value {
        font-size: 18px;
    }
}

/* Loading Animation */
@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

.loading {
    animation: pulse 1.5s ease-in-out infinite;
}

/* Online/Offline Status Indicator */
.status-indicator {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 5px;
}

.status-indicator.online {
    background: #4caf50;
    box-shadow: 0 0 6px #4caf50;
}

.status-indicator.offline {
    background: #f44336;
    box-shadow: 0 0 6px #f44336;
}

/* Tooltip */
.tooltip {
    position: relative;
    display: inline-block;
    cursor: help;
    border-bottom: 1px dotted #90caf9;
}

.tooltip .tooltiptext {
    visibility: hidden;
    width: 280px;
    background-color: #2a2a2a;
    color: #e0e0e0;
    text-align: left;
    border-radius: 6px;
    padding: 12px;
    position: absolute;
    z-index: 1000;
    bottom: 125%;
    left: 50%;
    margin-left: -140px;
    opacity: 0;
    transition: opacity 0.3s;
    font-size: 12px;
    line-height: 1.5;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.5);
    border: 1px solid #667eea;
    text-transform: none;
}

.tooltip .tooltiptext::after {
    content: "";
    position: absolute;
    top: 100%;
    left: 50%;
    margin-left: -5px;
    border-width: 5px;
    border-style: solid;
    border-color: #667eea transparent transparent transparent;
}

.tooltip:hover .tooltiptext {
    visibility: visible;
    opacity: 1;
}

/* Flag Styling */
.station-flag {
    font-size: 16px;
    margin-right: 6px;
    display: inline-block;
    vertical-align: middle;
}

/* Sortable Table */
.sortable {
    cursor: pointer;
    user-select: none;
    position: relative;
    padding-right: 20px !important;
}

.sortable::after {
    content: ' ⇅';
    position: absolute;
    right: 5px;
    color: #888;
    font-size: 10px;
}

.sortable.asc::after {
    content: ' ▲';
    color: #90caf9;
}

.sortable.desc::after {
    content: ' ▼';
    color: #90caf9;
}

.sortable:hover {
    background: #353535 !important;
}

/* Unit and Region Toggle Buttons */
.unit-toggle-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 15px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.unit-toggle-left {
    display: flex;
    gap: 15px;
    align-items: center;
}

.unit-toggle-right {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
}

.unit-toggle {
    background: #2a2a2a;
    border-radius: 20px;
    padding: 4px;
    display: inline-flex;
    gap: 4px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.unit-toggle-btn {
    padding: 6px 16px;
    border: none;
    background: transparent;
    color: #b0b0b0;
    border-radius: 16px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.3s ease;
}

.unit-toggle-btn:hover {
    color: #e0e0e0;
}

.unit-toggle-btn.active {
    background: #667eea;
    color: #fff;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* Disclaimer Button and Content */
.disclaimer-btn {
    padding: 6px 16px;
    border: 1px solid #667eea;
    background: transparent;
    color: #90caf9;
    border-radius: 16px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.3s ease;
}

.disclaimer-btn:hover {
    background: rgba(102, 126, 234, 0.1);
    color: #b3d4fc;
}

.disclaimer-btn.active {
    background: #667eea;
    color: #fff;
}

.disclaimer-content {
    display: none;
    background: #1a1a1a;
    border-left: 4px solid #667eea;
    padding: 20px;
    margin-bottom: 20px;
    border-radius: 4px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.disclaimer-content.show {
    display: block;
}

.disclaimer-content h3 {
    color: #667eea;
    margin: 0 0 15px 0;
    font-size: 18px;
    font-weight: 500;
}

.disclaimer-content p {
    color: #d0d0d0;
    line-height: 1.6;
    margin: 0 0 12px 0;
}

.disclaimer-content p:last-child {
    margin-bottom: 0;
}

.disclaimer-content strong {
    color: #90caf9;
}

/* Efficiency Legend Adjustments */
.efficiency-legend {
    background: #1a1a1a;
}

.legend-color.excellent {
    background: linear-gradient(90deg, #4caf50 0%, #66bb6a 100%);
}

.legend-color.good {
    background: linear-gradient(90deg, #8bc34a 0%, #9ccc65 100%);
}

.legend-color.fair {
    background: linear-gradient(90deg, #2196f3 0%, #42a5f5 100%);
}

.legend-color.poor {
    background: linear-gradient(90deg, #ff9800 0%, #ffa726 100%);
}

.legend-color.very-poor {
    background: linear-gradient(90deg, #f44336 0%, #ef5350 100%);
}

.legend-color.no-data {
    background: linear-gradient(90deg, #6a6a6a 0%, #7a7a7a 100%);
}
