/* =============================================================================
   public/css/main.css — ParkLedger structural stylesheet
   Version  : v0.1.20.0180 Beta
   Date     : 2026-11-16 03:30
   Developed by Tarras

   0180: dashboard boxes as links (.stat-card--link): pointer, lift on hover, keyboard focus ring; the filter row
         (.filter-bar / .filter-control, before only on the ticket list) for every list page.

   0166: sortable tables (.data-table--sort, public/js/table_sort.js): clickable
         headings with ⇅ / ▲ / ▼; on wide screens (900px+) the heading row stays
         under the top bar while scrolling (the box around the table no longer
         scrolls sideways there, so the heading can stick).
   0161: .bulk-bar (one save bar for a table, sticks to the bottom of the screen)
         and tr.is-dirty (a changed line, not saved yet).
   0160: .page-content uses the full width (was max 1160px), so pages follow the
         window and the collapsed side menu. Forms / text stay readable through
         .pl-narrow (max 760px) where a page wants it; dropdowns in tables max 240px.

   0135: form conventions — .form-label--alt1…5 (coloured star = "at least one
         field with this colour"), .form-control.is-invalid, .field-error,
         .form-legend.

   0119: html color-scheme follows the theme (dark scrollbars/form controls in dark mode).

   Structure and component anatomy ONLY.
   Zero hardcoded colours — all visual properties from theme CSS variables.
   Load order: themes/default.css FIRST, then this file.
   ============================================================================= */

/* ── Reset ─────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html  { font-size: var(--font-size-base); scroll-behavior: smooth; color-scheme: var(--color-scheme, light); }
body  {
    font-family: var(--font-body);
    font-size:   var(--text-body);
    font-weight: var(--font-weight-body);
    line-height: var(--line-height-body);
    color:       var(--color-text);
    background:  var(--color-bg);
    min-height:  100vh;
}
img  { display: block; max-width: 100%; }
svg  { display: block; }

.action-btns {
    display:     flex;
    gap:         4px;
    align-items: center;
    flex-wrap:   nowrap;
}
ul, ol    { list-style: none; }
button    { cursor: pointer; font: inherit; }
input, select, textarea { font: inherit; }
a {
    color:           var(--color-link);
    text-decoration: var(--link-decoration);
    transition:      color var(--transition-speed) var(--transition-easing);
}
a:hover { color: var(--color-link-hover); text-decoration: var(--link-decoration-hover); }

/* ── Typography ─────────────────────────────────────────────────────────────── */
h1, h2, h3, h4, h5, h6 {
    font-family:    var(--font-heading);
    font-weight:    var(--font-weight-heading);
    line-height:    var(--line-height-heading);
    letter-spacing: var(--letter-spacing-heading);
    color:          var(--color-heading);
}
h1 { font-size: var(--text-h1); margin-bottom: var(--heading-mb-h1); }
h2 { font-size: var(--text-h2); margin-bottom: var(--heading-mb-h2); }
h3 { font-size: var(--text-h3); margin-bottom: var(--heading-mb-h3); }
code { font-family: var(--font-mono); font-size: .875em; }

/* ── Utilities ──────────────────────────────────────────────────────────────── */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; }
.text-muted     { color: var(--color-text-muted) !important; }
.text-secondary { color: var(--color-text-secondary) !important; }
.text-small     { font-size: var(--text-sm) !important; }
.text-danger    { color: var(--color-danger-text) !important; }
.text-success   { color: var(--color-success-text) !important; }

/* ── Page structure ─────────────────────────────────────────────────────────── */
.site-main {
    flex: 1;
    padding: var(--page-padding);
    min-height: calc(100vh - var(--header-height) - 52px);
}
.site-main--public {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--color-bg-secondary);
    padding: var(--sp-8) var(--sp-6);
}

.site-footer {
    border-top:  var(--footer-border);
    padding:     var(--sp-4) var(--sp-8);
    font-size:   var(--text-xs);
    color:       var(--color-text-muted);
    background:  var(--color-footer-bg);
}
.site-footer--public {
    text-align:  center;
    padding:     var(--sp-4);
    background:  transparent;
    border-top:  none;
}
.footer-inner {
    display:         flex;
    justify-content: space-between;
    align-items:     center;
    gap:             var(--sp-4);
}

