/* HOA custom styles */

/* Slightly smaller base font */
html { font-size: 15px; }

/* ---- Top nav ---- */
body > nav {
    padding-inline: 0;
}
.nav-inner {
    max-width: 1440px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-inline: 1.5rem;
    width: 100%;
    box-sizing: border-box;
}
/* PicoCSS nav>ul styles don't reach nav>div>ul; reset manually */
.nav-inner ul {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    list-style: none;
    margin: 0;
    padding: 0;
}
.nav-inner ul li {
    list-style: none;
    padding: 0;
}

/* ---- Language dropdown ---- */
.lang-switcher {
    position: relative;
    display: inline-block;
}
.lang-switcher button {
    --pico-form-element-spacing-vertical: 0.25rem;
    --pico-form-element-spacing-horizontal: 0.5rem;
    font-size: 0.85rem;
    display: inline-flex;
    align-items: center;
    gap: 0.4em;
    color: var(--pico-color);
    border-color: var(--pico-muted-border-color);
}
#lang-menu {
    position: absolute;
    right: 0;
    top: calc(100% + 4px);
    z-index: 200;
    min-width: 140px;
    list-style: none;
    margin: 0;
    padding: 0.25rem 0;
    background: var(--pico-card-background-color, #fff);
    border: 1px solid var(--pico-muted-border-color, #ccc);
    border-radius: var(--pico-border-radius, 4px);
    box-shadow: 0 4px 12px rgba(0,0,0,.15);
    /* Override .nav-inner ul flex to make vertical */
    display: block;
}
#lang-menu li {
    list-style: none;
    padding: 0;
    /* Ensure vertical stacking */
    display: block;
}
#lang-menu li a {
    /* Remove all default link styling */
    all: unset;
    /* Re-apply needed layout styles (match theme-opt) */
    display: flex;
    align-items: center;
    gap: 0.5em;
    width: 100%;
    padding: 0.4rem 0.75rem;
    font-size: 0.9rem;
    text-align: left;
    cursor: pointer;
    white-space: nowrap;
    box-sizing: border-box;
    /* Use the theme's text color */
    color: var(--pico-contrast);
    font-family: inherit;
    line-height: inherit;
}
/* Light theme: darker hover */
[data-theme="light"] #lang-menu li a:hover {
    background: rgba(0, 0, 0, 0.08);
}
/* Dark theme: lighter hover */
[data-theme="dark"] #lang-menu li a:hover {
    background: rgba(255, 255, 255, 0.1);
}
.flag {
    width: 20px;
    height: 14px;
    object-fit: cover;
    border: 1px solid rgba(0,0,0,.1);
    flex-shrink: 0;
}

/* ---- Theme dropdown ---- */
.theme-switcher {
    position: relative;
    display: inline-block;
}
.theme-switcher > button {
    --pico-form-element-spacing-vertical: 0.25rem;
    --pico-form-element-spacing-horizontal: 0.5rem;
    font-size: 0.85rem;
    display: inline-flex;
    align-items: center;
    gap: 0.4em;
    color: var(--pico-color);
    border-color: var(--pico-muted-border-color);
}
#theme-menu {
    position: absolute;
    right: 0;
    top: calc(100% + 4px);
    z-index: 200;
    min-width: 110px;
    list-style: none;
    margin: 0;
    padding: 0.25rem 0;
    background: var(--pico-card-background-color, #fff);
    border: 1px solid var(--pico-muted-border-color, #ccc);
    border-radius: var(--pico-border-radius, 4px);
    box-shadow: 0 4px 12px rgba(0,0,0,.15);
    /* Override .nav-inner ul flex to make vertical */
    display: block;
}
#theme-menu li {
    list-style: none;
    padding: 0;
    /* Ensure vertical stacking */
    display: block;
}
#theme-menu .theme-opt {
    /* Remove all PicoCSS button styling */
    all: unset;
    /* Re-apply needed layout styles */
    display: flex;
    align-items: center;
    gap: 0.5em;
    width: 100%;
    padding: 0.4rem 0.75rem;
    font-size: 0.9rem;
    text-align: left;
    cursor: pointer;
    white-space: nowrap;
    box-sizing: border-box;
    /* Use the theme's text color */
    color: var(--pico-contrast);
    font-family: inherit;
    line-height: inherit;
}
/* Light theme: darker hover */
[data-theme="light"] #theme-menu .theme-opt:hover {
    background: rgba(0, 0, 0, 0.08);
}
/* Dark theme: lighter hover */
[data-theme="dark"] #theme-menu .theme-opt:hover {
    background: rgba(255, 255, 255, 0.1);
}
#theme-menu .t-icon,
#theme-menu .t-label {
    color: inherit;
}

