/* ePoslovanje IdP — styled after the main platform's look (brand red
   #e23d3a, light surface, centered auth card). Plain CSS on purpose:
   the IdP renders a handful of Razor Pages and must not drag in a
   component framework. */
:root {
    --brand: #e23d3a;
    --brand-dark: #c33330;
    --ink: #1f2328;
    --ink-muted: #6b7280;
    --surface: #f6f7f9;
    --card: #ffffff;
    --line: #e3e6ea;
    --danger: #b91c1c;
}

* { box-sizing: border-box; }
html, body {
    margin: 0; padding: 0;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    color: var(--ink);
    background: var(--surface);
}
.container { max-width: 960px; margin: 0 auto; padding: 0 1rem; }

.topbar { background: var(--card); border-bottom: 1px solid var(--line); padding: 0.65rem 0; }
.topbar__inner {
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 1.25rem;
}
.topbar .brand { display: inline-flex; align-items: center; text-decoration: none; }
.topbar .brand img { height: 28px; display: block; }
.topbar nav { display: flex; gap: 1.1rem; align-items: center; }
.topbar nav a, .topbar nav .link, .topbar nav .user {
    color: var(--ink-muted); text-decoration: none;
    font-size: 0.95rem; line-height: 1; display: inline-flex; align-items: center;
    background: none; border: none; padding: 0; cursor: pointer; font-family: inherit;
}
.topbar nav .user { color: var(--ink); font-weight: 500; }
.topbar nav a:hover, .topbar nav .link:hover { color: var(--brand); }
/* The logout button rides inside a form — flex-align the form itself so
   the button sits on the same baseline as the neighbouring links. */
.topbar nav form.inline { display: inline-flex; align-items: center; margin: 0; }

/* The whole body is one flex column so the auth card sits in the visual
   middle of the viewport and the footer stays pinned to the bottom. */
body { min-height: 100vh; display: flex; flex-direction: column; }

/* ── Anonymous (auth) layout — toolbar-less; brand, then language, then card ──── */
.auth-main {
    flex: 1;
    /* width:100% is load-bearing: .container's `margin: 0 auto` makes
       this flex item shrink-to-fit otherwise, and the card's percentage
       width would then collapse to its content width. */
    width: 100%;
    /* Column so the brand wordmark + language switcher stack centered ABOVE the card,
       the whole group centered vertically + horizontally. */
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    padding: 1.5rem 1rem 2.5rem;
}

.auth-brand { display: block; margin-bottom: 1.25rem; }
.auth-brand img { height: 30px; display: block; }

/* The frame matches the rendered card's width — standard 46rem, or 31rem when the page
   uses card--narrow (login, forgot/reset, 2FA, …), detected with :has(). The card fills
   the frame (width:100%), so the absolutely-positioned language switcher lands inside the
   card, on the same row as its heading. The top/right offsets track the card's padding
   (standard 2.5rem 3rem; narrow 2.25rem 2.5rem) so the flag sits level with the title. */
.auth-card-frame { position: relative; width: 100%; max-width: 46rem; margin: 0 auto; }
.auth-card-frame:has(.card--narrow) { max-width: 31rem; }

/* top = the heading's vertical CENTRE (card padding-top + ~½ heading line-box);
   translateY(-50%) then centres the flag on that line so it's level with the title. */
.auth-lang { position: absolute; top: 3.45rem; right: 3rem; transform: translateY(-50%); display: flex; }
.auth-card-frame:has(.card--narrow) .auth-lang { top: 3.2rem; right: 2.5rem; }
footer { padding: 1.25rem 0; color: var(--ink-muted); text-align: center; font-size: 0.85rem; }

