/* ParkingCloud console
   The shell, the light/dark theme, buttons, forms and motion come from ps-theme.css, the same file the
   ParkingSolution BackOffice uses. This file only styles the console's own building blocks with the
   theme's tokens (--ps-*), so every page follows light and dark without page-specific rules. */

:root,
[data-bs-theme="light"] {
    --pl-ink: var(--ps-text);
    --pl-ink-soft: var(--ps-muted);
    --pl-line: var(--ps-border);
    --pl-surface: var(--ps-surface);
    --pl-canvas: var(--ps-surface-2);
    --pl-accent: var(--ps-accent);
    --pl-accent-soft: var(--ps-accent-soft);
    --pl-ok: #18864b;
    --pl-ok-soft: rgba(38, 176, 80, .12);
    --pl-amber: #a2560c;
    --pl-amber-soft: rgba(245, 166, 35, .14);
    --pl-red: #b42318;
    --pl-red-soft: rgba(229, 72, 77, .12);
    --pl-gap: 1.5rem;
}

[data-bs-theme="dark"] {
    --pl-ok: #4ade80;
    --pl-ok-soft: rgba(74, 222, 128, .12);
    --pl-amber: #ffc857;
    --pl-amber-soft: rgba(255, 200, 87, .12);
    --pl-red: #ff7b72;
    --pl-red-soft: rgba(255, 123, 114, .12);
}

body {
    font-size: 15px;
    line-height: 1.55;
}

h1 {
    font-size: 1.55rem;
    font-weight: 650;
    margin: 0;
    letter-spacing: -.02em;
}

h2 {
    font-size: 1rem;
    font-weight: 600;
    margin: 0 0 .75rem;
}

h3 {
    font-size: .8rem;
    font-weight: 600;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--pl-ink-soft);
    margin: 1.25rem 0 .6rem;
}

#blazor-error-ui {
    display: none;
    position: fixed;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 2100;
    padding: .6rem 1.25rem;
    background: var(--pl-amber-soft);
    color: var(--pl-ink);
    border-top: 1px solid var(--pl-amber);
}

/* ---------- page header: icon, title, actions ---------------------------- */

.page-head {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: var(--pl-gap);
}

.page-title {
    flex: 1 1 12rem;
    min-width: 0;
}

.page-title .hint {
    margin: .1rem 0 0;
    font-size: .92rem;
}

/* ---------- surfaces ------------------------------------------------------- */

.fieldset,
.card-panel,
.stat,
.empty {
    background: var(--pl-surface);
    border: 1px solid var(--pl-line);
    border-radius: var(--ps-radius);
    box-shadow: var(--ps-shadow-sm);
}

.fieldset {
    padding: 1.5rem;
    margin-bottom: var(--pl-gap);
}

.card-panel {
    padding: 2rem;
    width: min(440px, 100%);
}

.card-panel h1 {
    margin-bottom: 1.25rem;
}

.card-wide {
    width: 100%;
    padding: 1.75rem;
    margin-bottom: var(--pl-gap);
}

/* On the sign-in pages the card is the BackOffice's login card. */
.ps-auth .card-panel {
    width: min(440px, 92vw);
    border-radius: 22px;
    box-shadow: var(--ps-shadow-lg);
    animation: ps-rise .7s var(--ps-ease) .08s both;
}

.ps-auth .card-panel h1 {
    font-size: 1.35rem;
}

/* ---------- fields ---------------------------------------------------------- */

.fields {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: 1rem;
}

.field {
    display: flex;
    flex-direction: column;
    gap: .3rem;
    margin-bottom: .75rem;
}

.field-wide {
    grid-column: 1 / -1;
}

.field label {
    font-size: .85rem;
    font-weight: 500;
    color: var(--pl-ink-soft);
}

/* A field showing its value instead of its editor. Same height as an input, so switching between
   modes does not make the page jump. */
.field-value {
    padding: .5rem 0;
    min-height: 2.35rem;
    color: var(--pl-ink);
    word-break: break-word;
}

