/* components.css — Nav, cards, tables, forms, buttons, focus styles */

/* Navigation */
header[role="banner"] {
    background-color: var(--ps-nav-bg, #1a1a2e);
    color: var(--ps-nav-text, #ffffff);
    padding: 0 1rem;
    position: sticky;
    top: 0;
    z-index: 100;
}

nav[role="navigation"] {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    max-width: 80rem;
    margin: 0 auto;
    min-height: 3.5rem;
}

.nav-brand {
    display: flex;
    align-items: center;
    text-decoration: none;
}

.nav-logo {
    height: 28px;
    width: auto;
    display: block;
}

.nav-logo-mini {
    display: none;
}

@media (max-width: 575px) {
    .nav-logo-full { display: none; }
    .nav-logo-mini { display: block; }
}

.nav-toggle {
    display: none;
    background: none;
    border: none;
    color: inherit;
    cursor: pointer;
    padding: 0.5rem;
}

/* Hamburger icon — three bars, animates to X when open */
.nav-toggle-icon {
    display: block;
    width: 1.25rem;
    height: 2px;
    background-color: currentColor;
    position: relative;
    transition: background-color 0.2s;
}

.nav-toggle-icon::before,
.nav-toggle-icon::after {
    content: '';
    display: block;
    width: 1.25rem;
    height: 2px;
    background-color: currentColor;
    position: absolute;
    left: 0;
    transition: transform 0.2s, top 0.2s;
}

.nav-toggle-icon::before { top: -6px; }
.nav-toggle-icon::after { top: 6px; }

.nav-toggle[aria-expanded="true"] .nav-toggle-icon {
    background-color: transparent;
}

.nav-toggle[aria-expanded="true"] .nav-toggle-icon::before {
    transform: rotate(45deg);
    top: 0;
}

.nav-toggle[aria-expanded="true"] .nav-toggle-icon::after {
    transform: rotate(-45deg);
    top: 0;
}

#nav-menu {
    display: flex;
    list-style: none;
    gap: 0.5rem;
    flex: 1;
}

#nav-menu a {
    color: inherit;
    text-decoration: none;
    padding: 0.5rem 0.75rem;
    border-radius: 0.25rem;
}

#nav-menu a:hover,
#nav-menu a[aria-current="page"] {
    background-color: rgba(255, 255, 255, 0.1);
}

.nav-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.nav-actions select {
    min-height: auto;
    width: auto;
    /* As wide as the choice shown (field-sizing), not the longest one
       listed; browsers without it keep the list's width */
    field-sizing: content;
    padding: 0.25rem 0.5rem;
    font-size: 0.8125rem;
    background-color: rgba(255, 255, 255, 0.1);
    color: inherit;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 0.25rem;
}

/* The open list, at every width: the pickers take the nav's light text
   and a see-through fill, and browsers that draw the list from the page
   would show those on their own white list, white on white. The list
   gets the theme's input colours instead. */