/* ── Page content wrapper ───────────────────────────────────────────────────── */
.page-content { width: 100%; max-width: none; }
.pl-narrow    { max-width: 760px; }   /* 0160: for forms / reading text inside a full-width page */
.data-table select.form-control, .data-table select { max-width: 240px; }   /* 0160 */

/* 0161: one save bar per table of editable lines (public/js/bulk_save.js) */
.bulk-bar { position: sticky; bottom: 0; z-index: 3; display: flex; flex-wrap: wrap; justify-content: flex-end; align-items: center;
            gap: var(--sp-2) var(--sp-3); padding: var(--sp-3) var(--sp-4); margin: 0;
            background: var(--color-surface); border-top: 1px solid var(--color-border); border-radius: 0 0 var(--radius-lg, 12px) var(--radius-lg, 12px); }
.bulk-bar__hint { margin-right: auto; }
.bulk-bar.is-dirty { box-shadow: 0 -6px 16px rgba(0, 0, 0, .18); }
.bulk-bar.is-dirty .bulk-bar__hint { color: var(--color-primary); font-weight: 600; }
.bulk-bar button[disabled] { opacity: .5; cursor: default; }
tr.is-dirty > td { background: color-mix(in srgb, var(--color-primary) 12%, transparent); }
tr.is-dirty > td:first-child { box-shadow: inset 3px 0 0 var(--color-primary); }

.page-header {
    display:         flex;
    align-items:     center;
    justify-content: space-between;
    gap:             var(--sp-4);
    margin-bottom:   var(--sp-6);
    flex-wrap:       wrap;
}
.page-header h1 { margin-bottom: var(--sp-1); }

/* ── Header ─────────────────────────────────────────────────────────────────── */
.header-page-title {
    font-size:   var(--text-sm);
    font-weight: var(--font-weight-bold);
    color:       var(--color-text-secondary);
}
.header-username {
    font-size:   var(--text-sm);
    color:       var(--color-text-secondary);
}

/* Role badge in header */
.role-badge {
    font-size:     var(--text-xs);
    font-weight:   var(--font-weight-bold);
    padding:       2px 8px;
    border-radius: var(--radius-full);
    text-transform: capitalize;
    background:    var(--color-bg-secondary);
    color:         var(--color-text-secondary);
    border:        1px solid var(--color-border);
}
.role-badge--admin  { background: var(--color-danger-bg);  color: var(--color-danger-text);  border-color: var(--color-danger-border); }
.role-badge--manager { background: var(--color-info-bg);   color: var(--color-info-text);    border-color: var(--color-info-border); }

/* Flash messages inline in header */
.flash-inline {
    font-size:   var(--text-sm);
    padding:     5px 12px;
    border-radius: var(--radius-md);
    border:      1px solid;
}
.flash-inline--success { background: var(--color-success-bg); color: var(--color-success-text); border-color: var(--color-success-border); }
.flash-inline--error   { background: var(--color-danger-bg);  color: var(--color-danger-text);  border-color: var(--color-danger-border); }

/* ── Version badge ──────────────────────────────────────────────────────────── */
.version-badge {
    display:       inline-block;
    padding:       2px 8px;
    border-radius: var(--badge-radius);
    font-size:     var(--text-xs);
    font-weight:   var(--font-weight-bold);
    background:    var(--color-warning-bg);
    color:         var(--color-warning-text);
    border:        1px solid var(--color-warning-border);
}

/* ── Buttons ────────────────────────────────────────────────────────────────── */
.btn {
    display:         inline-flex;
    align-items:     center;
    gap:             var(--sp-2);
    padding:         var(--btn-padding);
    border-radius:   var(--btn-radius);
    border:          var(--btn-border-width) solid transparent;
    font-size:       var(--text-btn);
    font-weight:     var(--font-weight-btn);
    text-decoration: none;
    cursor:          pointer;
    transition:      background  var(--transition-speed) var(--transition-easing),
                     color       var(--transition-speed) var(--transition-easing),
                     box-shadow  var(--transition-speed) var(--transition-easing),
                     transform   var(--transition-speed) var(--transition-easing);
    white-space:     nowrap;
}
.btn:focus-visible { outline: var(--focus-outline); outline-offset: 2px; }

.btn--primary {
    background: var(--color-primary);
    color:      var(--color-on-primary);
    box-shadow: var(--btn-primary-shadow);
}
.btn--primary:hover {
    background: var(--color-primary-hover);
    color:      var(--color-on-primary);
    box-shadow: var(--btn-primary-shadow-hover);
    transform:  var(--btn-hover-lift);
    text-decoration: none;
}

