/* ============================================================
   site.css
   Shared theme, in the style of server.pro: Bootstrap 5.3 with its
   light and dark mode (data-bs-theme, set by theme.js), one system
   sans-serif font, one blue accent.
   Page stylesheets only use the tokens below, never colour values.
   Import on every page.
   ============================================================ */

/* ── Design tokens ────────────────────────────────────────── */
:root {
    /* One font for everything: the system sans-serif stack (no web fonts).
       --mono / --display are kept as names so older rules keep working; they are the same font. */
    --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
    --display: var(--font);
    --mono: var(--font);
    --code: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; /* only for real code and addresses */
    --radius: 12px;
}

/* Dark (default look, as on server.pro) */
:root,
[data-bs-theme="dark"] {
    --bg: #212529;
    --bg2: #1a1e23; /* cards */
    --bg3: #2b3036; /* inputs, hover */
    --nav: #1a1e23;
    --border: rgba(255, 255, 255, 0.10);
    --border2: rgba(255, 255, 255, 0.20);
    --accent: #2f6bed; /* white text on it: 4.9:1 */
    --accent-hover: #4a80f5;
    --accent-text: #7fa8ff; /* accent used as text on dark: 7:1 */
    --text: #e9ecef;
    --muted: #adb5bd; /* 8:1 on --bg2 */
    --good: #4ade80;
    --warn: #fbbf24;
    --danger: #ff8080;
    --purple: #c4a1ff;
}

[data-bs-theme="light"] {
    --bg: #f4f6f9;
    --bg2: #ffffff;
    --bg3: #eef1f5;
    --nav: #ffffff;
    --border: rgba(0, 0, 0, 0.12);
    --border2: rgba(0, 0, 0, 0.25);
    --accent: #1f5fe0; /* white text on it: 5.6:1 */
    --accent-hover: #174bb5;
    --accent-text: #1a4fc0; /* 6.5:1 on white */
    --text: #212529;
    --muted: #5b6570; /* 5.9:1 on white */
    --good: #0b7a43;
    --warn: #8a5a00;
    --danger: #c62828;
    --purple: #7b3fc4;
}

/* ── Reset & Base ─────────────────────────────────────────── */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html,
body {
    height: 100%;
}

body {
    font-size: 15px;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    background-color: var(--bg);
    color: var(--text);
    font-family: var(--display);
}

main {
    flex: 1 0 auto;
    min-width: 0;
    max-width: 100%;
    padding-bottom: 48px;
}

/* ── Navbar ───────────────────────────────────────────────── */
.navbar {
    background-color: var(--nav) !important;
    border-bottom: 1px solid var(--border);
    --bs-navbar-color: var(--muted);
    --bs-navbar-hover-color: var(--text);
    --bs-navbar-active-color: var(--text);
}

.navbar .nav-link {
    border-radius: 8px;
    padding: 8px 14px;
}

/* current page: filled pill (set by site.js) */
.navbar .nav-link.active {
    background: var(--bg3);
    color: var(--text);
}

.navbar-brand {
    color: var(--text);
    font-weight: 600;
}

/* ── Footer ───────────────────────────────────────────────── */
.footer {
    flex-shrink: 0;
    background: var(--nav);
    padding: 10px 0 0;
    color: var(--muted);
    border-top: 1px solid var(--border);
}

/* ── Divider ──────────────────────────────────────────────── */
hr {
    border: none;
    border-top: 1px solid var(--border);
}

/* ── Utility ──────────────────────────────────────────────── */
.bg-primary {
    background-color: var(--bg2) !important;
}

.content {
    flex: 1;
}

/* ── Page Header Bar ──────────────────────────────────────── */
.page-header {
    padding: 36px 0 8px;
}

.page-header h1,
.page-header h2 {
    font-size: clamp(22px, 4vw, 32px);
    font-weight: 800;
    letter-spacing: -0.02em;
    line-height: 1;
    color: var(--text);
    margin: 0 0 6px;
}

.page-header h1 .dim {
    color: var(--muted);
    font-weight: 400;
}

.page-header .subtitle {
    font-family: var(--mono);
    font-size: 14px;
    color: var(--muted);
    letter-spacing: 0.04em;
    margin: 0;
}