/* ---- Layout ---- */
main.container {
    max-width: 1440px;
    /* Prevent page-level horizontal scroll; wide tables scroll within main */
    overflow-x: auto;
}

/* ---- Dashboard nav lists ---- */
.nav-list {
    list-style: none;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-bottom: 1rem;
}
.nav-list li {
    list-style: none;
    padding: 0;
}
.nav-list [role="button"] {
    --pico-form-element-spacing-vertical:   0.3rem;
    --pico-form-element-spacing-horizontal: 0.7rem;
    font-size: 0.9rem;
}

/* ---- Table density ---- */
td, th { padding: 0.35rem 0.6rem; }

/* ---- Action cells ---- */
td.actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.3rem;
    --pico-form-element-spacing-vertical:   0.2rem;
    --pico-form-element-spacing-horizontal: 0.4rem;
}
td.actions [role="button"],
td.actions button {
    font-size: 0.8rem;
    margin-bottom: 0;
    white-space: nowrap;
}

/* ---- Forms ---- */
main form:not(.wide-form) { max-width: 640px; }
details { margin: 1rem 0; }
details summary { cursor: pointer; }
details[open] summary { margin-bottom: 0.75rem; }

/* ---- Icon spacing ---- */
[role="button"] span[aria-hidden],
button span[aria-hidden] {
    display: inline-block;
    margin-right: 0.2em;
}

/* ---- Headings ---- */
h1 { font-size: 1.6rem;  margin-bottom: 0.5rem; }
h2 { font-size: 1.35rem; margin-bottom: 0.4rem; }
h3 { font-size: 1.1rem;  margin-bottom: 0.3rem; }

/* ---- QR code: always show on white so dark-mode doesn't hide black paths ---- */
.qr-wrap {
    display: inline-block;
    background: #ffffff;
    padding: 0.5rem;
    border-radius: 4px;
    line-height: 0;  /* remove gap below inline SVG */
}
.qr-wrap svg { display: block; width: 200px; height: 200px; }

/* ---- Breadcrumb nav ---- */
nav[aria-label] {
    margin-bottom: 1rem;
}
nav[aria-label] > ul {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    list-style: none;
    margin: 0;
    padding: 0.4rem 0.75rem;
    background: var(--pico-card-sectioning-background-color, rgba(0,0,0,.04));
    border-left: 3px solid var(--pico-primary);
    border-radius: 0 var(--pico-border-radius, 4px) var(--pico-border-radius, 4px) 0;
    font-size: 0.88rem;
    gap: 0;
}
nav[aria-label] > ul > li {
    list-style: none;
    padding: 0;
    display: flex;
    align-items: center;
}
nav[aria-label] > ul > li + li::before {
    content: "›";
    margin: 0 0.5em;
    color: var(--pico-muted-color);
}
/* Back arrow on every ancestor link */
nav[aria-label] > ul > li a::before {
    content: "\2190\00a0";  /* ← + nbsp */
}
/* Current page (last item, no link) shown as muted */
nav[aria-label] > ul > li:last-child:not(:first-child) {
    color: var(--pico-muted-color);
}