.btn--outline {
    background:   transparent;
    border-color: var(--color-border);
    color:        var(--color-text);
}
.btn--outline:hover {
    background:   var(--color-surface-raised);
    border-color: var(--color-primary);
    color:        var(--color-primary);
    text-decoration: none;
}

.btn--ghost {
    background:   transparent;
    border-color: transparent;
    color:        var(--color-text);
}
.btn--ghost svg {
    stroke: var(--color-text-secondary) !important;
}
.btn--ghost:hover {
    background:   var(--color-surface-raised);
    color:        var(--color-text);
    text-decoration: none;
}
.btn--ghost:hover svg {
    stroke: var(--color-text) !important;
}

.btn--danger {
    background: var(--color-danger);
    color:      #fff;
}
.btn--danger:hover {
    background: var(--color-danger-hover);
    color:      #fff;
    text-decoration: none;
}

.btn--sm  { padding: var(--btn-padding-sm);  font-size: var(--text-sm); }
.btn--lg  { padding: var(--btn-padding-lg);  font-size: var(--text-lg); }
.btn--full { width: 100%; justify-content: center; }

/* ── Forms ──────────────────────────────────────────────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: var(--sp-2); margin-bottom: var(--sp-5); }
.form-group:last-of-type { margin-bottom: 0; }

.form-label {
    font-size:   var(--text-sm);
    font-weight: var(--font-weight-label);
    color:       var(--color-label);
}
.form-label--required::after {
    content: ' *';
    color:   var(--color-danger-text);
}
/* 0135: either/or groups — first group blue, then green, purple, orange, teal */
.form-label--alt1::after { content: ' *'; color: var(--color-alt-1); }
.form-label--alt2::after { content: ' *'; color: var(--color-alt-2); }
.form-label--alt3::after { content: ' *'; color: var(--color-alt-3); }
.form-label--alt4::after { content: ' *'; color: var(--color-alt-4); }
.form-label--alt5::after { content: ' *'; color: var(--color-alt-5); }
.form-control.is-invalid { border-color: var(--color-danger); box-shadow: 0 0 0 2px var(--color-danger-bg); }
.form-control.is-invalid:focus { border-color: var(--color-danger); box-shadow: 0 0 0 3px var(--color-danger-bg); }
.field-error { font-size: var(--text-sm); color: var(--color-danger); font-weight: 600; }
.field-error[hidden] { display: none; }
.form-legend { font-size: var(--text-xs, .75rem); color: var(--color-text-muted); }
.form-legend .star { font-weight: 700; }

.form-control {
    width:         100%;
    padding:       var(--input-padding);
    border:        var(--input-border-width) solid var(--color-input-border);
    border-radius: var(--input-radius);
    font-size:     var(--text-input);
    color:         var(--color-text);
    background:    var(--color-input-bg);
    transition:    border-color var(--transition-speed) var(--transition-easing),
                   box-shadow   var(--transition-speed) var(--transition-easing);
}
.form-control:focus {
    outline:      none;
    border-color: var(--color-primary);
    box-shadow:   var(--focus-ring);
    background:   var(--color-input-bg-focus);
}
.form-control::placeholder { color: var(--color-text-muted); }

textarea.form-control { resize: vertical; min-height: 100px; }
select.form-control   { cursor: pointer; }

/* Input with button inside (password toggle etc.) */
.input-with-toggle { position: relative; }
.input-with-toggle .form-control { padding-right: 44px; }
.input-toggle-btn {
    position:    absolute;
    right:       10px;
    top:         50%;
    transform:   translateY(-50%);
    background:  none;
    border:      none;
    color:       var(--color-text-muted);
    padding:     var(--sp-1);
    display:     flex;
    align-items: center;
}
.input-toggle-btn:hover { color: var(--color-text); }

/* Form row (side by side fields) */
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-4); }
.form-row--3 { grid-template-columns: 1fr 1fr 1fr; }
@media (max-width: 640px) {
    .form-row, .form-row--3 { grid-template-columns: 1fr; }
}