/* ── Cards Grid ───────────────────────────────────────────── */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(280px, 100%), 1fr));
    gap: 16px;
    padding: 0 28px;
}

/* ── Individual Card ──────────────────────────────────────── */
.card {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: 14px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    cursor: pointer;
    animation: fadeUp 0.4s ease both;
    transition: border-color 0.2s, transform 0.2s, background 0.2s;
}

.card:hover {
    border-color: var(--border2);
    background: var(--bg3);
    transform: translateY(-3px);
}


.card:hover .arrow-icon {
    color: var(--accent);
    transform: translate(2px, -2px);
}

/* ── Card actions (edit / delete) ─────────────────────────── */
.card-actions {
    display: flex;
    gap: 8px;
    padding: 10px 16px 14px;
    border-top: 1px solid var(--border);
}

.card-action-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-family: var(--mono);
    font-size: 14px;
    color: var(--text);
    background: transparent;
    border: 1px solid var(--border2);
    border-radius: 8px;
    padding: 6px 12px;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.2s, border-color 0.2s;
}

.card-action-btn:hover {
    background: var(--bg3);
    color: var(--text);
}

.card-action-danger {
    color: var(--danger);
    border-color: rgba(255, 107, 107, 0.35);
}

.card-action-danger:hover {
    background: rgba(255, 107, 107, 0.08);
    color: var(--danger);
}

.btn-primary-dark.btn-danger-dark {
    background: var(--danger);
}

.btn-primary-dark.btn-danger-dark:hover {
    background: var(--danger);
}

/* ── Dark modals (shared) ─────────────────────────────────── */
.modal-content {
    background: var(--bg2);
    color: var(--text);
    border: 1px solid var(--border2);
    border-radius: 14px;
}

.modal-header,
.modal-footer {
    border-color: var(--border);
}

.modal-title {
    font-weight: 800;
    letter-spacing: -0.01em;
}

/* ── Hover Effect ─────────────────────────────────────────── */
.hover-effect {
    transition: background-color 0.2s, transform 0.2s, border-color 0.2s;
}

.hover-effect:hover {
    background-color: var(--bg3);
    transform: translateY(-3px);
    border-color: var(--border2);
}

.hover-effect:hover .card-title {
    color: var(--accent);
}

/* ── Shared Button ────────────────────────────────────────── */
.btn-primary-dark {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--accent);
    color: #fff;
    font-family: var(--display);
    font-size: 14px;
    font-weight: 600;
    letter-spacing: 0.04em;
    border: none;
    border-radius: 8px;
    padding: 10px 24px;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.2s, transform 0.15s;
    white-space: nowrap;
}

.btn-primary-dark:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
    color: #fff;
    text-decoration: none;
}