.nav-actions select option,
.nav-actions select optgroup {
    color: var(--ps-text-primary, #1a1a1a);
    background-color: var(--ps-input-bg, #ffffff);
}

/* Language picker: a globe, in the nav's text colour, before the name */
.lang-select {
    position: relative;
    display: inline-flex;
    align-items: center;
}

.lang-select::before {
    content: "";
    position: absolute;
    left: 0.45rem;
    width: 0.875rem;
    height: 0.875rem;
    background-color: currentColor;
    -webkit-mask: url(../img/globe.svg) no-repeat center / contain;
    mask: url(../img/globe.svg) no-repeat center / contain;
    opacity: 0.85;
    pointer-events: none;
}

.nav-actions .lang-select select {
    padding-left: 1.65rem;
    max-width: 11.5rem;
    text-overflow: ellipsis;
    min-width: 4.5rem;
}

/* Theme picker: a palette, shown only in the compact view below */
.theme-select {
    position: relative;
    display: inline-flex;
    align-items: center;
}

/* Compact view (the hamburger menu): the pickers show only what they
   need, so the bar never spills over: the theme a palette, the language
   a globe and its code (EN, DE, PT-BR; the language in use when it
   follows the browser). The select is still there, full size under the
   face drawn on it, and opens its list as ever, every name in full;
   screen readers hear the full name too. */
@media (max-width: 991px) {
    .theme-select::before {
        content: "";
        position: absolute;
        left: 0.5rem;
        width: 1rem;
        height: 1rem;
        background-color: currentColor;
        -webkit-mask: url(../img/palette.svg) no-repeat center / contain;
        mask: url(../img/palette.svg) no-repeat center / contain;
        opacity: 0.85;
        pointer-events: none;
    }
    .theme-select::after,
    .lang-select::after {
        content: "\25BE";
        position: absolute;
        right: 0.45rem;
        font-size: 0.75rem;
        line-height: 1;
        pointer-events: none;
    }
    .lang-select::after {
        content: attr(data-short) "\2002\25BE";
        font-size: 0.8125rem;
        letter-spacing: 0.02em;
    }
    .nav-actions .theme-select select,
    .nav-actions .lang-select select {
        appearance: none;
        -webkit-appearance: none;
        color: transparent;
        field-sizing: fixed;
        text-overflow: clip;
        min-width: 0;
    }
    .nav-actions .theme-select select { width: 3rem; }
    .nav-actions .lang-select select {
        width: calc(3.2rem + var(--short-len, 2) * 0.62em);
        max-width: none;
    }
}

/* Nav logout button with icon */
.nav-logout-form {
    display: inline;
}

.nav-logout-btn {
    background: none;
    border: none;
    color: inherit;
    cursor: pointer;
    padding: 0.5rem;
    min-height: auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.25rem;
    opacity: 0.8;
}

.nav-logout-btn:hover {
    background-color: rgba(255, 255, 255, 0.1);
    opacity: 1;
}

.nav-logout-btn svg {
    display: block;
}

/* The same, as the last item of the collapsed (hamburger) menu: only
   there, where it takes the icon's place */
.nav-menu-logout {
    display: none;
}

.nav-menu-logout form {
    margin: 0;
}

/* Laid out like the menu's links beside it (not as a button) */
.nav-menu-logout-btn {
    display: inline-flex;
    align-items: center;
    justify-content: flex-start;
    gap: 0.5rem;
    min-height: auto;
    padding: 0.625rem 0.75rem;
    /* The links' padding does not take up room (they are inline), so
       neither does this: the item spaced as they are */
    margin: -0.625rem 0;
    background: none;
    border: none;
    border-radius: 0.25rem;
    color: inherit;
    font: inherit;
    line-height: inherit;
    text-align: left;
    cursor: pointer;
}

.nav-menu-logout-btn:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

/* Dashboard main content — breathing room for rounded-corner cards */
#dashboard {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    padding: 1rem 2%;
}

.module-panel {
    flex: 1 1 100%;
    /* A panel never pushes the page wider than the screen: what is too
       wide for it (a table) scrolls inside it instead */
    min-width: 0;
}

/* LCD panels (modemStatus + systemInfo) sit side by side on wide screens */
#module-modemStatus,
#module-systemInfo {
    flex: 1 1 0;
    min-width: 280px;
    display: flex;
    flex-direction: column;
}

#module-modemStatus > section,
#module-systemInfo > section {
    flex: 1;
    display: flex;
    flex-direction: column;
}

#module-modemStatus .lcd-bezel,
#module-systemInfo .lcd-bezel {
    flex: 1;
    display: flex;
    flex-direction: column;
}

#module-modemStatus .lcd-screen,
#module-systemInfo .lcd-screen {
    flex: 1;
}

/* Side by side the two screens are one height: the rows of the shorter
   spread down it rather than leaving a gap at the bottom */
#module-modemStatus .lcd-screen,
#module-systemInfo .lcd-screen {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

/* One above the other on a phone: System Information first, so Modem
   Status sits with On Air and the radio panels read as one, with the
   system figures above to scroll past */
@media (max-width: 700px) {
    #module-modemStatus,
    #module-systemInfo {
        flex: 1 1 100%;
    }
    #module-core { order: -2; }
    #module-systemInfo { order: -1; }
}

/* Collapse navigation to hamburger on tablet and below */
@media (max-width: 991px) {
    .nav-toggle { display: block; }
    #nav-menu {
        display: none;
        flex-basis: 100%;
        flex-direction: column;
        padding: 0.5rem 0;
    }
    #nav-menu.open { display: flex; }
    #nav-menu a {
        padding: 0.625rem 0.75rem;
    }
    .nav-menu-logout { display: block; }
    .nav-actions .nav-logout-form { display: none; }
}

