/* assets/css/history.css */

/* =========================================
   CONTROLS & FILTERS
   ========================================= */
.controls-group { 
    display: flex; 
    align-items: center; 
    gap: 12px; 
    flex-wrap: wrap; 
}

/* Button Styling (Cal Switcher, Range Switcher, and Heatmap Tabs) */
.cal-switcher button, 
.switcher button, 
.tab-btn { 
    background: var(--bg-card); 
    color: var(--text-main); 
    border: 1px solid var(--border-color); 
    padding: 10px 16px; 
    cursor: pointer; 
    font-size: 14px; 
    transition: 0.2s; 
    font-weight: 500; 
    font-family: inherit;
}

.cal-switcher button:first-child { border-radius: 6px 0 0 6px; border-right: none; }
.cal-switcher button:last-child { border-radius: 0 6px 6px 0; }
.switcher button, .tab-btn { border-radius: 6px; }

.cal-switcher button:hover, 
.switcher button:hover, 
.tab-btn:hover { 
    background: var(--hover-bg); 
}

.cal-switcher button.active, 
.switcher button.active, 
.tab-btn.active { 
    background: var(--text-main); 
    color: var(--bg-card); 
    border-color: var(--text-main); 
}

/* Form Elements */
.date-input, #month-select {
    background: var(--bg-card);
    color: var(--text-main);
    border: 1px solid var(--border-color);
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 13px;
    outline: none;
    cursor: pointer;
    font-family: inherit;
}

/* Table Navigation (Filter/Reset) */
.table-nav-btn { 
    background: var(--bg-card); 
    color: var(--text-main); 
    border: 1px solid var(--border-color); 
    padding: 8px 16px; 
    border-radius: 6px; 
    cursor: pointer; 
    font-size: 13px; 
    font-weight: 600; 
}
.table-nav-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* =========================================
   CHART CONTAINER
   ========================================= */
#chart-container { width: 100%; height: 500px; position: relative; }

/* =========================================
   HEATMAP STYLING (The Fix for your Screenshot)
   ========================================= */
.heatmap-container { 
    overflow-x: auto; 
    margin-top: 15px; 
    border: 1px solid var(--border-color);
    border-radius: 8px;
}

table.heatmap { 
    width: 100%; 
    border-collapse: separate; /* Required for sticky headers to show borders */
    border-spacing: 0; 
    font-size: 13px; 
    white-space: nowrap; 
}

table.heatmap th, table.heatmap td { 
    padding: 12px 10px; 
    text-align: center; 
    border-bottom: 1px solid var(--border-color); 
    border-right: 1px solid var(--border-color); 
    color: var(--text-main); 
}

/* Sticky Header Row */
table.heatmap th { 
    background: var(--bg-card); 
    position: sticky; 
    top: 0; 
    z-index: 10; 
    font-weight: 600; 
    color: var(--text-muted); 
    border-bottom: 2px solid var(--border-color);
}

/* Sticky Year Column (Left) */
table.heatmap td:first-child, table.heatmap th:first-child { 
    position: sticky; 
    left: 0; 
    background: var(--bg-card); 
    z-index: 20; 
    border-right: 2px solid var(--border-color); 
    font-weight: bold; 
    text-align: left; 
    padding-left: 15px; 
}

/* Performance Colors */
table.heatmap td.cell-up { 
    background-color: var(--hm-up-bg) !important; 
    color: var(--hm-up-txt) !important; 
}
table.heatmap td.cell-down { 
    background-color: var(--hm-down-bg) !important; 
    color: var(--hm-down-txt) !important; 
}
table.heatmap td.cell-flat { 
    background-color: transparent; 
    color: var(--text-muted); 
}

/* Stats Row (Avg, Med, Up, Down) */
.stat-row td { 
    font-weight: bold; 
    background: var(--hover-bg); 
    border-top: 2px solid var(--border-color); 
}

/* =========================================
   HISTORICAL LOG TABLE
   ========================================= */
.table-container { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.data-table th, .data-table td { padding: 12px 15px; border-bottom: 1px solid var(--border-color); text-align: right; }
.data-table th { background: var(--hover-bg); color: var(--text-muted); font-weight: 600; }

.data-table th:first-child, .data-table td:first-child { text-align: left; font-family: monospace; }
.data-table td:nth-child(2) { font-weight: bold; color: var(--text-main); }

.table-footer { 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    margin-top: 20px; 
    padding-top: 15px; 
    border-top: 1px solid var(--border-color); 
}

@media (max-width: 768px) {
    #chart-container { height: 350px; }
    .date-input { width: 100%; }
}

/* Summary Blocks Grid */
.summary-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin: 20px 0;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    padding: 20px;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.05);
}

.stat-label {
    font-size: 13px;
    color: var(--text-muted);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-value {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-main);
}

.stat-delta {
    font-size: 13px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 4px;
}

/* Chart Legend (Crosshair Tooltip) */
.chart-legend {
    position: absolute;
    left: 12px;
    top: 12px;
    z-index: 10;
    font-size: 14px;
    line-height: 1.6;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: rgba(0, 0, 0, 0.75);
    color: #ffffff;
    padding: 8px 12px;
    border-radius: 6px;
    pointer-events: none;
    display: none;
}

[data-theme="light"] .chart-legend {
    background: rgba(255, 255, 255, 0.95);
    color: #333333;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}