.field-empty {
    color: var(--pl-ink-soft);
    font-style: italic;
}

.field-label {
    font-weight: 600;
    font-size: .875rem;
}

.hint {
    color: var(--pl-ink-soft);
    font-size: .85rem;
    margin: .15rem 0 0;
}

.error,
.validation-message {
    color: var(--pl-red);
    font-size: .85rem;
}

.validation-errors {
    color: var(--pl-red);
    font-size: .85rem;
    padding-left: 1.1rem;
}

.required {
    color: var(--pl-red);
    text-decoration: none;
    border: 0;
    cursor: help;
    font-weight: 600;
}

.actions {
    display: flex;
    gap: .6rem;
    align-items: center;
    margin-top: 1.25rem;
}

.actions form {
    display: inline;
    margin: 0;
}

.head-actions {
    display: flex;
    align-items: center;
    gap: .6rem;
}

.section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: .75rem;
}

.section-head h2 {
    margin: 0;
}

.filters,
.range {
    display: flex;
    flex-wrap: wrap;
    gap: .75rem 1rem;
    align-items: flex-end;
}

.filters {
    margin-bottom: var(--pl-gap);
}

.filters .field {
    min-width: 180px;
}

.range {
    margin-bottom: 1rem;
}

.page-head .range {
    margin-bottom: 0;
}

.range label {
    display: flex;
    flex-direction: column;
    gap: .25rem;
    font-size: .875rem;
    font-weight: 500;
    color: var(--pl-ink-soft);
}

.checklist {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem 1.25rem;
}

.checklist .form-check-label {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
}

/* ---------- tables: the BackOffice's soft cards ---------------------------- */

.grid {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    background: var(--pl-surface);
    border: 1px solid var(--pl-line);
    border-radius: var(--ps-radius);
    box-shadow: var(--ps-shadow-sm);
    overflow: hidden;
    margin-bottom: 1.25rem;
}

.grid th,
.grid td {
    text-align: left;
    padding: .75rem 1rem;
    border-bottom: 1px solid var(--pl-line);
    vertical-align: middle;
}

.grid thead th {
    background: var(--pl-canvas);
    color: var(--pl-ink-soft);
    font-size: .74rem;
    font-weight: 600;
    letter-spacing: .06em;
    text-transform: uppercase;
    white-space: nowrap;
}

.grid tfoot th {
    background: var(--pl-canvas);
    font-weight: 600;
    border-bottom: 0;
}

.grid tbody tr:last-child td {
    border-bottom: 0;
}

.grid tbody tr {
    transition: background-color .15s ease;
}

.grid tbody tr:hover > td {
    background: var(--pl-accent-soft);
}

.grid .num,
.grid th.num {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.row-action {
    text-align: right;
    white-space: nowrap;
}

.row-action > * + * {
    margin-left: .35rem;
}

.row-warn > td {
    background: var(--pl-amber-soft);
}

.row-inside td {
    background: var(--pl-ok-soft);
}

/* Rows slide in like the BackOffice's tables. */
.ps-page .grid > tbody > tr { animation: ps-row .45s var(--ps-ease) backwards; }
.ps-page .grid > tbody > tr:nth-child(2) { animation-delay: .04s; }
.ps-page .grid > tbody > tr:nth-child(3) { animation-delay: .08s; }
.ps-page .grid > tbody > tr:nth-child(4) { animation-delay: .12s; }
.ps-page .grid > tbody > tr:nth-child(5) { animation-delay: .16s; }
.ps-page .grid > tbody > tr:nth-child(n+6) { animation-delay: .20s; }

/* ---------- pills ------------------------------------------------------------ */

.pill {
    display: inline-block;
    font-size: .78rem;
    font-weight: 500;
    padding: .15rem .6rem;
    border-radius: 999px;
    background: var(--pl-canvas);
    color: var(--pl-ink-soft);
    margin-left: .25rem;
    white-space: nowrap;
}

.pill:first-child {
    margin-left: 0;
}

.pill-active,
.pill-paid {
    background: var(--pl-ok-soft);
    color: var(--pl-ok);
}

.pill-pastdue,
.pill-pending {
    background: var(--pl-amber-soft);
    color: var(--pl-amber);
}

.pill-suspended,
.pill-failed,
.pill-cancelled,
.pill-closed {
    background: var(--pl-red-soft);
    color: var(--pl-red);
}

.pill-never {
    background: var(--pl-canvas);
    color: var(--pl-ink-soft);
}

/* ---------- stats, callouts, empty states -------------------------------------- */

.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 1rem;
    margin-bottom: var(--pl-gap);
}

