/* ============================================================
   Components — buttons, inputs, user panel, login, modals
   ============================================================ */

/* --- BUTTONS --- */
.btn-primary,
.btn-secondary {
    font-family: var(--font-sans);
    font-weight: 600;
    font-size: 1rem;
    letter-spacing: 0.01em;
    padding: var(--s-3) var(--s-4);
    min-height: 48px;
    border-radius: var(--r-soft);
    border: 1px solid transparent;
    cursor: pointer;
    transition: all var(--dur-base) var(--ease-smooth);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--s-2);
    position: relative;
    user-select: none;
    -webkit-user-select: none;
}

.btn-primary {
    background: var(--accent);
    color: #1a0d00;
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.2) inset, var(--shadow-sm);
}
.btn-primary:hover {
    background: var(--accent-hover);
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.2) inset, 0 8px 20px -6px var(--accent-glow);
    transform: translateY(-1px);
}
.btn-primary:active {
    transform: translateY(0) scale(0.98);
    box-shadow: 0 0 0 1px var(--accent-glow);
}

.btn-secondary {
    background: var(--surface-2);
    color: var(--text);
    border-color: var(--border-strong);
}
.btn-secondary:hover {
    background: var(--surface-3);
    border-color: var(--accent);
}
.btn-secondary:active { transform: scale(0.98); }

.btn-primary:disabled,
.btn-secondary:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    transform: none !important;
}

/* Icon-only circular button */
.icon-btn {
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--text-dim);
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--dur-base) var(--ease-smooth);
    flex-shrink: 0;
}
.icon-btn:hover {
    background: var(--surface-3);
    border-color: var(--accent);
    color: var(--accent);
    transform: rotate(8deg);
}
.icon-btn svg { width: 18px; height: 18px; }

/* --- INPUTS --- */
.input-group {
    margin-bottom: var(--s-3);
    position: relative;
}

.input-group input,
.input-group textarea {
    width: 100%;
    padding: var(--s-3) var(--s-3);
    min-height: 52px;
    background: var(--surface-2);
    color: var(--text);
    border: 1px solid var(--border);
    border-bottom: 2px solid var(--border-strong);
    border-radius: var(--r-soft);
    font-family: var(--font-sans);
    font-size: 1rem;
    transition: all var(--dur-base) var(--ease-smooth);
}
.input-group input::placeholder { color: var(--text-hint); }
.input-group input:focus,
.input-group textarea:focus {
    outline: none;
    border-color: var(--border-strong);
    border-bottom-color: var(--accent);
    background: var(--surface);
    box-shadow: 0 4px 16px -8px var(--accent-glow);
}

/* Monospace input (codes, plates) */
.input-mono {
    font-family: var(--font-mono) !important;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    font-weight: 600;
}

/* --- LOGIN BOX --- */
.login-box {
    background: var(--surface);
    padding: var(--s-6) var(--s-5);
    border-radius: var(--r-card);
    width: 100%;
    max-width: 440px;
    margin: var(--s-7) auto 0;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
    position: relative;
}
/* Corner brackets (blueprint "scoped" marker) */
.login-box::before,
.login-box::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    border-color: var(--accent);
    border-style: solid;
}
.login-box::before {
    top: -1px; left: -1px;
    border-width: 2px 0 0 2px;
    border-top-left-radius: var(--r-card);
}
.login-box::after {
    bottom: -1px; right: -1px;
    border-width: 0 2px 2px 0;
    border-bottom-right-radius: var(--r-card);
}

.login-box h2 {
    text-align: center;
    margin-bottom: var(--s-5);
    font-size: 1.4rem;
    position: relative;
    padding-bottom: var(--s-3);
}
.login-box h2::after {
    content: '';
    position: absolute;
    left: 50%;
    bottom: 0;
    transform: translateX(-50%);
    width: 40px;
    height: 2px;
    background: var(--accent);
    border-radius: 2px;
}

.login-box .btn-primary { width: 100%; }

/* --- USER PANEL — avatar + dropdown ---
   Stary inline-pill (email + motyw + „Wyloguj" obok siebie) zasłaniał logo
   i pigułkę wersji na telefonach / tabletach niezależnie od breakpointu.
   Teraz w headerze jest tylko 44×44 ikonka usera — menu z wersją, motywem
   i „Wyloguj" (z potwierdzeniem) wylatuje jako dropdown dopiero po tapie. */