/* Cards / Panels */
.card {
    background-color: var(--ps-bg-secondary, #f8f9fa);
    border: 1px solid var(--ps-border, #dee2e6);
    border-radius: 0.5rem;
    padding: 1rem;
}

.card h2 {
    font-size: 1.125rem;
    margin-bottom: 0.75rem;
}

/* Phones: the dashboard's cards give their space to what is in them */
@media (max-width: 575px) {
    #dashboard .card { padding: 0.75rem; }
    #dashboard .card h2 { margin-bottom: 0.5rem; }
}

/* Tables */
table {
    width: 100%;
    border-collapse: collapse;
}

thead {
    background-color: var(--ps-table-header-bg, #e9ecef);
}

th, td {
    padding: 0.5rem 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--ps-border, #dee2e6);
}

th {
    font-weight: 600;
}

/* Forms */
.form-group {
    margin-bottom: 1rem;
}

label {
    display: block;
    margin-bottom: 0.25rem;
    font-weight: 500;
}

input[type="text"],
input[type="password"],
input[type="number"],
input[type="email"],
select,
textarea {
    width: 100%;
    padding: 0.5rem 0.75rem;
    font-size: 1rem;
    border: 1px solid var(--ps-input-border, #ced4da);
    border-radius: 0.25rem;
    background-color: var(--ps-input-bg, #ffffff);
    color: var(--ps-text-primary, #1a1a1a);
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--ps-accent, #0066cc);
}

input[aria-invalid="true"] {
    border-color: var(--ps-danger, #dc3545);
}

.error-message {
    color: var(--ps-danger-text, var(--ps-danger, #dc3545));
    font-size: 0.875rem;
    margin-top: 0.25rem;
}

/* Buttons */
button,
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 1.25rem;
    font-size: 1rem;
    font-weight: 500;
    border: none;
    border-radius: 0.25rem;
    cursor: pointer;
    background-color: var(--ps-accent-btn, var(--ps-accent, #0066cc));
    color: var(--ps-on-accent, var(--ps-text-inverse, #ffffff));
    text-decoration: none;
}

button:hover,
.btn:hover {
    background-color: var(--ps-accent-btn-hover, var(--ps-accent-hover, #0052a3));
}

button:disabled,
.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Small button variant */
.btn-sm {
    padding: 0.25rem 0.75rem;
    font-size: 0.8125rem;
}

.btn-secondary {
    background-color: transparent;
    color: var(--ps-text-primary, #1a1a1a);
    box-shadow: inset 0 0 0 1px var(--ps-border, #dee2e6);
}
.btn-secondary:hover {
    background-color: var(--ps-bg-secondary, #f8f9fa);
}

.btn-danger {
    background-color: var(--ps-danger, #dc3545);
}
.btn-danger:hover {
    background-color: #c82333;
}

.btn-warning {
    background-color: var(--ps-warning, #e67e22);
}
.btn-warning:hover {
    background-color: #d35400;
}

/* Status indicators */
.status-running { color: var(--ps-success-text, var(--ps-success, #28a745)); }
.status-stopped { color: var(--ps-text-secondary, #6c757d); }
.status-crashed { color: var(--ps-danger-text, var(--ps-danger, #dc3545)); }

/* Login page */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-container {
    width: 100%;
    max-width: 24rem;
    padding: 2rem;
}

/* The login form's buttons: back to the public dashboard (outlined) and
   Log In (the accent), a matched pair side by side */
.login-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}

.login-actions .btn,
.login-actions button {
    width: 100%;
    gap: 0.5rem;
}

.login-back svg {
    flex: none;
    transition: transform 0.15s ease;
}

.login-back:hover svg {
    transform: translateX(-3px);
}

@media (prefers-reduced-motion: reduce) {
    .login-back svg { transition: none; }
    .login-back:hover svg { transform: none; }
}

/* "Keep me logged in on this browser" */
.login-keep {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0.25rem 0 1rem;
    font-size: 0.9375rem;
    cursor: pointer;
}

.login-keep input {
    width: 1.125rem;
    height: 1.125rem;
    min-height: auto;
    margin: 0;
    flex: none;
    accent-color: var(--ps-accent, #0066cc);
}

.login-welcome {
    text-align: center;
    margin-bottom: 1rem;
}

.login-welcome h1 {
    font-size: 1.25rem;
    margin-bottom: 0.5rem;
}

.login-welcome p {
    font-size: 0.875rem;
    color: var(--ps-text-secondary, #6c757d);
}

.login-logo {
    height: 48px;
    width: 100%;
    margin-bottom: 1.5rem;
    background-color: var(--ps-text-primary, #1a1a1a);
    -webkit-mask-image: url(../img/logo-login.png);
    -webkit-mask-size: contain;
    -webkit-mask-repeat: no-repeat;
    -webkit-mask-position: center;
    mask-image: url(../img/logo-login.png);
    mask-size: contain;
    mask-repeat: no-repeat;
    mask-position: center;
}

@media (max-width: 575px) {
    .login-logo {
        height: 40px;
        -webkit-mask-image: url(../img/logo-login-mini.png);
        mask-image: url(../img/logo-login-mini.png);
    }
}

/* In-page dialog (PiStar.ask) */
.ps-dialog {
    max-width: min(28rem, calc(100vw - 2rem));
    width: 100%;
    padding: 1.25rem;
    border: 1px solid var(--ps-border, #dee2e6);
    border-radius: 0.5rem;
    background-color: var(--ps-bg-primary, #ffffff);
    color: var(--ps-text-primary, #1a1a1a);
}

.ps-dialog::backdrop {
    background: rgba(0, 0, 0, 0.45);
}

.ps-dialog-title {
    font-size: 1.125rem;
    margin: 0 0 0.5rem;
}

.ps-dialog-message {
    margin: 0 0 1rem;
    white-space: pre-line;
}

.ps-dialog-input {
    width: 100%;
    margin-bottom: 1rem;
}

.ps-dialog-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
}

/* A caller's callsign opens their look-up menu (pistar.js callButton):
   it looks like the callsign it was, with a pointer and a dotted
   underline when pointed at or focused. */
.call-menu-btn {
    display: inline;
    min-height: 0;
    padding: 0;
    margin: 0;
    border: 0;
    background: none;
    font: inherit;
    color: inherit;
    letter-spacing: inherit;
    text-align: inherit;
    cursor: pointer;
    text-decoration: none;
}
/* An area that opens it (Recent Activity's caller cell): all of it */
.call-menu-area {
    cursor: pointer;
}
.call-menu-btn:hover,
.call-menu-area:hover .call-menu-btn,
.call-menu-btn:focus-visible,
.call-menu-btn[aria-expanded="true"] {
    text-decoration: underline dotted;
    text-underline-offset: 0.2em;
    text-decoration-thickness: 1px;
}
.call-menu-btn:focus-visible {
    outline: 2px solid var(--ps-accent, #0066cc);
    outline-offset: 2px;
}
/* The menu: full-size rows, easy to hit with a pointer or a finger */
.call-menu {
    position: fixed;
    z-index: 150;
    min-width: 12rem;
    padding: 0.25rem 0;
    background: var(--ps-bg-secondary, #ffffff);
    color: var(--ps-text-primary, #1a1a1a);
    border: 1px solid var(--ps-border, #dee2e6);
    border-radius: 0.375rem;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
}
.call-menu-title {
    padding: 0.35rem 0.9rem 0.3rem;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    color: var(--ps-text-secondary);
    border-bottom: 1px solid var(--ps-border, #dee2e6);
    margin-bottom: 0.25rem;
}
.call-menu a {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    min-height: 2.75rem;
    padding: 0 0.9rem;
    color: inherit;
    text-decoration: none;
}
.call-menu a:hover,
.call-menu a:focus-visible {
    background: var(--ps-bg-tertiary, #e9ecef);
    color: var(--ps-accent-text, var(--ps-accent));
    outline: none;
}
.call-menu-ext {
    color: var(--ps-text-secondary);
    font-size: 0.85em;
}

/* Toggle switch (the admin pages' settings, and the public dashboard's
   own switches: Recent Activity's Compact) */
.toggle-switch {
    position: relative;
    width: 2.75rem;
    height: 1.5rem;
    flex-shrink: 0;
    margin-left: 0.5rem;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute;
}

.toggle-slider {
    position: absolute;
    inset: 0;
    background-color: var(--ps-text-secondary, #6c757d);
    border-radius: 0.75rem;
    cursor: pointer;
    transition: background-color 0.2s;
}

.toggle-slider::before {
    content: "";
    position: absolute;
    height: 1.125rem;
    width: 1.125rem;
    left: 0.1875rem;
    bottom: 0.1875rem;
    background-color: white;
    border-radius: 50%;
    transition: transform 0.2s;
}

.toggle-switch input:checked + .toggle-slider {
    background-color: var(--ps-success, #28a745);
}

.toggle-switch input:checked + .toggle-slider::before {
    transform: translateX(1.25rem);
}

.toggle-switch input:focus-visible + .toggle-slider {
    outline: 3px solid var(--ps-accent, #0066cc);
    outline-offset: 2px;
}

/* Smaller toggle for bridge items */
.toggle-switch-sm {
    width: 2.25rem;
    height: 1.25rem;
}

.toggle-switch-sm .toggle-slider::before {
    height: 0.875rem;
    width: 0.875rem;
    left: 0.1875rem;
    bottom: 0.1875rem;
}

.toggle-switch-sm input:checked + .toggle-slider::before {
    transform: translateX(1rem);
}