.stat {
    padding: 1.15rem 1.25rem;
    transition: transform .3s var(--ps-ease), box-shadow .3s ease, border-color .3s ease;
}

.stat:hover {
    transform: translateY(-3px);
    box-shadow: var(--ps-shadow);
    border-color: color-mix(in srgb, var(--ps-accent) 40%, var(--ps-border));
}

.stat-value {
    display: block;
    font-size: 1.9rem;
    font-weight: 700;
    letter-spacing: -.02em;
    line-height: 1.15;
    font-variant-numeric: tabular-nums;
}

.stat-label {
    color: var(--pl-ink-soft);
    font-size: .85rem;
}

.stat-warn {
    border-color: var(--pl-amber);
}

.callout {
    background: var(--pl-amber-soft);
    border-left: 3px solid var(--pl-amber);
    padding: .75rem 1rem;
    border-radius: var(--ps-radius-sm);
    margin-top: var(--pl-gap);
}

.empty {
    border-style: dashed;
    padding: 2.5rem;
    text-align: center;
    color: var(--pl-ink-soft);
}

.empty p {
    margin: 0;
}

.empty p + p {
    margin-top: .35rem;
}

.empty .btn {
    margin-top: 1rem;
}

.sync-state {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .5rem;
    margin-bottom: 1rem;
}

/* ---------- monthly report charts ------------------------------------------------ */

.lot-chart {
    display: flex;
    flex-direction: column;
    gap: .75rem;
}

.lot-chart-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 1rem;
}

.lot-chart-head a {
    font-weight: 600;
}

.lot-chart-canvas {
    position: relative;
    height: 280px;
}

.lot-chart-figures {
    display: flex;
    flex-wrap: wrap;
    gap: .25rem 1.25rem;
    margin: 0;
    font-size: .85rem;
    color: var(--pl-ink-soft);
}

.lot-chart-figures strong {
    color: var(--pl-ink);
    font-variant-numeric: tabular-nums;
}

/* ---------- small controls ---------------------------------------------------------- */

.app-icon {
    flex: none;
    vertical-align: -.15em;
}

.icon-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.1rem;
    height: 2.1rem;
    padding: 0;
    border: 1px solid transparent;
    border-radius: 10px;
    background: none;
    color: var(--pl-ink-soft);
    cursor: pointer;
    text-decoration: none !important;
    transition: background-color .18s ease, color .18s ease, transform .18s var(--ps-ease);
}

.icon-button:hover:not(:disabled) {
    background: var(--pl-accent-soft);
    color: var(--pl-accent);
    transform: scale(1.08);
}

.icon-button:disabled {
    opacity: .4;
    cursor: not-allowed;
}

.link-button {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    padding: 0;
    border: 0;
    background: none;
    color: var(--pl-accent);
    font: inherit;
    font-variant-numeric: tabular-nums;
    cursor: pointer;
    text-align: left;
}

.link-button:hover {
    text-decoration: underline;
}

.btn:disabled {
    opacity: .5;
    cursor: not-allowed;
}

.btn-sm {
    padding: .3rem .7rem;
    font-size: .9rem;
}

/* A quiet secondary action, for the destructive one in a row of two. */
.btn-quiet {
    background: none;
    border: 1px solid var(--pl-line);
    color: var(--pl-ink-soft);
}