#user-panel {
    position: relative;
    margin-left: auto;
    flex-shrink: 0;
}

.user-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text-dim);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all var(--dur-base) var(--ease-smooth);
    padding: 0;
}
.user-avatar:hover,
.user-avatar[aria-expanded="true"] {
    border-color: var(--accent);
    color: var(--accent);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}
.user-avatar-icon {
    width: 22px;
    height: 22px;
    display: block;
    color: currentColor;
}

.user-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 260px;
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--r-card);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    z-index: 500;
    animation: dropIn 0.18s var(--ease-smooth);
}
@keyframes dropIn {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: translateY(0); }
}

.user-dropdown-header {
    padding: var(--s-3) var(--s-4);
    background: var(--surface-2);
    border-bottom: 1px solid var(--border);
}
#user-email {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text);
    word-break: break-all;
    line-height: 1.25;
    margin-bottom: 2px;
}
#user-role {
    font-family: var(--font-mono);
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--accent);
}

.user-dropdown-divider {
    height: 1px;
    background: var(--border);
}

.user-dropdown-item {
    display: flex;
    align-items: center;
    gap: var(--s-3);
    padding: var(--s-3) var(--s-4);
    width: 100%;
    min-height: 48px;
    font-family: var(--font-sans);
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text);
    background: transparent;
    border: none;
    cursor: pointer;
    text-align: left;
    transition: background var(--dur-fast) var(--ease-smooth);
}
.user-dropdown-item svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    color: var(--text-dim);
}
.user-dropdown-action:hover  { background: var(--surface-2); }
.user-dropdown-action:active { background: var(--surface-3); }

.user-dropdown-info { cursor: default; color: var(--text-dim); }
.user-dropdown-info svg { color: var(--text-hint); }
.user-dropdown-value {
    margin-left: auto;
    font-family: var(--font-mono);
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text);
    letter-spacing: 0.04em;
}

.user-dropdown-danger { color: var(--danger); }
.user-dropdown-danger svg { color: var(--danger); }
.user-dropdown-danger:hover {
    background: color-mix(in srgb, var(--danger) 12%, transparent);
}

/* Inline confirmation state — zamiast natywnego confirm(). Klik na
   „Wyloguj" dodaje .is-confirm → tekst „Na pewno?" + kolor ostrzegawczy. */
.user-dropdown-danger.is-confirm {
    background: color-mix(in srgb, var(--danger) 16%, var(--surface));
}

/* Mobile — dropdown w trybie fixed, żeby ewentualny `overflow: hidden`
   na którymkolwiek kontenerze nad #user-panel nie ucinał menu. */
@media (max-width: 480px) {
    .user-dropdown {
        position: fixed;
        top: 64px;
        right: 12px;
        left: 12px;
        min-width: 0;
        width: auto;
    }
}

/* --- MESSAGES --- */
.system-message {
    background: var(--surface);
    padding: var(--s-4);
    border-radius: var(--r-soft);
    border: 1px solid var(--border);
    border-left: 3px solid var(--accent);
    margin-top: var(--s-4);
}

.error-text {
    color: var(--danger);
    margin-top: var(--s-3);
    text-align: center;
    font-weight: 600;
    font-size: 0.9rem;
}

/* Status pill — technical "[ STATUS: X ]" style */
.status-pill {
    display: inline-flex;
    align-items: center;
    gap: var(--s-2);
    font-family: var(--font-mono);
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    padding: var(--s-1) var(--s-2);
    border: 1px solid var(--border-strong);
    border-radius: var(--r-sharp);
    color: var(--text-dim);
    background: var(--surface-2);
}
.status-pill::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
    box-shadow: 0 0 8px currentColor;
}
.status-pill.ok { color: var(--ok); }
.status-pill.warn { color: var(--warn); }
.status-pill.danger { color: var(--danger); }

/* ============================================================
   .plate-eu — wizualny odwzorowanie polskiej tablicy rejestracyjnej
   Proporcje rzeczywistej tablicy 520 × 114 mm (~4.56:1).
   Wysokość sterowana zmienną --plate-h (domyślnie 56px).
   ============================================================ */