/* ── Shared Animation ─────────────────────────────────────── */
@keyframes fadeUp {
    from {
        opacity: 0;
        transform: translateY(16px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ── Shared Form Elements ─────────────────────────────────── */
.form-label {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 6px;
}

.form-control,
.form-select {
    background: var(--bg3);
    border: 1px solid var(--border2);
    border-radius: 8px;
    color: var(--text);
    font-family: var(--mono);
    font-size: 14px;
    padding: 10px 14px;
    transition: border-color 0.2s, background 0.2s;
}

.form-control:focus,
.form-select:focus {
    background: var(--bg3);
    border-color: var(--accent);
    color: var(--text);
    box-shadow: 0 0 0 3px rgba(79, 140, 255, 0.12);
    outline: none;
}

.form-control::placeholder {
    color: var(--muted);
}

.form-select option {
    background: var(--bg3);
    color: var(--text);
}

.form-section-label {
    font-family: var(--mono);
    font-size: 13px;
    font-weight: 600;
    color: var(--muted);
    letter-spacing: 0.1em;
    text-transform: uppercase;
    margin-bottom: 14px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}

/* ── Alerts ───────────────────────────────────────────────── */
.alert-box {
    display: flex;
    align-items: center;
    gap: 10px;
    font-family: var(--mono);
    font-size: 14px;
    border-radius: 8px;
    padding: 10px 14px;
    margin-bottom: 20px;
}

.alert-box-error {
    color: var(--danger);
    background: rgba(255, 107, 107, 0.08);
    border: 1px solid rgba(255, 107, 107, 0.25);
}

.alert-box-ok {
    color: var(--good);
    background: rgba(61, 232, 154, 0.08);
    border: 1px solid rgba(61, 232, 154, 0.25);
}

.multi-filter {
    position: relative;
}

.multi-filter-toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.multi-filter-toggle::after {
    content: '▾';
    font-size: 14px;
    color: var(--muted);
}

/* At least one option ticked */
.multi-filter-toggle.active {
    border-color: var(--accent);
    color: var(--text);
}

.multi-filter-menu {
    min-width: 220px;
    max-height: 280px;
    overflow-y: auto;
    padding: 6px;
    background: var(--bg3);
    border: 1px solid var(--border2);
    border-radius: 10px;
}

.multi-filter-option {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0;
    padding: 7px 10px;
    border-radius: 6px;
    font-family: var(--mono);
    font-size: 14px;
    color: var(--text);
    cursor: pointer;
}

.multi-filter-option:hover {
    background: var(--bg2);
}

.multi-filter-option input {
    accent-color: var(--accent);
}


/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 600px) {
    .main {
        min-width: 0;
    }

    .header-bar,
    .filters,
    .grid {
        padding-left: 16px;
        padding-right: 16px;
    }

    .score-value {
        font-size: 15px;
    }
}

/* ── Shared components (P2.1) ─────────────────────────────── */

/* Outlined button, next to .btn-primary-dark */
.btn-ghost {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: transparent;
    color: var(--text);
    font-size: 14px;
    font-weight: 600;
    border: 1px solid var(--border2);
    border-radius: 8px;
    padding: 9px 20px;
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
    transition: background 0.2s, border-color 0.2s;
}

.btn-ghost:hover {
    background: var(--bg3);
    color: var(--text);
}

:focus-visible {
    outline: 2px solid var(--accent-text);
    outline-offset: 2px;
}

/* Centred page title, as on server.pro */
.page-title {
    text-align: center;
    padding: 36px 0 20px;
}

.page-title h1 {
    font-size: clamp(26px, 4vw, 36px);
    font-weight: 700;
    margin: 0 0 4px;
}

.page-title p {
    color: var(--muted);
    margin: 0;
}

.page-container {
    width: min(1000px, calc(100% - 32px));
    margin: 0 auto;
}

/* Small uppercase label above a card */
.section-label {
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--muted);
    margin: 0 0 10px;
}

/* Static card: same look as .card, not clickable */
.panel {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px 24px;
    margin-bottom: 24px;
}

.panel > :last-child {
    margin-bottom: 0;
}

.panel-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 1fr));
    gap: 0 24px;
}

/* Full-width segmented tabs with an accent underline */
.tabs-seg {
    display: flex;
    overflow-x: auto;
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 28px;
}

.tabs-seg .tab-link {
    flex: 1 0 auto;
    text-align: center;
    padding: 16px 20px;
    color: var(--muted);
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
    border-bottom: 2px solid transparent;
}

.tabs-seg .tab-link + .tab-link {
    border-left: 1px solid var(--border);
}

.tabs-seg .tab-link:hover {
    color: var(--text);
    background: var(--bg3);
}

.tabs-seg .tab-link.active {
    color: var(--text);
    border-bottom-color: var(--accent);
}

/* Status badge: green outline for good, others via modifiers */
.badge-soft {
    display: inline-block;
    font-size: 13px;
    font-weight: 600;
    color: var(--good);
    border: 1px solid currentColor;
    border-radius: 6px;
    padding: 2px 10px;
}

.badge-soft.warn {
    color: var(--warn);
}

.badge-soft.danger {
    color: var(--danger);
}

.badge-soft.muted {
    color: var(--muted);
}

/* List row with thin divider */
.list-row {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 14px 0;
    border-bottom: 1px solid var(--border);
}

.list-row:last-child {
    border-bottom: none;
}

/* Theme chooser buttons */
.theme-choice {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.theme-choice button {
    flex: 1 1 140px;
}

.theme-choice button.active {
    border-color: var(--accent);
    box-shadow: 0 0 0 1px var(--accent);
}

/* Account dropdown in the navbar */
.account-menu .dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
}

.account-menu form {
    margin: 0;
}

.account-menu .dropdown-item.btn-reset {
    width: 100%;
    background: none;
    border: none;
    text-align: left;
}