.btn-quiet:hover:not(:disabled) {
    border-color: var(--pl-red);
    color: var(--pl-red);
}

/* A password or code shown once, to be read off the screen and typed somewhere else. */
.issued-password {
    display: inline-block;
    font-family: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
    font-size: 1.25rem;
    letter-spacing: .08em;
    color: var(--pl-ink);
    background: var(--pl-canvas);
    border: 1px solid var(--pl-line);
    border-radius: var(--ps-radius-sm);
    padding: .4rem .7rem;
    user-select: all;
}

.plate {
    font-family: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
    letter-spacing: .04em;
}

code {
    color: var(--pl-accent);
}

.qr {
    display: block;
    margin: 0 auto 1rem;
    background: #fff;
    padding: .5rem;
    border-radius: var(--ps-radius-sm);
}

.key {
    font-size: .9rem;
    color: var(--pl-ink-soft);
}

.codes {
    columns: 2;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: .9rem;
    background: var(--pl-canvas);
    padding: 1rem 1rem 1rem 2.2rem;
    border-radius: var(--ps-radius-sm);
}

.map-block .hint {
    margin-top: .5rem;
}

/* ---------- lot location and map ----------------------------------------------------- */

.lot-workspace {
    display: grid;
    gap: 1.25rem;
    margin-top: 1rem;
}

.lot-workspace:not(.is-editing) .lot-form:empty {
    display: none;
}

@media (min-width: 1100px) {
    .lot-workspace.is-editing {
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
        align-items: start;
    }

    .lot-workspace.is-editing .map {
        height: 460px;
    }
}

.lot-form h3 {
    margin-top: 0;
}

.map {
    height: 360px;
    border: 1px solid var(--pl-line);
    border-radius: var(--ps-radius);
    box-shadow: var(--ps-shadow-sm);
    overflow: hidden;
    z-index: 0;
}

/* Shown over the map when the wheel is used without Ctrl: the page scrolls, the map does not zoom. */
.map-wheel-hint {
    position: absolute;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: rgba(0, 0, 0, .45);
    color: #fff;
    font-weight: 600;
    text-align: center;
    pointer-events: none;
    opacity: 0;
    transition: opacity .2s ease;
}

.map-wheel-hint.is-visible {
    opacity: 1;
}

.map.is-editing {
    cursor: crosshair;
    border-color: color-mix(in srgb, var(--ps-accent) 55%, var(--ps-border));
}

/* OpenStreetMap tiles are light; in the dark theme they are inverted to match, the pins are not. */
[data-bs-theme="dark"] .map .leaflet-tile-pane {
    filter: invert(1) hue-rotate(180deg) brightness(.92) contrast(.9) saturate(.8);
}

[data-bs-theme="dark"] .map .leaflet-control-attribution,
[data-bs-theme="dark"] .map .leaflet-bar a {
    background: var(--ps-surface);
    color: var(--ps-muted);
    border-color: var(--ps-border);
}

/* A wide table scrolls inside its card instead of pushing out of it. */
.grid-scroll {
    overflow-x: auto;
    margin-bottom: 1.25rem;
}

.grid-scroll > .grid {
    margin-bottom: 0;
}