/* ── Signed-in app shell (mirrors the Blazor clients) ───────── */
.shell { flex: 1; display: flex; width: 100%; min-height: 0; }
.sidebar {
    width: 240px; flex-shrink: 0;
    background: var(--card); border-right: 1px solid var(--line);
    padding: 1.25rem 0.75rem;
}
.sidebar__section {
    font-size: 0.72rem; font-weight: 700; letter-spacing: 0.08em;
    text-transform: uppercase; color: var(--ink-muted);
    padding: 0 0.75rem; margin: 1.5rem 0 0.5rem;
}
.sidebar__section:first-child { margin-top: 0; }
.sidebar__link {
    display: flex; align-items: center; gap: 10px;
    padding: 0.55rem 0.75rem; border-radius: 8px; margin-bottom: 2px;
    color: var(--ink); text-decoration: none; font-size: 0.95rem;
}
.sidebar__link svg { width: 18px; height: 18px; fill: var(--ink-muted); flex-shrink: 0; }
.sidebar__link:hover { background: var(--surface); }
.sidebar__link.is-active { background: rgba(226, 61, 58, 0.08); color: var(--brand); font-weight: 600; }
.sidebar__link.is-active svg { fill: var(--brand); }

.shell__main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.shell__content { flex: 1; padding: 1.75rem; }
.shell__content .card { margin: 0; }
.shell__content .hub { max-width: 56rem; }

@media (max-width: 900px) {
    .shell { flex-direction: column; }
    .sidebar {
        width: 100%; display: flex; align-items: center; gap: 4px;
        overflow-x: auto; -webkit-overflow-scrolling: touch;
        border-right: 0; border-bottom: 1px solid var(--line);
        padding: 0.5rem 0.75rem;
    }
    .sidebar__section { display: none; }
    .sidebar__link { white-space: nowrap; padding: 0.45rem 0.7rem; margin: 0; }
    .shell__content { padding: 1rem; }
}

.hero { text-align: center; max-width: 30rem; }
.hero h1 { margin-top: 0; font-size: 1.8rem; }
.hero p { line-height: 1.6; }
.hero .actions { display: flex; gap: 0.75rem; justify-content: center; margin: 1.5rem 0; }
.hero .muted { color: var(--ink-muted); font-size: 0.85rem; }
.hero img.mark { height: 56px; margin-bottom: 1rem; }

/* Flag-dropdown language switcher — mirrors the Blazor clients' look. */
.lang-menu { position: relative; }
.lang-menu summary {
    list-style: none; cursor: pointer;
    display: flex; align-items: center;
    padding: 2px; border-radius: 4px;
}
.lang-menu summary::-webkit-details-marker { display: none; }
.lang-menu summary:hover { background: var(--surface); }
.lang-menu img.flag {
    width: 26px; height: 18px; display: block;
    border-radius: 2px; box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.15);
}
.lang-menu .menu {
    position: absolute; right: 0; top: calc(100% + 8px);
    background: var(--card); border: 1px solid var(--line);
    border-radius: 8px; box-shadow: 0 6px 16px rgba(16, 24, 40, 0.12);
    min-width: 165px; padding: 0.3rem; z-index: 50;
}
.lang-menu .menu a {
    display: flex; align-items: center; gap: 10px;
    padding: 0.45rem 0.6rem; border-radius: 6px;
    color: var(--ink); text-decoration: none; font-size: 0.95rem;
    white-space: nowrap;
}
.lang-menu .menu a:hover { background: var(--surface); }
.lang-menu .menu img.flag { width: 20px; height: 14px; }
.lang-menu .check { margin-left: auto; color: var(--brand); font-weight: 700; }
.muted { color: var(--ink-muted); }
.muted a { color: var(--brand); text-decoration: none; }
.muted a:hover { color: var(--brand-dark); }

.card {
    background: var(--card); padding: 2.5rem 3rem;
    border: 1px solid var(--line); border-radius: 10px;
    width: 100%; max-width: 46rem;
    box-shadow: 0 1px 3px rgba(16, 24, 40, 0.06);
}
/* Compact flows (forgot/reset password) — ~2/3 of the standard card. */
.card--narrow { max-width: 31rem; padding: 2.25rem 2.5rem; }
.card h1 { margin-top: 0; font-size: 1.4rem; }
.card h1::after {
    content: ""; display: block; width: 44px; height: 3px;
    background: var(--brand); border-radius: 2px; margin-top: 0.5rem;
}