/* ── Alerts ─────────────────────────────────────────────────────────────────── */
.alert {
    display:       flex;
    align-items:   flex-start;
    gap:           var(--sp-3);
    padding:       var(--sp-4) var(--sp-5);
    border-radius: var(--radius-md);
    border:        1px solid;
    font-size:     var(--text-sm);
    line-height:   1.6;
    margin-bottom: var(--sp-5);
}
.alert--info    { background: var(--color-info-bg);    color: var(--color-info-text);    border-color: var(--color-info-border); }
.alert--success { background: var(--color-success-bg); color: var(--color-success-text); border-color: var(--color-success-border); }
.alert--warning { background: var(--color-warning-bg); color: var(--color-warning-text); border-color: var(--color-warning-border); }
.alert--danger  { background: var(--color-danger-bg);  color: var(--color-danger-text);  border-color: var(--color-danger-border); }

/* ── Cards ──────────────────────────────────────────────────────────────────── */
.card {
    background:    var(--color-card-bg);
    border:        var(--card-border);
    border-radius: var(--card-radius);
    box-shadow:    var(--card-shadow);
    padding:       var(--card-padding);
}
.card-header {
    display:         flex;
    align-items:     center;
    justify-content: space-between;
    gap:             var(--sp-4);
    margin-bottom:   var(--sp-4);
    padding-bottom:  var(--sp-4);
    border-bottom:   var(--card-border);
}
.card-title {
    font-size:   var(--text-h3);
    font-weight: var(--font-weight-heading);
    color:       var(--color-heading);
    margin:      0;
}

/* ── Stat cards (dashboard) ─────────────────────────────────────────────────── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: var(--sp-4);
    margin-bottom: var(--sp-6);
}
.stat-card {
    background:    var(--color-card-bg);
    border:        var(--card-border);
    border-radius: var(--card-radius);
    padding:       var(--sp-5);
    box-shadow:    var(--card-shadow);
    display:       flex;
    align-items:   center;
    gap:           var(--sp-4);
}
.stat-card__icon {
    width:           48px;
    height:          48px;
    border-radius:   var(--radius-md);
    display:         flex;
    align-items:     center;
    justify-content: center;
    flex-shrink:     0;
}
.stat-card__value {
    font-size:   1.875rem;
    font-weight: var(--font-weight-heading);
    line-height: 1;
    color:       var(--color-heading);
    font-family: var(--font-heading);
}
.stat-card__label {
    font-size: var(--text-sm);
    color:     var(--color-text-muted);
    margin-top: var(--sp-1);
}
.stat-card--blue  .stat-card__icon { background: var(--color-info-bg);    color: var(--color-info-text); }
.stat-card--green .stat-card__icon { background: var(--color-success-bg); color: var(--color-success-text); }
.stat-card--amber .stat-card__icon { background: var(--color-warning-bg); color: var(--color-warning-text); }
.stat-card--teal  .stat-card__icon { background: var(--color-success-bg); color: var(--color-success-text); }

/* ── Tables ─────────────────────────────────────────────────────────────────── */
.table-wrap {
    overflow-x: auto;
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}
.data-table {
    width:           100%;
    border-collapse: collapse;
    font-size:       var(--text-sm);
}
.data-table thead {
    background: var(--color-table-header-bg);
}
.data-table th {
    padding:       var(--table-cell-padding);
    text-align:    left;
    font-size:     var(--text-xs);
    font-weight:   var(--font-weight-bold);
    text-transform: uppercase;
    letter-spacing: .06em;
    color:         var(--color-text-muted);
    border-bottom: var(--table-header-border);
    white-space:   nowrap;
}
.data-table td {
    padding:       var(--table-cell-padding);
    border-bottom: var(--table-row-border);
    vertical-align: middle;
    color:         var(--color-text);
}
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover td { background: var(--color-table-row-hover); }

.table-empty {
    text-align: center;
    padding:    var(--sp-12) var(--sp-6);
    color:      var(--color-text-muted);
    font-size:  var(--text-sm);
    display:    flex;
    flex-direction: column;
    align-items: center;
    gap: var(--sp-2);
}

/* Ticket number monospace style */
.ticket-number {
    font-family:   var(--font-mono);
    font-size:     var(--text-xs);
    background:    var(--color-bg-secondary);
    padding:       2px 6px;
    border-radius: var(--radius-sm);
    border:        1px solid var(--color-border);
}