@media (max-width: 600px) {
    main {
        min-width: 0;
    }
}


/* ── Responsive (mobile first fixes) ──────────────────────── */

/* Long names, addresses and links must wrap instead of widening the page */
.panel,
.card,
.list-row,
.device-info {
    overflow-wrap: anywhere;
}

img,
video {
    max-width: 100%;
}

.device-row {
    flex-wrap: wrap;
}

.filters-right {
    flex-wrap: wrap;
}

/* Collapsed navbar (below the lg breakpoint of Bootstrap, 992px): full-width, easy to tap entries */
@media (max-width: 991.98px) {
    .navbar .navbar-nav {
        padding-top: 8px;
        gap: 8px;
    }

    .navbar .nav-link {
        padding: 12px 14px;
    }

    .navbar .btn-ghost,
    .navbar .btn-primary-dark {
        width: 100%;
        justify-content: center;
    }

    .navbar .account-menu {
        width: 100%;
    }
}

/* Tablets and phones */
@media (max-width: 768px) {
    .page-container {
        width: calc(100% - 24px);
    }

    body .grid,
    body .header-bar,
    body .filters,
    body .profile-pad {
        padding-left: 16px;
        padding-right: 16px;
    }

    body .grid-flush {
        padding-left: 0;
        padding-right: 0;
    }

    body .header-bar {
        align-items: flex-start;
        padding-top: 24px;
    }

    body .filters-left,
    body .filters-right {
        width: 100%;
    }

    .page-title {
        padding: 24px 12px 16px;
    }

    .panel {
        padding: 16px;
    }

    /* tabs scroll sideways instead of squeezing; the active tab stays readable */
    .tabs-seg .tab-link {
        padding: 14px 16px;
    }

    .theme-choice button {
        flex: 1 1 100%;
    }

    .login-card {
        padding: 20px 16px;
    }

    .navbar-brand {
        font-size: 16px;
    }

    .navbar-brand img {
        width: 32px;
        height: 32px;
    }

    /* modals use the whole width */
    .modal-dialog {
        margin: 8px;
    }
}

/* Touch screens: comfortable targets (44px, the usual minimum) */
@media (pointer: coarse) {
    .btn-ghost,
    .btn-primary-dark,
    .card-action-btn,
    .um-btn,
    .filter-chip,
    .sort-btn,
    .form-control,
    .form-select {
        min-height: 44px;
    }

    .dropdown-item {
        padding-top: 12px;
        padding-bottom: 12px;
    }
}

/* Very small phones */
@media (max-width: 380px) {
    body {
        font-size: 14px;
    }

    .navbar-brand {
        max-width: 70%;
        white-space: normal;
        line-height: 1.2;
    }
}

/* ── Password strength meter (advice only, see password-strength.js) ── */
.pw-meter {
    margin-top: 8px;
    --pw-colour: var(--muted);
}

.pw-meter[data-level="very-weak"] {
    --pw-colour: var(--danger);
}

.pw-meter[data-level="weak"] {
    --pw-colour: var(--danger);
}

.pw-meter[data-level="okay"] {
    --pw-colour: var(--warn);
}

.pw-meter[data-level="good"] {
    --pw-colour: var(--good);
}

.pw-meter[data-level="strong"] {
    --pw-colour: var(--good);
}

.pw-bar {
    height: 6px;
    border-radius: 3px;
    background: var(--bg3);
    overflow: hidden;
}

.pw-bar > span {
    display: block;
    height: 100%;
    width: var(--pw-fill, 0%);
    background: var(--pw-colour);
    transition: width 0.2s, background 0.2s;
}

/* the text says it too: colour is never the only signal */
.pw-label {
    margin: 6px 0 0;
    font-size: 14px;
    font-weight: 600;
    color: var(--pw-colour);
}

.pw-tips {
    margin: 4px 0 0;
    padding-left: 18px;
    font-size: 13px;
    color: var(--muted);
}

/* ── Show-password button (password-toggle.js) ────────────── */
.password-input {
    padding-right: 2.75rem;
}

.password-toggle {
    position: absolute;
    right: 0;
    width: 2.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: 0;
    color: var(--muted);
    cursor: pointer;
}

.password-toggle:hover,
.password-toggle:focus-visible {
    color: var(--text);
}