.field { display: block; margin-bottom: 1rem; }
.field label { display: block; font-weight: 500; margin-bottom: 0.3rem; font-size: 0.9rem; }
.field input[type=text], .field input[type=email], .field input[type=password],
.field input[type=number], .field input:not([type]) {
    width: 100%; padding: 0.55rem 0.75rem;
    border: 1px solid #cfd4da; border-radius: 6px;
    font-size: 1rem; background: var(--card); font-family: inherit;
}
.field input:focus { outline: 2px solid var(--brand); outline-offset: -1px; border-color: var(--brand); }
.field.checkbox { display: flex; align-items: center; gap: 0.5rem; }
.field.checkbox label { margin-bottom: 0; font-weight: 400; }
.field.checkbox input { accent-color: var(--brand); }

.button {
    display: inline-block; padding: 0.55rem 1.4rem;
    font-size: 1rem; font-weight: 600;
    border: 0; border-radius: 6px;
    background: var(--brand); color: #fff;
    text-decoration: none; cursor: pointer; font-family: inherit;
}
.button:hover { background: var(--brand-dark); }
.button-secondary { background: var(--ink-muted); }
.button-secondary:hover { background: #4b5563; }

.text-danger { color: var(--danger); font-size: 0.85rem; }
[role=alert] ul { margin: 0 0 1rem; padding-left: 1.25rem; }

/* ── "Moj račun" hub (signed-in homepage) ───────────────────── */
.hub { width: 100%; max-width: 46rem; display: flex; flex-direction: column; gap: 1.25rem; }
.hub .card { max-width: none; }
.hub .card h2 { margin: 0 0 0.35rem; font-size: 1.15rem; }

/* One-shot success banner (TempData flash after password/e-mail change). */
.flash {
    background: #ecfdf5; border: 1px solid #a7f3d0; color: #065f46;
    border-radius: 8px; padding: 0.7rem 1rem; font-size: 0.95rem;
}

/* Identity summary — label/value rows that collapse to a stack on
   phones (mobile-friendly hard requirement). */
.account-facts { display: grid; grid-template-columns: 12rem 1fr; gap: 0.45rem 1rem; margin: 1.25rem 0 1.5rem; }
.account-facts dt { color: var(--ink-muted); font-size: 0.9rem; }
.account-facts dd { margin: 0; font-weight: 500; overflow-wrap: anywhere; }
@media (max-width: 560px) {
    .account-facts { grid-template-columns: 1fr; gap: 0; }
    .account-facts dt { margin-top: 0.6rem; }
}

.hub-actions { display: flex; gap: 0.75rem; flex-wrap: wrap; }
.button-outline {
    background: transparent; color: var(--brand);
    border: 1px solid var(--brand);
    padding: 0.5rem 1.35rem;
}
.button-outline:hover { background: var(--brand); color: #fff; }

/* Ecosystem application tiles. */
.app-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr)); gap: 0.85rem; margin-top: 1rem; }
.app-tile {
    display: flex; flex-direction: column; gap: 0.3rem;
    padding: 1rem 1.1rem;
    border: 1px solid var(--line); border-radius: 8px;
    text-decoration: none; color: var(--ink);
    transition: border-color 0.12s ease, box-shadow 0.12s ease;
}
.app-tile:hover { border-color: var(--brand); box-shadow: 0 2px 8px rgba(226, 61, 58, 0.12); }
.app-tile .app-name { font-weight: 600; color: var(--brand); }
.app-tile .app-desc { font-size: 0.85rem; color: var(--ink-muted); line-height: 1.4; }

/* "Natrag na Moj račun" footer link under manage forms. */
.form-footer { margin: 1.25rem 0 0; font-size: 0.9rem; }