.lot-location .link-button {
    max-width: 15rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.location-value {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .5rem 1rem;
    min-height: 2.35rem;
}

.location-value .bi,
.lot-location .bi {
    color: var(--pl-red);
}

.lot-place {
    margin-bottom: var(--pl-gap);
}

.lot-place .map {
    height: 300px;
}

/* ---------- lot page tabs ----------------------------------------------------------- */

.lot-tabs {
    display: flex;
    gap: .25rem;
    margin: .25rem 0 1rem;
    padding: .3rem;
    overflow-x: auto;
    scrollbar-width: thin;
    background: var(--pl-surface);
    border: 1px solid var(--pl-line);
    border-radius: var(--ps-radius);
    box-shadow: var(--ps-shadow-sm);
}

.lot-tab {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    flex: 0 0 auto;
    padding: .55rem .95rem;
    border: 0;
    border-radius: var(--ps-radius-sm);
    background: transparent;
    color: var(--pl-ink-soft);
    font: inherit;
    font-weight: 550;
    white-space: nowrap;
    cursor: pointer;
    transition: background-color .2s ease, color .2s ease, transform .15s ease;
}

.lot-tab > .bi {
    font-size: 1.05rem;
    transition: transform .3s var(--ps-ease);
}

.lot-tab:hover {
    background: var(--ps-surface-2);
    color: var(--pl-ink);
}

.lot-tab:hover > .bi {
    transform: scale(1.12) rotate(-4deg);
}

.lot-tab:active {
    transform: scale(.97);
}

.lot-tab:focus-visible {
    outline: 2px solid var(--ps-accent);
    outline-offset: 1px;
}

.lot-tab.active {
    background: var(--pl-accent-soft);
    color: var(--ps-accent);
}

.lot-tab.active::after {
    content: "";
    position: absolute;
    left: .95rem;
    right: .95rem;
    bottom: .2rem;
    height: 2px;
    border-radius: 2px;
    background: var(--ps-accent);
    animation: lot-tab-bar .3s var(--ps-ease);
}

.lot-tab-count {
    min-width: 1.5rem;
    padding: .05rem .45rem;
    border-radius: 999px;
    background: var(--ps-surface-2);
    color: var(--pl-ink);
    font-size: .78rem;
    font-variant-numeric: tabular-nums;
    text-align: center;
}

.lot-tab.active .lot-tab-count {
    background: var(--ps-accent);
    color: #fff;
}

.lot-tab-panel {
    animation: ps-rise .4s var(--ps-ease) backwards;
}

.lot-tab-panel > .tab-intro {
    margin: 0 0 .75rem;
}

/* On a phone every tab stays in sight, so the open one is never scrolled away. */
@media (max-width: 767.98px) {
    .lot-tabs {
        flex-wrap: wrap;
        overflow-x: visible;
    }

    .lot-tab {
        flex: 1 1 auto;
        justify-content: center;
    }
}

@keyframes lot-tab-bar {
    from { transform: scaleX(0); }
    to { transform: scaleX(1); }
}

@media (prefers-reduced-motion: reduce) {
    .lot-tab,
    .lot-tab > .bi,
    .lot-tab.active::after,
    .lot-tab-panel {
        animation: none;
        transition: none;
    }
}

/* ---------- plate lists -------------------------------------------------------------- */

.plate-panels {
    display: grid;
    gap: 1rem;
}

@media (min-width: 1800px) {
    .plate-panels {
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
        align-items: start;
    }

    .plate-panels.single {
        grid-template-columns: minmax(0, 1fr);
    }
}

.plate-list .grid-scroll {
    margin-bottom: 0;
}

.plate-list .pill {
    white-space: nowrap;
}

.plate-list h3 {
    display: flex;
    align-items: baseline;
    gap: .5rem;
    margin-top: 0;
}

.plate-list h3 .hint {
    text-transform: none;
    letter-spacing: 0;
    font-weight: 400;
}

.plate-add {
    display: flex;
    gap: .5rem;
    margin-bottom: 1rem;
}

.plate-add .form-control:first-child {
    flex: 1 1 auto;
    text-transform: uppercase;
}

.plate-number {
    width: 6.5rem;
    flex: 0 0 auto;
}

.inline-edit {
    display: inline-block;
    vertical-align: middle;
}

.icon-button.danger:hover:not(:disabled) {
    background: var(--pl-red-soft);
    color: var(--pl-red);
}

.conflicts ul {
    margin: .5rem 0 0;
    padding-left: 1.1rem;
}

.conflicts li {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: .5rem;
    margin-bottom: .35rem;
}

.sync-note .pill {
    margin-left: 0;
}