/* === Utility classes (replaces inline styles) === */
.table-scroll { overflow-x: auto; }
.login-card { max-width: 380px; margin: 4rem auto; }
.center-card { max-width: 420px; margin: 4rem auto; }
.article-narrow { max-width: 400px; }
.btn-del-form { display: inline-flex; align-items: center; margin: 0; }
.btn-group { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-bottom: 1rem; }
.mt-sm { margin-top: 0.75rem; }
.mb-0 { margin-bottom: 0; }
.input-code { max-width: 10rem; }
.secret-code { font-size: 1rem; letter-spacing: 0.15em; word-break: break-all; }
.uri-code { word-break: break-all; font-size: 0.75rem; }
.totp-revoke-summary { cursor: pointer; color: var(--pico-del-color, #c0392b); }
.nav-logo-link { text-decoration: none; color: inherit; }
.nav-logout-btn {
    --pico-form-element-spacing-vertical: 0.25rem;
    --pico-form-element-spacing-horizontal: 0.5rem;
    font-size: 0.85rem;
}
.filter-form { display: flex; gap: 1rem; align-items: center; }
.filter-label { margin: 0; }

/* === Debt/credit colouring (global, replaces per-template <style> blocks) === */
td.debt, th.debt, .debt { color: var(--pico-color-red-500, #e53e3e); font-weight: bold; }
td.credit, th.credit, .credit { color: var(--pico-color-green-500, #38a169); }
td.unpaid { background: color-mix(in srgb, #e53e3e 10%, transparent); }
td.unpaid-current { background: color-mix(in srgb, #e53e3e 4%, transparent); }

/* === Order buttons (compact up/down arrows) === */
.btn-order {
    --pico-form-element-spacing-vertical: 0.1rem;
    --pico-form-element-spacing-horizontal: 0.3rem;
    font-size: 0.7rem;
    min-width: 1.6rem;
    padding: 0.1rem 0.3rem;
}
.btn-order[disabled] {
    opacity: 0.25;
    pointer-events: none;
}

/* === Annual report: synchronized column widths across both tables === */
.annual-table { table-layout: fixed; }
.annual-table td, .annual-table th {
    padding: 0.25rem 0.4rem;
    white-space: nowrap;
}
col.col-apt    { width: 50px; }
col.col-owner  { width: 130px; }
col.col-month  { width: 72px; }
col.col-total  { width: 80px; }
col.col-credit { width: 70px; }
col.col-debt   { width: 70px; }
/* Vertical separators: after owner (before months), after total, after credit */
col.col-sep-after { border-right: 1px solid var(--pico-table-border-color); }
.annual-table .owner-col { white-space: normal; font-size: 0.82rem; }
.annual-table .cat-name  { font-size: 0.82rem; }

/* Mute zero values in reports */
.annual-table td:has(.zero-value),
.annual-table td .zero-value {
    opacity: 0.5;  /* 50% visible - balanced for both themes */
}

/* Total column highlight */
[data-theme="light"] .col-total-highlight {
    background: rgba(0, 0, 0, 0.06);
}
[data-theme="dark"] .col-total-highlight {
    background: rgba(255, 255, 255, 0.08);
}

/* === Minor (infrequent) action button === */
.btn-minor {
    --pico-form-element-spacing-vertical: 0.2rem;
    --pico-form-element-spacing-horizontal: 0.5rem;
    font-size: 0.8rem;
}

/* === Temporal history action column === */
td.row-actions {
    white-space: nowrap;
    display: flex;
    gap: 0.3rem;
    align-items: center;
    flex-wrap: wrap;
}
td.row-actions .btn-del-form { display: inline; }

/* ---- Expense form: previous amount hint ---- */
.muted-hint {
    display: block;
    color: var(--pico-muted-color);
    font-size: 0.85em;
    margin-top: 0.2em;
}

#expense-prev-value {
    cursor: pointer;
    text-decoration: underline dotted;
}
#expense-prev-value:hover {
    color: var(--pico-primary);
}

th[data-sort-col] {
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
}
th[data-sort-col]:hover {
    color: var(--pico-primary);
}
.sort-icon {
    font-size: 0.8em;
    opacity: 0.7;
}

/* ---- Owner name cell ---- */
.owner-name {
    font-size: 0.85em;
    line-height: 1.4;
    display: inline-flex;
    flex-direction: column;
    justify-content: center;
}
.owner-secondary {
    display: block;
    color: var(--pico-muted-color);
}
td.owner-col {
    vertical-align: middle;
}