/* ── Badges (status) ────────────────────────────────────────────────────────── */
.badge {
    display:       inline-block;
    padding:       var(--badge-padding);
    border-radius: var(--badge-radius);
    font-size:     var(--text-xs);
    font-weight:   var(--font-weight-bold);
    white-space:   nowrap;
}
.badge--info      { background: var(--color-info-bg);    color: var(--color-info-text);    border: 1px solid var(--color-info-border); }
.badge--success   { background: var(--color-success-bg); color: var(--color-success-text); border: 1px solid var(--color-success-border); }
.badge--warning   { background: var(--color-warning-bg); color: var(--color-warning-text); border: 1px solid var(--color-warning-border); }
.badge--danger    { background: var(--color-danger-bg);  color: var(--color-danger-text);  border: 1px solid var(--color-danger-border); }
.badge--secondary { background: var(--color-bg-secondary); color: var(--color-text-muted); border: 1px solid var(--color-border); }

/* ── Login page ─────────────────────────────────────────────────────────────── */
.login-wrap {
    display:        flex;
    flex-direction: column;
    align-items:    center;
    width:          100%;
    max-width:      420px;
    gap:            var(--sp-4);
}
.login-card {
    width:         100%;
    background:    var(--color-card-bg);
    border:        var(--card-border);
    border-radius: var(--card-radius);
    padding:       var(--card-padding-lg);
    box-shadow:    var(--card-shadow);
}
.login-brand {
    display:         flex;
    align-items:     center;
    gap:             var(--sp-2);
    margin-bottom:   var(--sp-6);
    font-weight:     var(--font-weight-heading);
    font-size:       1.25rem;
    color:           var(--color-heading);
}
.login-brand__mark { color: var(--color-primary); font-size: 1.5rem; }
.login-heading {
    font-size:     var(--text-h2);
    margin-bottom: var(--sp-2);
}
.login-sub {
    color:         var(--color-text-muted);
    font-size:     var(--text-sm);
    margin-bottom: var(--sp-6);
}
.login-form { margin-top: var(--sp-2); }
.login-form .form-group { margin-bottom: var(--sp-5); }
.login-form .btn--primary { margin-top: var(--sp-2); }
.login-footer {
    font-size: var(--text-xs);
    color:     var(--color-text-muted);
    text-align: center;
}

/* ── Responsive ─────────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
    .site-main { padding: var(--sp-4) var(--sp-4); }
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .page-header { flex-direction: column; align-items: flex-start; }
}
@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr; }
    .login-card { padding: var(--sp-8) var(--sp-5); }
}
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* Visually hidden but read by screen readers (0119) */
.visually-hidden { position:absolute !important; width:1px; height:1px; padding:0; margin:-1px; overflow:hidden; clip:rect(0,0,0,0); white-space:nowrap; border:0; }

/* 0166: sortable tables + sticky headings */
.data-table--sort th.ts-th { cursor: pointer; user-select: none; white-space: nowrap; }
.data-table--sort th.ts-th:hover, .data-table--sort th.ts-th:focus-visible { color: var(--color-primary); outline: none; }
.data-table--sort .ts-mark { margin-left: .35em; font-size: .85em; opacity: .35; }
.data-table--sort th.is-sorted .ts-mark { opacity: 1; color: var(--color-primary); }
@media (min-width: 900px) {
    .data-table--sort thead th { position: sticky; top: var(--header-height, 64px); z-index: 5;
        background: var(--color-table-header-bg); box-shadow: inset 0 -1px 0 var(--color-border); }
    .table-wrap:has(> .data-table--sort), .card:has(.data-table--sort), div:has(> .data-table--sort) { overflow: visible !important; }
}

/* 0180: dashboard boxes that open the list behind the number */
a.stat-card--link { text-decoration: none; color: inherit; cursor: pointer; transition: transform .12s ease, box-shadow .12s ease, border-color .12s ease; }
a.stat-card--link:hover { transform: translateY(-2px); box-shadow: 0 6px 18px rgba(0,0,0,.12); border-color: var(--color-primary, #2563eb); }
a.stat-card--link:focus-visible { outline: 2px solid var(--color-primary, #2563eb); outline-offset: 2px; }

/* 0180: the filter row (also Complaints and Payments) */
.filter-bar { display: flex; gap: var(--sp-3); flex-wrap: wrap; align-items: center; margin-bottom: var(--sp-5); }
.filter-control { flex: 1; min-width: 130px; max-width: 200px; }
