/*
 * AVION Modern for the public account pages (sign-in, 2FA code, forgot password, registration, redeem link), the installer
 * and the start page.
 * Loaded after app.css only on these pages (body.auth-modern); it re-maps app.css colour variables to the palette of
 * the browser administration (admin-src/src/styles.css, design "modern") and adjusts a few fixed values.
 * Pure CSS: works without JavaScript, follows html[data-theme] (light | dark | system) like app.css.
 */
@font-face { font-family: 'Inter'; font-style: normal; font-weight: 100 900; font-display: swap; src: url('fonts/inter-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+2074,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD; }
@font-face { font-family: 'Inter'; font-style: normal; font-weight: 100 900; font-display: swap; src: url('fonts/inter-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02AF,U+0304,U+0308,U+0329,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF; }
@font-face { font-family: 'Inter'; font-style: normal; font-weight: 100 900; font-display: swap; src: url('fonts/inter-cyrillic.woff2') format('woff2');
  unicode-range: U+0301,U+0400-045F,U+0490-0491,U+04B0-04B1,U+2116; }

body.auth-modern {
  --bg: #f8fafc; --surface: #fff; --ink: #0f172a; --muted: #64748b; --line: #e2e8f0; --soft: #f1f5f9;
  --accent: #1a7562; --secondary: #4db8a5; --primary: #1a7562;
  --error-bg: #fef2f2; --error-ink: #b91c1c; --shadow: 0 1px 2px rgb(15 23 42 / .04), 0 20px 40px -24px rgb(15 23 42 / .25);
  --auth-head: #fff; --auth-side: #f1f5f9; --auth-mark: #1a7562; --auth-mark-ink: #fff; --auth-ok: #047857;
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
}
html[data-theme="dark"] body.auth-modern {
  --bg: #0f0f13; --surface: #1a1a24; --ink: #e2e8f0; --muted: #94a3b8; --line: #2a2a3a; --soft: #131319;
  --accent: #4db8a5; --secondary: #28987e; --primary: #1a7562;
  --error-bg: rgb(248 113 113 / .1); --error-ink: #f87171; --shadow: 0 25px 50px -12px rgb(0 0 0 / .6);
  --auth-head: #16161f; --auth-side: #0f0f13; --auth-mark: #1a7562; --auth-mark-ink: #fff; --auth-ok: #34d399;
}
@media (prefers-color-scheme: dark) {
  html[data-theme="system"] body.auth-modern {
    --bg: #0f0f13; --surface: #1a1a24; --ink: #e2e8f0; --muted: #94a3b8; --line: #2a2a3a; --soft: #131319;
    --accent: #4db8a5; --secondary: #28987e; --primary: #1a7562;
    --error-bg: rgb(248 113 113 / .1); --error-ink: #f87171; --shadow: 0 25px 50px -12px rgb(0 0 0 / .6);
    --auth-head: #16161f; --auth-side: #0f0f13; --auth-mark: #1a7562; --auth-mark-ink: #fff; --auth-ok: #34d399;
  }
}

body.auth-modern { background: var(--bg); color: var(--ink); -webkit-font-smoothing: antialiased; }
body.auth-modern :focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Header: brand left, language/theme right */
.auth-modern .topbar { min-height: 64px; padding: 12px 24px; background: var(--auth-head); border-bottom: 1px solid var(--line); }
.auth-modern .brand { gap: 12px; font-size: 14px; letter-spacing: 0; color: var(--ink); }
.auth-modern .brand-mark { width: 32px; height: 32px; border-radius: 8px; background: var(--auth-mark); color: var(--auth-mark-ink); font-size: 14px; font-weight: 700; letter-spacing: 0; }
.auth-modern .brand small { color: var(--accent); font-size: 12px; font-weight: 500; letter-spacing: 0; margin-top: -2px; }
.auth-modern .brand-logo { height: 32px; border-radius: 8px; }
.auth-modern .preferences select, .auth-modern .preference-save { height: 36px; border-radius: 8px; background: var(--soft); border-color: var(--line); font-size: 12px; }

/* Language dialog (resources/views/language-menu.php): flag + short code in the header open the same dialog as in
   the administration (admin-src/src/components/LanguageDialog.tsx): search, three columns, "show more". */
.language-menu { margin-inline-start: auto; }
.language-menu summary { display: flex; align-items: center; gap: 8px; height: 36px; padding: 0 10px; border-radius: 8px; list-style: none; cursor: pointer; color: var(--muted); font-size: 12px; font-weight: 600; }
.language-menu summary::-webkit-details-marker { display: none; }
.language-menu summary:hover, .language-menu[open] summary { background: var(--soft); color: var(--ink); }
.language-menu img { border-radius: 2px; flex-shrink: 0; }
.language-chevron { width: 6px; height: 6px; border: solid currentColor; border-width: 0 1.5px 1.5px 0; transform: translateY(-2px) rotate(45deg); }
.language-menu[open] .language-chevron { transform: translateY(1px) rotate(-135deg); }
.language-menu[open]::before { content: ''; position: fixed; inset: 0; z-index: 40; background: rgb(0 0 0 / .5); }
.language-dialog { position: fixed; z-index: 50; top: 50%; left: 50%; transform: translate(-50%, -50%); width: min(40rem, calc(100% - 2rem)); max-height: calc(100dvh - 2rem); overflow-y: auto;
  background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 25px 50px -12px rgb(0 0 0 / .45); }
.language-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.language-head h2 { margin: 0; font-size: 16px; font-weight: 600; letter-spacing: 0; }
.language-close { width: 30px; height: 30px; border: 0; border-radius: 8px; background: none; color: var(--muted); font-size: 20px; line-height: 1; cursor: pointer; }
.language-close:hover { background: var(--soft); color: var(--ink); }
.language-body { padding: 20px; }
.language-filter { width: 100%; height: 42px; padding: 0 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--soft); color: var(--ink); font: inherit; font-size: 14px; }
.language-filter:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px rgb(26 117 98 / .2); }
.language-list { display: grid; grid-template-columns: 1fr; gap: 4px; margin: 16px 0 0; padding: 0; list-style: none; }
@media (min-width: 640px) { .language-list { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.language-list a, .language-list button { display: flex; align-items: center; gap: 12px; width: 100%; padding: 8px 12px; border: 0; border-radius: 8px; background: none; color: var(--muted); font: inherit; font-size: 14px; text-align: start; text-decoration: none; cursor: pointer; }
.language-list span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.language-share { margin-inline-start: auto; color: var(--muted); font-size: 11px; white-space: nowrap; }
.language-list a:hover, .language-list button:hover { background: var(--soft); color: var(--ink); }
.language-list [aria-current="true"] { background: rgb(26 117 98 / .15); color: var(--accent); }
.language-list [aria-current="true"]::after { content: '✓'; margin-inline-start: auto; }
.language-empty { margin: 0; padding: 24px 0; text-align: center; color: var(--muted); font-size: 14px; }
.language-more { display: block; width: 100%; min-height: 40px; margin: 16px 0 0; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--ink); font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; }
.language-more:hover { background: var(--soft); }

/* Installer sidebar and steps */
.auth-modern .sidebar { background: var(--auth-side); color: var(--ink); border-inline-end: 1px solid var(--line); }
.auth-modern .sidebar :focus-visible { outline-color: var(--accent); }
.auth-modern .sidebar .eyebrow { color: var(--accent); font-size: 10px; letter-spacing: .12em; }
.auth-modern .sidebar h1 { font-size: 26px; font-weight: 650; letter-spacing: -.02em; line-height: 1.2; }
.auth-modern .sidebar p { color: var(--muted); font-size: 13px; line-height: 1.6; }
.auth-modern .steps li { color: var(--muted); font-size: 13px; }
.auth-modern .steps li:not(:last-child)::after { background: var(--line); }
.auth-modern .step-number { border-color: var(--line); background: var(--surface); font-size: 11px; font-weight: 600; }
.auth-modern .steps .current { color: var(--ink); font-weight: 600; }
.auth-modern .steps .current .step-number { background: #1a7562; border-color: #1a7562; color: #fff; box-shadow: 0 0 0 4px rgb(26 117 98 / .15); }
.auth-modern .steps .done .step-number { color: var(--accent); border-color: rgb(26 117 98 / .45); }
.auth-modern .sidebar-bottom { color: var(--muted); font-size: 12px; }
.auth-modern .status-dot { background: var(--auth-ok); }
.auth-modern .topbar-note { font-size: 12px; }

/* Welcome illustration in the Modern palette */
.auth-modern .mini-nav { background: #1a7562; }
.auth-modern .mini-tag { background: #4db8a5; }
.auth-modern .visual-badge { background: #1a7562; color: #fff; }

/* Completion and locked installer */
.auth-modern .completion { max-width: 560px; padding: 44px 36px; }
.auth-modern .large-check { width: 56px; height: 56px; border-radius: 12px; background: rgb(26 117 98 / .12); color: var(--accent); font-size: 24px; }
.auth-modern .completion h2 { font-size: 28px; font-weight: 650; letter-spacing: -.02em; margin: 8px 0 10px; }
.auth-modern .form-actions { border-top-color: var(--line); }
.auth-modern .button.secondary { background: var(--surface); border-color: var(--line); color: var(--ink); }

/* Card */
.auth-modern .main { padding: 40px 16px; }
.auth-modern .panel { border-radius: 12px; border-color: var(--line); background: var(--surface); box-shadow: var(--shadow); }
.auth-modern .login { max-width: 420px; padding: 32px; }
/* Start-page diagnostics: wide enough for the permissions table (resources/views/startup.php). */
.auth-modern .startup { width: 100%; max-width: 920px; padding: 32px; }
.auth-modern .startup h1 { margin: 0 0 12px; font-size: 26px; font-weight: 650; letter-spacing: -.02em; color: var(--ink); }
.auth-modern .startup .startup-checks { margin-bottom: 20px; }
.startup-folders { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 6px !important; }
.startup-folders code { padding: 2px 8px; border-radius: 6px; background: var(--error-bg); color: var(--error-ink); font-size: 12px; }
.startup-folders code.found { background: rgb(4 120 87 / .12); color: var(--auth-ok); }
[data-startup-partial] p { margin: 0; }
@media (max-width: 640px) { .auth-modern .startup { padding: 22px 18px; } }
.auth-modern .login-symbol { width: 40px; height: 40px; border-radius: 10px; background: var(--auth-mark); color: var(--auth-mark-ink); font-size: 18px; font-weight: 700; margin-bottom: 20px; }
.auth-modern .eyebrow { color: var(--accent); font-size: 11px; font-weight: 600; letter-spacing: .12em; }
.auth-modern .login h1, .auth-modern .dashboard-intro h1 { font-size: 26px; font-weight: 650; letter-spacing: -.02em; }
.auth-modern .lead { font-size: 14px; line-height: 1.6; }

/* Fields, buttons, messages */
.auth-modern .field { font-size: 12px; font-weight: 500; color: var(--muted); gap: 6px; }
.auth-modern .field input, .auth-modern .field select, .auth-modern .field textarea { height: 42px; border-radius: 8px; background: var(--soft); border-color: var(--line); font-size: 14px; color: var(--ink); }
.auth-modern .field input:focus, .auth-modern .field select:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px rgb(26 117 98 / .2); }
.auth-modern .button { min-height: 42px; border-radius: 8px; font-size: 14px; font-weight: 600; }
.auth-modern .button.primary { background: #1a7562; border-color: #1a7562; color: #fff; }
.auth-modern .button.primary:hover { filter: brightness(1.08); }
.auth-modern .alert { border-radius: 8px; font-size: 13px; }
.auth-modern .alert.success { color: var(--auth-ok); background: var(--soft); border-color: currentColor; }
.auth-modern .note { border-radius: 0 8px 8px 0; border-inline-start-color: var(--accent); font-size: 12px; }
.auth-modern .subtle { font-size: 12px; }
.auth-modern a { color: var(--accent); }
.auth-modern .login-links { font-size: 13px; }
.auth-modern .remember { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); cursor: pointer; }
.auth-modern .remember input { width: 16px; height: 16px; accent-color: #1a7562; }
.passkey-login { display: grid; gap: 14px; margin-top: 18px; }
.passkey-login[hidden] { display: none; }
.passkey-login .button { width: 100%; }
.passkey-login .alert { margin: 0; }
.passkey-divider { display: flex; align-items: center; gap: 12px; margin: 0; color: var(--muted); font-size: 12px; }
.passkey-divider::before, .passkey-divider::after { content: ''; flex: 1; height: 1px; background: var(--line); }

/* Identity pages without a session (2FA code, forgot, register, redeem): heading, messages and form in one card like sign-in */
.auth-modern .identity-public { max-width: 440px; width: 100%; padding: 32px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); }
.auth-modern .identity-public .dashboard-intro { display: block; margin: 0 0 20px; }
.auth-modern .identity-public .dashboard-intro .lead { margin: 8px 0 0; }
.auth-modern .identity-public .panel { max-width: none; padding: 0; border: 0; background: transparent; box-shadow: none; }
.auth-modern .identity-public .panel > a { display: block; margin-top: 16px; text-align: center; font-size: 13px; }

.auth-modern .footer { color: var(--muted); font-size: 11px; padding: 16px 24px; }

/* File permissions (resources/views/permissions.php): table, state badges and the commands to copy */
.permissions { display: grid; gap: 12px; margin-top: 8px; min-width: 0; container: permissions / inline-size; }
.permissions h2 { margin: 0; font-size: 16px; font-weight: 600; letter-spacing: 0; }
.permissions .subtle, .permissions p { margin: 0; }
.permissions-scroll { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; }
.permissions-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.permissions-table th, .permissions-table td { padding: 10px 12px; text-align: start; vertical-align: top; border-bottom: 1px solid var(--line); }
.permissions-table thead th { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); background: var(--soft); }
.permissions-table tbody tr:last-child > * { border-bottom: 0; }
.permissions-table tbody th { font-weight: 500; overflow-wrap: anywhere; }
.permissions-table small { display: block; margin-top: 2px; color: var(--muted); font-size: 12px; }
.permissions-table code, .permissions-commands code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; }
.permission-state { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--soft); color: var(--muted); }
.permission-state.ok, .permission-state.later { background: rgb(4 120 87 / .12); color: var(--auth-ok); }
.permission-state.warn { background: rgb(180 83 9 / .12); color: #b45309; }
.permission-state.error { background: var(--error-bg); color: var(--error-ink); }
html[data-theme="dark"] .permission-state.warn { color: #fbbf24; }
@media (prefers-color-scheme: dark) { html[data-theme="system"] .permission-state.warn { color: #fbbf24; } }
.permissions-table td { white-space: normal; }
.permissions-table td code, .permissions-table .permission-state { white-space: nowrap; }
.permissions-table td:last-child { min-width: 140px; }
.permissions-table .permission-who { color: var(--ink); }
.permissions-table tbody tr[data-state="error"] > th { box-shadow: inset 3px 0 0 var(--error-ink); }
.permissions-table tbody tr[data-state="warn"] > th { box-shadow: inset 3px 0 0 #b45309; }
[dir="rtl"] .permissions-table tbody tr[data-state] > th { box-shadow: none; }
[dir="rtl"] .permissions-table tbody tr[data-state="error"] > th { box-shadow: inset -3px 0 0 var(--error-ink); }
[dir="rtl"] .permissions-table tbody tr[data-state="warn"] > th { box-shadow: inset -3px 0 0 #b45309; }
.permission-reasons { margin: 6px 0 0; padding-inline-start: 16px; color: var(--muted); font-size: 12px; line-height: 1.45; }
.permission-reasons li + li { margin-top: 2px; }
/* Too little room (narrow screen or the installer card): every row becomes a small card with labelled values
   instead of a squeezed or sideways-scrolling table. Measured on the section itself, not on the screen. */
@container permissions (max-width: 720px) {
    .permissions-scroll { overflow: visible; border: 0; border-radius: 0; }
    .permissions-table thead { display: none; }
    .permissions-table, .permissions-table tbody, .permissions-table tr, .permissions-table th, .permissions-table td { display: block; }
    .permissions-table tbody tr { margin-bottom: 10px; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
    .permissions-table tbody tr > * { border-bottom: 0; padding: 6px 12px; white-space: normal; min-width: 0; }
    .permissions-table tbody tr > th { padding-top: 10px; background: var(--soft); }
    .permissions-table td[data-label]::before { content: attr(data-label); display: block; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
    .permissions-table tbody tr > td:last-child { padding-bottom: 12px; }
}
/* Room for three values side by side: folder name on top, needed / current / state in one row (compact cards). */
@container permissions (min-width: 420px) and (max-width: 720px) {
    .permissions-table tbody tr { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .permissions-table tbody tr > th { grid-column: 1 / -1; }
    .permissions-table tbody tr > td { padding-bottom: 12px; }
    .permissions-table tbody tr > td[colspan] { grid-column: span 2; }
}
/* Installer password generator (resources/views/wizard.php, step "Administratorkonto") */
.password-generator { display: grid; gap: 10px; justify-items: start; }
.password-generator[hidden], .generated-password[hidden] { display: none; }
.generated-password { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; width: 100%; }
.generated-password code { flex: 1 1 220px; min-width: 0; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--soft); color: var(--ink); font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 15px; letter-spacing: .04em; overflow-wrap: anywhere; user-select: all; }
.password-generator .subtle { margin: 0; }
.permissions-commands { display: grid; gap: 8px; }
.permissions-root { display: grid; gap: 6px; }
.permissions-root[hidden] { display: none; }
.permissions-root input { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; }
.permissions-root small { color: var(--muted); font-size: 12px; }
.permissions-commands pre { margin: 0; padding: 12px 14px; overflow-x: auto; border: 1px solid var(--line); border-radius: 8px; background: var(--soft); color: var(--ink); white-space: pre; }
.permissions-commands .button { justify-self: start; }
