body {
    font-family: Arial, sans-serif;
    margin: 20px;
}

.controls {
    margin-bottom: 15px;
}

table {
    border-collapse: collapse;
    width: 100%;
}

th, td {
    border: 1px solid #ccc;
    padding: 5px;
    text-align: right;
}

th:first-child,
td:first-child {
    text-align: center;
    font-weight: bold;
}

/* Highlighted row and column */
td, th {
    position: relative;
    transition: background 0.2s;
}

/* HOVER EFFECTS (ONLY ROW + COLUMN HEADERS) */

/* Highlight column header when hovering a cell */
td:hover {
    /* Find corresponding column header */
}
th.hovered {
    background-color: rgba(255, 255, 153, 0.3); /* light pale yellow */
    cursor: default;
}

/* Highlight row header (first cell in row) */
td:first-child.hovered {
    background-color: rgba(255, 255, 153, 0.3); /* light pale yellow */
    cursor: default;
}

/* Remove any diagonal overlay or intersection effect */
td.hovered.intersection::after {
    content: none;
}

thead {
    background: #f2f2f2;
}

tfoot td {
    font-weight: bold;
    background-color: #d0d0d0; /* darker footer */
}

.record-high {
    background-color: #fdd; /* pale red */
}

.record-low {
    background-color: #ddf; /* pale blue */
}

.hovered {
    background-color: #ffffcc !important; /* pale yellow only for non-highlighted cells */
    cursor: default;
}

.table-container {
    max-height: 600px; /* adjust as needed */
    overflow: auto;
    border: 1px solid #ccc;
}

/* Sticky header */
thead th {
    position: sticky;
    top: 0;
    background: #f2f2f2;
    z-index: 3;
}

/* Sticky first column (optional) */
th:first-child,
td:first-child {
    position: sticky;
    left: 0;
    background: #f2f2f2;
    z-index: 2;
}

/* Top-left cell ("Day") fix */
thead th:first-child {
    z-index: 4; /* highest so it stays above both header row & first column */
}

.legend {
    margin-top: 15px;
    font-size: 0.9em;
}

.legend span {
    display: inline-block;
    padding: 3px 8px;
    margin-right: 10px;
    border-radius: 3px;
    color: #000;
    font-weight: bold;
}

/* Matching the table highlight colors */
.legend .record-high {
    background-color: #fdd;
}

.legend .record-low {
    background-color: #ddf;
}

.legend .hovered {
    background-color: #ffff99;
}

.legend .intersection {
    background-color: #ffffcc;
    background-image: repeating-linear-gradient(
        45deg,
        rgba(255, 165, 0, 0.25),
        rgba(255, 165, 0, 0.25) 4px,
        transparent 4px,
        transparent 8px
    );
}

/* =========================
   DAILY STATS TABLE WRAPPING HEADERS
   ========================= */

/* Header short labels wrap */
#dailyStatsTable th .th-label {
    display: inline;
    white-space: normal;       /* allow wrapping */
    word-break: break-word;    /* wrap long words */
    text-align: center;        /* center headers */
    line-height: 1.2em;
    max-width: 120px;          /* adjust to preference */
}

/* Make table auto-fit content but allow scrolling horizontally */
#dailyStatsTable {
    table-layout: auto;       /* columns adjust based on content */
    width: auto;              /* allow horizontal scroll */
	border-collapse: collapse;
	border-spacing: 0;
}

/* Optional: table container for vertical + horizontal scrolling */
#dailyStatsTableContainer {
    max-height: 600px;        /* adjust as needed */
    overflow: auto;
	border-collapse: collapse;
    border: 1px solid #ccc;
}

/* Ensure first column (date) is sticky and wide enough */
#dailyStatsTable th:first-child,
#dailyStatsTable td:first-child {
    min-width: 100px;
}

/* Other header columns min width */
#dailyStatsTable th:not(:first-child) {
    min-width: 60px;
}

/* Sticky footer */
#dailyStatsTable tfoot td {
    position: sticky;
    bottom: 0;
    background: #f3f3f3;
	box-shadow: 0 -1px 0 #ccc;
    z-index: 12;
}

#dailyStatsTable tfoot tr {
    position: sticky;
    bottom: -1px;
    background: #f3f3f3;
    z-index: 30;
}

/* =========================
   NUMBERS + UNITS
   ========================= */

/* Ensure numbers and units stay on the same line */
#dailyStatsTable td span {
    display: inline;           /* keep units inline with number */
    vertical-align: text-bottom;
    font-size: 0.7em;          /* optional smaller size for units */
    margin-left: 2px;           /* small gap between number and unit */
    white-space: nowrap;        /* prevent wrapping units to next line */
}

/* =========================
   CENTER HEADINGS
   ========================= */

/* Center the short labels inside th */
#dailyStatsTable th {
    text-align: center;      /* center header text */
    vertical-align: middle;  /* vertical alignment */
}

/* =========================
   DAILY STATS SEARCH BOX WITH INSIDE CLEAR BUTTON
   ========================= */

/* Base search input */
#dailyStatsTableContainer + .controls input#dailySearch,
#dailySearch {
    width: 400px;        /* adjust as needed */
    max-width: 90%;      /* ensures it doesn’t overflow on smaller screens */
    padding: 5px 28px 5px 8px; /* right padding for the X inside */
    font-size: 0.95em;   /* optional, matches table text size */
    box-sizing: border-box;
}

/* Wrapper is needed for absolute positioning inside input */
.search-wrapper {
    position: relative;
    display: inline-block;
}

/* Clear button inside input */
.clear-search {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    cursor: pointer;
    font-size: 1em;
    color: #888;
    display: none;       /* hidden by default */
    user-select: none;
    z-index: 2;
}

/* Show X only when input has text */
.search-wrapper input#dailySearch:not(:placeholder-shown) ~ .clear-search {
    display: inline;
}

/* Hover effect for X */
.search-wrapper .clear-search:hover {
    color: #000;
}

/* Sort indicator arrow */
#dailyStatsTable thead th .sort-indicator {
    font-size: 0.75em;
    opacity: 0.7;
    margin-left: 4px;
    white-space: nowrap;
    display: inline-block;
    vertical-align: middle;
}
