/* fuelprices.php */

:root {
    color-scheme: light;
    --background: #f4f6f8;
    --surface: #ffffff;
    --text: #17202a;
    --muted: #68737d;
    --border: #e1e6eb;
    --header: #17202a;
    --accent: #17202a;
    --cheapest: #dcfce7;
    --cheapest-text: #166534;
    --error: #fee2e2;
    --error-text: #991b1b;
    --success: #dcfce7;
    --success-text: #166534;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--background);
    color: var(--text);
    font-family:
        Inter, ui-sans-serif, system-ui, -apple-system,
        BlinkMacSystemFont, "Segoe UI", sans-serif;
    line-height: 1.5;
}

.container {
    width: min(100% - 32px, 1200px);
    margin: 42px auto;
}

.page-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 22px;
}

h1 {
    margin: 0;
    font-size: clamp(28px, 5vw, 38px);
    letter-spacing: -0.03em;
}

.station-logo {
    display: block;
    max-width: 80px;
    max-height: 32px;
    width: auto;
    height: auto;
    margin-bottom: 4px;
}

.page-header p {
    margin: 4px 0 0;
    color: var(--muted);
}

.updated {
    color: var(--muted);
    font-size: 14px;
    white-space: nowrap;
}

/* Postcode search */

.search {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 18px;
}

.search label {
    font-size: 14px;
    font-weight: 600;
}

.search input {
    width: 7ch;
    min-width: 96px;
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: 9px;
    background: var(--surface);
    color: var(--text);
    font: inherit;
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.08em;
}

.search input:focus {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
}

.search button {
    padding: 9px 16px;
    border: 0;
    border-radius: 9px;
    background: var(--accent);
    color: #fff;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
}

.search button:hover {
    opacity: 0.88;
}

.search-status {
    color: var(--muted);
    font-size: 13px;
}

/* Table */

.table-wrap {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.05);
    overflow: visible;
}

.table-scroll {
    overflow-x: auto;
    overflow-y: visible;
    border-radius: 11px;
}

.fuel-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

.fuel-table th,
.fuel-table td {
    padding: 14px 16px;
    text-align: left;
    vertical-align: top;
    border-bottom: 1px solid var(--border);
}

.fuel-table th {
    background: var(--header);
    color: #fff;
    font-size: 13px;
    font-weight: 650;
    letter-spacing: 0.02em;
    white-space: nowrap;
}

/* Floating table header created by JS */
.fuel-table-floating-header {
    position: fixed;
    top: 0;
    z-index: 1000;
    display: none;
    overflow: hidden;
    background: var(--header);
    border-bottom: 1px solid var(--border);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}

.fuel-table-floating-header table {
    border-collapse: separate;
    border-spacing: 0;
    table-layout: fixed;
    margin: 0;
}

/* Sticky first column */

.fuel-table th:first-child,
.fuel-table td.station {
    position: sticky;
    left: 0;
}

/* First-column body cells */

.fuel-table td.station {
    z-index: 5;
    background: var(--surface);
    min-width: 150px;
}

.fuel-table tbody tr:last-child td {
    border-bottom: 0;
}

.fuel-table td small {
    display: block;
    margin-top: 2px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 400;
}

.fuel-table td.price {
    white-space: nowrap;
    font-weight: 750;
    font-variant-numeric: tabular-nums;
}

.fuel-table td.price small {
    font-weight: 400;
}

.fuel-table td.none {
    color: #b4bcc4;
}

.fuel-table .col-updated {
    color: var(--muted);
    font-size: 13px;
    white-space: nowrap;
}

.fuel-table th.col-updated {
    color: #fff;
}

.fuel-table tbody tr:hover td:not(.cheapest) {
    background: #f8fafc;
}

/* Cheapest price in its column */

.fuel-table td.cheapest {
    background: var(--cheapest);
    color: var(--cheapest-text);
}

.fuel-table td.cheapest small {
    color: var(--cheapest-text);
    opacity: 0.8;
}

/* Notices */

.notice {
    margin-bottom: 18px;
    padding: 12px 15px;
    border-radius: 9px;
    font-weight: 600;
}

.notice.success {
    background: var(--success);
    color: var(--success-text);
}

.notice.error,
.errors {
    background: var(--error);
    color: var(--error-text);
}

.errors {
    margin-bottom: 18px;
    padding: 12px 15px;
    border-radius: 9px;
}

.empty {
    padding: 28px 16px;
    text-align: center;
    color: var(--muted);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
}

.note {
    margin: 13px 2px 0;
    color: var(--muted);
    font-size: 13px;
}

/* Mobile */

@media (max-width: 650px) {
    .container {
        width: min(100% - 18px, 1200px);
        margin: 22px auto;
    }

    .page-header {
        align-items: flex-start;
        flex-direction: column;
        gap: 4px;
    }

    .updated {
        font-size: 12px;
    }

    .fuel-table th,
    .fuel-table td {
        padding: 11px 9px;
        font-size: 13px;
    }

    .fuel-table td.station {
        min-width: 120px;
    }
}