.plate-eu {
    --plate-h: 56px;
    --plate-radius: calc(var(--plate-h) * 0.14);
    --plate-border: max(2px, calc(var(--plate-h) * 0.05));
    --plate-band-w: calc(var(--plate-h) * 0.78);
    --plate-font: calc(var(--plate-h) * 0.62);
    --plate-pad-x: calc(var(--plate-h) * 0.22);

    display: inline-flex;
    align-items: stretch;
    height: var(--plate-h);
    min-width: calc(var(--plate-h) * 4.2);
    background: #ffffff;
    border: var(--plate-border) solid #111111;
    border-radius: var(--plate-radius);
    overflow: hidden;
    font-family: 'Arial Narrow', 'Helvetica Neue', Arial, sans-serif;
    box-shadow:
        inset 0 0 0 1px rgba(0, 0, 0, 0.08),
        0 2px 6px rgba(0, 0, 0, 0.15);
    user-select: none;
    line-height: 1;
    flex-shrink: 0;
}

.plate-eu__band {
    width: var(--plate-band-w);
    background: linear-gradient(180deg, #003399 0%, #002277 100%);
    color: #ffcc00;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    padding: calc(var(--plate-h) * 0.08) 0 calc(var(--plate-h) * 0.06);
    flex-shrink: 0;
    position: relative;
}

/* Okrąg 12 gwiazd EU — odwzorowany jako radial layout przez SVG background */
.plate-eu__stars {
    width: 70%;
    aspect-ratio: 1 / 1;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'><g fill='%23ffcc00'><g id='s'><polygon points='50,38 51.76,43.42 57.46,43.42 52.85,46.77 54.61,52.19 50,48.84 45.39,52.19 47.15,46.77 42.54,43.42 48.24,43.42'/></g><use href='%23s' transform='rotate(30 50 50)'/><use href='%23s' transform='rotate(60 50 50)'/><use href='%23s' transform='rotate(90 50 50)'/><use href='%23s' transform='rotate(120 50 50)'/><use href='%23s' transform='rotate(150 50 50)'/><use href='%23s' transform='rotate(180 50 50)'/><use href='%23s' transform='rotate(210 50 50)'/><use href='%23s' transform='rotate(240 50 50)'/><use href='%23s' transform='rotate(270 50 50)'/><use href='%23s' transform='rotate(300 50 50)'/><use href='%23s' transform='rotate(330 50 50)'/></g></svg>");
    background-repeat: no-repeat;
    background-position: center;
    background-size: contain;
}

.plate-eu__country {
    font-weight: 800;
    font-size: calc(var(--plate-h) * 0.22);
    letter-spacing: 0.05em;
    color: #ffffff;
    line-height: 1;
}

.plate-eu__number {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: calc(var(--plate-h) * 0.06);
    padding: 0 var(--plate-pad-x);
    color: #111111;
    font-weight: 900;
    font-size: var(--plate-font);
    letter-spacing: 0.04em;
    white-space: nowrap;
    overflow: hidden;
    text-transform: uppercase;
    font-stretch: condensed;
}

/* Nalepka legalizacyjna — szary prostokąt między wyróżnikiem województwa a indywidualnym wyróżnikiem */
.plate-eu__sticker {
    display: inline-block;
    width: calc(var(--plate-h) * 0.24);
    height: calc(var(--plate-h) * 0.42);
    background: linear-gradient(180deg, #c8ccd1 0%, #9ea3a9 100%);
    border-radius: calc(var(--plate-h) * 0.04);
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.1);
    flex-shrink: 0;
}

/* Placeholder gdy brak numeru */
.plate-eu.is-empty .plate-eu__number {
    color: #bbb;
    letter-spacing: 0.2em;
}

/* Warianty rozmiarów */
.plate-eu.plate-sm  { --plate-h: 36px; }
.plate-eu.plate-md  { --plate-h: 56px; }
.plate-eu.plate-lg  { --plate-h: 84px; }
.plate-eu.plate-xl  { --plate-h: 120px; }

/* Wariant na ciemnym tle (OCR capture UI) — dodaje białą obwódkę */
.plate-eu.plate-on-dark {
    box-shadow:
        0 0 0 2px rgba(255, 255, 255, 0.15),
        inset 0 0 0 1px rgba(0, 0, 0, 0.08),
        0 8px 24px rgba(0, 0, 0, 0.4);
}