/* ── 2FA (TwoFactor + EnableAuthenticator) ──────────────────── */
.status-on { color: #0f8e3c; font-weight: 600; }
.status-off { color: var(--ink-muted); font-weight: 600; }

.actions-column { display: flex; flex-direction: column; gap: 0.6rem; align-items: flex-start; margin-top: 1rem; }
.actions-column form { margin: 0; }

.button-danger { background: var(--danger); }
.button-danger:hover { background: #991616; }

.setup-steps { margin: 0 0 1rem; padding-left: 1.25rem; line-height: 1.7; }

.qr-block { display: flex; flex-direction: column; align-items: center; gap: 0.6rem; margin: 0 0 1.5rem; }
.qr-block img { border: 1px solid var(--line); border-radius: 8px; padding: 8px; background: #fff; }
.shared-key {
    background: var(--surface); border: 1px solid var(--line); border-radius: 6px;
    padding: 0.4rem 0.7rem; font-size: 0.9rem; letter-spacing: 0.05em;
    overflow-wrap: anywhere; text-align: center;
}

.recovery-codes {
    background: #fff7ed; border: 1px solid #fdba74; border-radius: 8px;
    padding: 1rem 1.25rem; margin-bottom: 1.5rem;
}
.recovery-codes__title { margin: 0 0 0.4rem; font-weight: 700; color: #9a3412; }
.recovery-codes ul {
    margin: 0.6rem 0 0; padding: 0; list-style: none;
    display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.35rem 1rem;
}
.recovery-codes code { font-size: 0.95rem; letter-spacing: 0.04em; }
@media (max-width: 480px) {
    .recovery-codes ul { grid-template-columns: 1fr; }
}

/* ── /Admin pages ───────────────────────────────────────────── */
.card--wide { max-width: 64rem; }
/* List pages (Users, OIDC clients) span the whole content column. */
.card--full { max-width: none; }

.admin-toolbar { display: flex; gap: 0.6rem; align-items: center; margin: 0 0 1.25rem; flex-wrap: wrap; }
.admin-toolbar input[type=text] {
    flex: 1 1 240px; padding: 0.5rem 0.75rem;
    border: 1px solid #cfd4da; border-radius: 6px; font-size: 0.95rem; font-family: inherit;
}
.admin-toolbar input[type=text]:focus { outline: 2px solid var(--brand); outline-offset: -1px; border-color: var(--brand); }
.admin-toolbar a { margin-left: auto; }

.admin-table-wrap { overflow-x: auto; }
.admin-table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
.admin-table th {
    text-align: left; padding: 0.5rem 0.75rem;
    border-bottom: 2px solid var(--line);
    font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.05em;
    color: var(--ink-muted); white-space: nowrap;
}
.admin-table td { padding: 0.55rem 0.75rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.admin-table tr:hover td { background: var(--surface); }
.admin-table .row-actions a { color: var(--brand); text-decoration: none; }
.admin-table .row-actions a:hover { color: var(--brand-dark); }

.badge {
    display: inline-block; padding: 0.15rem 0.55rem; border-radius: 999px;
    font-size: 0.78rem; font-weight: 600;
}
.badge--active { background: #ecfdf5; color: #065f46; border: 1px solid #a7f3d0; }
.badge--locked { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.badge--admin { background: rgba(226, 61, 58, 0.08); color: var(--brand); border: 1px solid rgba(226, 61, 58, 0.35); }

.admin-pager { display: flex; gap: 1rem; align-items: center; margin-top: 1rem; font-size: 0.9rem; }
.admin-pager a { color: var(--brand); text-decoration: none; }
.admin-pager a:hover { color: var(--brand-dark); }

.admin-section { font-size: 1.05rem; margin: 1.75rem 0 0.75rem; }
.admin-actions { display: flex; gap: 0.6rem; flex-wrap: wrap; }
.admin-actions form { margin: 0; }
.admin-inline-form { max-width: 28rem; }

/* Six-box one-time-code input (_OtpInput partial). The field rule
   above sets width:100% on inputs — override back to fixed boxes. */
.otp-input { display: flex; gap: 8px; margin: 0.35rem 0 0.25rem; }
.field .otp-input input[type=text] {
    width: 3rem; height: 3.4rem; padding: 0;
    text-align: center; font-size: 1.45rem; font-weight: 600;
    font-feature-settings: "tnum";
    border: 1px solid #cfd4da; border-radius: 8px;
}
.field .otp-input input[type=text]:focus {
    outline: 2px solid var(--brand); outline-offset: -1px; border-color: var(--brand);
}
@media (max-width: 380px) {
    .otp-input { gap: 5px; }
    .field .otp-input input[type=text] { width: 2.6rem; height: 3rem; font-size: 1.25rem; }
}


/* ── External sign-in providers (Google / Certilia) ─────────── */
.auth-divider {
    display: flex; align-items: center; gap: 0.75rem;
    margin: 1.5rem 0 1.25rem; color: var(--ink-muted); font-size: 0.85rem;
}
.auth-divider::before, .auth-divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }

.external-providers { display: flex; flex-direction: column; gap: 0.6rem; }
.button-external {
    display: flex; align-items: center; justify-content: center; gap: 0.65rem;
    width: 100%; padding: 0.55rem 1.4rem;
    font-family: inherit; font-size: 1rem; font-weight: 600;
    border-radius: 6px; cursor: pointer; text-decoration: none;
}
.button-external svg { width: 18px; height: 18px; flex-shrink: 0; }

/* Certilia brand blue — colour lifted from their official sign-in button. */
.button-certilia { background: #2d74b5; color: #fff; border: 0; }
.button-certilia:hover { background: #25608f; }
.button-certilia svg { fill: #fff; }

/* Google branding: white button, dark-grey label, the multi-colour G
   carries its own fills (guidelines forbid recolouring). */
.button-google { background: #fff; color: #3c4043; border: 1px solid #cfd4da; }
.button-google:hover { background: #f8f9fa; border-color: #b9bec6; }

/* Future providers without bespoke branding fall back to outline. */
.button-external-generic { background: transparent; color: var(--brand); border: 1px solid var(--brand); }
.button-external-generic:hover { background: var(--brand); color: #fff; }
.button-external-generic svg { fill: currentColor; }

/* Povezani računi (Manage/ExternalLogins) */
.linked-logins { list-style: none; margin: 0 0 1.25rem; padding: 0; display: flex; flex-direction: column; gap: 0.5rem; }
.linked-login {
    display: flex; align-items: center; gap: 0.65rem;
    border: 1px solid var(--line); border-radius: 8px; padding: 0.55rem 0.8rem;
}
.linked-login form { margin: 0 0 0 auto; }
.linked-login__mark { display: flex; }
.linked-login__mark svg { width: 20px; height: 20px; }
/* The mark spans reuse the provider button classes for colour only —
   strip the button chrome and restore the brand fill on a plain card row. */
span.button-certilia, span.button-google, span.button-external-generic { background: transparent; border: 0; padding: 0; }
span.button-certilia svg { fill: #2d74b5; }
.linked-login__name { font-weight: 600; }

.button-small { padding: 0.3rem 0.8rem; font-size: 0.85rem; }
.section-sub { font-size: 1.05rem; margin: 1.5rem 0 0.75rem; }


/* ── Per-user actions dropdown (Admin Users list + UserDetail) ── */
.detail-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; }

.row-menu { position: relative; display: inline-block; }
.row-menu summary {
    list-style: none; cursor: pointer;
    width: 30px; height: 30px; border-radius: 6px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.15rem; font-weight: 700; color: var(--ink-muted);
    border: 1px solid var(--line); background: var(--card);
}
.row-menu summary::-webkit-details-marker { display: none; }
.row-menu summary:hover, .row-menu[open] summary { background: var(--surface); }
.row-menu .menu {
    position: absolute; right: 0; top: calc(100% + 6px);
    background: var(--card); border: 1px solid var(--line); border-radius: 8px;
    box-shadow: 0 6px 16px rgba(16, 24, 40, 0.12);
    min-width: 250px; padding: 0.3rem; z-index: 60;
    display: flex; flex-direction: column;
}
.row-menu .menu form { margin: 0; }
.row-menu .menu a,
.row-menu .menu button {
    display: block; width: 100%; text-align: left;
    padding: 0.45rem 0.7rem; border: 0; border-radius: 6px;
    background: transparent; color: var(--ink);
    font-family: inherit; font-size: 0.92rem; cursor: pointer; text-decoration: none;
}
.row-menu .menu a:hover,
.row-menu .menu button:hover { background: var(--surface); }
.row-menu .menu .menu-danger { color: var(--danger); }
.row-menu .menu .menu-danger:hover { background: #fef2f2; }
.menu-divider { height: 1px; background: var(--line); margin: 0.3rem 0.2rem; }

/* The dropdown must not get clipped by the table's scroll context — on
   wide screens the table fits anyway, so let overflow show; narrow
   screens keep horizontal scrolling. */
@media (min-width: 1100px) {
    .admin-table-wrap { overflow-x: visible; }
}


/* ── Links — same visual language as the Blazor clients: brand colour,
   NEVER underlined; hover darkens instead. Scoped rules above (topbar,
   sidebar, menus, buttons) win on specificity and keep their colours. */
a { color: var(--brand); text-decoration: none; }
a:hover { color: var(--brand-dark); }


/* ── Masked inputs on account-mutation forms ──────────────────
   type="text" + disc masking instead of type="password": Firefox offers
   its saved-logins dropdown on EVERY password-typed field regardless of
   autocomplete tokens, and these forms must never get credentials
   pre-offered. The layout script falls back to type="password" on
   browsers without text-security support. */
.password-mask { -webkit-text-security: disc; }


/* ── Terms of use ─────────────────────────────────────────────
   The consent tick-box on the register form, and the document itself —
   shown either in the dialog on that page or on its own at /Legal/Terms. */

.alert {
    border: 1px solid var(--line); border-radius: 8px;
    padding: 0.7rem 0.9rem; margin-bottom: 1rem;
    font-size: 0.9rem; line-height: 1.45;
}
.alert-danger { border-color: var(--danger); color: var(--danger); background: #fdf2f2; }

/* The row is its own flex line so the validation message sits UNDER the
   label rather than becoming a third flex item beside it. */
.terms-field { margin-top: 1.25rem; }
.terms-field__row { display: flex; align-items: flex-start; gap: 0.55rem; }
.terms-field__row input[type=checkbox] { margin-top: 0.15rem; accent-color: var(--brand); flex-shrink: 0; }
.terms-field__row label { margin-bottom: 0; font-weight: 400; font-size: 0.9rem; line-height: 1.45; }
.terms-field__row label a { font-weight: 600; }

.recaptcha-notice { margin: 0.75rem 0 0; font-size: 0.75rem; line-height: 1.4; }

.terms-dialog {
    border: 1px solid var(--line); border-radius: 12px;
    padding: 0; background: var(--card); color: var(--ink);
    /* Narrower than the viewport on a phone, never wider than a comfortable
       measure on a desktop. */
    width: min(46rem, calc(100vw - 2rem));
    max-height: min(85vh, 52rem);
    overflow: hidden;
    display: flex; flex-direction: column;
}
.terms-dialog::backdrop { background: rgba(15, 18, 24, 0.45); }
.terms-dialog__body { overflow-y: auto; padding: 1.5rem 1.75rem 0.5rem; }
.terms-dialog__actions {
    padding: 0.9rem 1.75rem 1.1rem; border-top: 1px solid var(--line);
    display: flex; justify-content: flex-end; background: var(--card);
}

/* Document typography — the HTML comes from the terms file, so these
   selectors are the only thing giving it shape. */
.legal-doc { font-size: 0.9rem; line-height: 1.55; }
.legal-doc h1 { font-size: 1.25rem; margin: 0 0 0.75rem; }
.legal-doc h2 { font-size: 1rem; margin: 1.35rem 0 0.4rem; }
.legal-doc p { margin: 0 0 0.55rem; }
.legal-doc .lead { color: var(--ink-muted); margin-bottom: 1.25rem; }
.legal-doc hr { border: 0; border-top: 1px solid var(--line); margin: 1.5rem 0 1rem; }
.legal-doc .legal-footer { color: var(--ink-muted); font-size: 0.8rem; }
