/* go-toolz Lizenz-Portal theme layer on top of Pico CSS.
   Light, compact look aligned with the go-toolz brand (accent #0097ff). */

:root {
    color-scheme: light;
    --pico-font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --pico-font-family-monospace: ui-monospace, SFMono-Regular, Menlo, monospace;
    --pico-font-size: 93.75%;

    --pico-primary: #0097ff;
    --pico-primary-hover: #0084dd;
    --pico-primary-focus: rgba(0, 151, 255, 0.25);
    --pico-primary-inverse: #ffffff;

    --pico-background-color: #ffffff;
    --pico-color: #1a1f36;
    --pico-muted-color: #64748b;
    --pico-border-color: #e5e9f0;
    --pico-border-radius: 0.375rem;

    --pico-block-spacing-vertical: 0.85rem;
    --pico-spacing: 0.6rem;

    --lp-ok: #16a34a;
    --lp-err: #dc2626;
    --lp-warn: #d97706;
}

:root[data-theme="dark"] {
    color-scheme: dark;

    --pico-primary: #3b82f6;
    --pico-primary-hover: #60a5fa;
    --pico-primary-focus: rgba(59, 130, 246, 0.3);
    --pico-primary-inverse: #0f172a;

    --pico-background-color: #0f172a;
    --pico-color: #e2e8f0;
    --pico-muted-color: #94a3b8;
    --pico-border-color: #283548;
}

body {
    background: var(--pico-background-color);
}

h1 {
    font-size: 1.25rem;
    margin-bottom: 0.65rem;
}

h2 {
    font-size: 1.05rem;
    margin: 0.9rem 0 0.45rem;
}

/* --- Topbar ------------------------------------------------------------- */

.topbar {
    background: var(--pico-background-color);
    border-bottom: 1px solid var(--pico-border-color);
    margin-bottom: 1rem;
    padding-block: 0;
}

.topbar nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.55rem 0;
}

.brand {
    display: inline-flex;
    align-items: center;
}

.brand img {
    height: 28px;
    display: block;
}

.nav-links {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: 0.85rem;
    list-style: none;
    margin: 0;
    padding: 0.15rem 0;
    overflow-x: auto;
    scrollbar-width: thin;
    min-width: 0;
}

.nav-links li {
    margin: 0;
    padding: 0;
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

.nav-links a,
.topbar button.nav-link {
    display: inline-flex;
    align-items: center;
    color: var(--pico-muted-color);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 400;
    line-height: 1.2;
    margin: 0;
    padding: 0;
    background: none;
    border: 0;
    box-shadow: none;
    width: auto;
    min-width: 0;
    height: auto;
    text-align: start;
    cursor: pointer;
}

.nav-links a:hover,
.nav-links a.active,
.topbar button.nav-link:hover,
.topbar button.nav-link:focus {
    color: var(--pico-primary);
    background: none;
    box-shadow: none;
}

.nav-links a.active {
    font-weight: 650;
}

.nav-links form {
    display: flex;
    align-items: center;
    margin: 0;
    line-height: 1.2;
    font-size: 0.9rem;
}

main.container {
    overflow-x: auto;
}

/* --- Cards & metrics ---------------------------------------------------- */

.card {
    background: var(--pico-background-color);
    border: 1px solid var(--pico-border-color);
    border-radius: var(--pico-border-radius);
    padding: 0.9rem 1rem;
    margin-bottom: 0.85rem;
}

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 0.65rem;
    margin-bottom: 0.85rem;
}

.metric {
    background: var(--pico-background-color);
    border: 1px solid var(--pico-border-color);
    border-radius: var(--pico-border-radius);
    padding: 0.7rem 0.85rem;
}

.metric .value {
    font-size: 1.35rem;
    font-weight: 700;
    line-height: 1.2;
}

.metric .label {
    color: var(--pico-muted-color);
    font-size: 0.78rem;
}

/* --- Tables & forms ----------------------------------------------------- */

table {
    font-size: 0.88rem;
}

th, td {
    padding: 0.45rem 0.65rem;
}

th {
    color: var(--pico-muted-color);
    font-weight: 600;
    font-size: 0.82rem;
}

form.stack label {
    margin: 0.55rem 0 0.2rem;
    font-size: 0.85rem;
}

form.stack .checkbox-row label {
    margin: 0;
}

.inline-fields {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 0.65rem;
    align-items: end;
}

.checkbox-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0.55rem 0;
    font-size: 0.88rem;
}

input, select, textarea {
    padding: 0.4rem 0.55rem;
    font-size: 0.9rem;
}

/* --- Buttons ------------------------------------------------------------ */

button, .btn {
    margin-top: 0.75rem;
    padding: 0.45rem 1rem;
    font-size: 0.88rem;
    border-radius: var(--pico-border-radius);
}

.btn {
    display: inline-block;
    border: none;
    background: var(--pico-primary);
    color: var(--pico-primary-inverse);
    line-height: 1.25;
    text-decoration: none;
    cursor: pointer;
}

button.btn,
button.btn-danger,
button.btn-plain,
button.btn-small {
    width: auto;
}

.btn:hover {
    background: var(--pico-primary-hover);
}

.btn-danger {
    background: var(--lp-err);
}

.btn-danger:hover {
    background: #b91c1c;
}

.btn-plain {
    background: var(--pico-muted-color);
}

.btn-plain:hover {
    background: var(--pico-color);
}

.btn-small {
    margin: 0;
    padding: 0.25rem 0.6rem;
    font-size: 0.78rem;
}

.actions {
    display: flex;
    gap: 0.4rem;
    align-items: center;
    white-space: nowrap;
}

.actions form {
    display: inline;
    margin: 0;
}

.actions .btn,
.actions button {
    margin-top: 0;
}

/* --- Flash messages & badges -------------------------------------------- */

.flash {
    padding: 0.55rem 0.85rem;
    border-radius: var(--pico-border-radius);
    margin-bottom: 0.85rem;
    font-size: 0.88rem;
    border: 1px solid transparent;
}

.flash.ok {
    background: #dcfce7;
    color: var(--lp-ok);
    border-color: #bbf7d0;
}

.flash.err {
    background: #fee2e2;
    color: var(--lp-err);
    border-color: #fecaca;
}

.flash.warn {
    background: #fef3c7;
    color: var(--lp-warn);
    border-color: #fde68a;
}

.badge {
    display: inline-block;
    padding: 0.12rem 0.5rem;
    border-radius: 999px;
    font-size: 0.74rem;
    background: var(--pico-border-color);
    color: var(--pico-color);
    white-space: nowrap;
}

.badge.ok {
    background: #dcfce7;
    color: var(--lp-ok);
}

.badge.warn {
    background: #fef3c7;
    color: var(--lp-warn);
}

.badge.err {
    background: #fee2e2;
    color: var(--lp-err);
}

/* --- Theme switch -------------------------------------------------------- */

.theme-slot {
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

.theme-switch {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    cursor: pointer;
    margin: 0;
    line-height: 1;
}

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

.theme-icon {
    color: var(--pico-muted-color);
    display: none;
    flex-shrink: 0;
}

.theme-icon-sun {
    display: block;
}

.theme-switch input:checked ~ .theme-icon-sun {
    display: none;
}

.theme-switch input:checked ~ .theme-icon-moon {
    display: block;
}

.theme-switch-track {
    position: relative;
    width: 2.25rem;
    height: 1.25rem;
    border-radius: 999px;
    background: var(--pico-border-color);
    border: 1px solid var(--pico-border-color);
    transition: background 0.2s ease;
    flex-shrink: 0;
}

.theme-switch-track::after {
    content: "";
    position: absolute;
    top: 2px;
    left: 2px;
    width: 0.875rem;
    height: 0.875rem;
    border-radius: 50%;
    background: var(--pico-primary);
    transition: transform 0.2s ease, background 0.2s ease;
}

.theme-switch input:checked ~ .theme-switch-track {
    background: var(--pico-primary);
}

.theme-switch input:checked ~ .theme-switch-track::after {
    transform: translateX(1rem);
    background: var(--pico-primary-inverse);
}

.theme-switch input:focus-visible ~ .theme-switch-track {
    outline: 2px solid var(--pico-primary);
    outline-offset: 2px;
}

/* --- Dark mode component overrides --------------------------------------- */

:root[data-theme="dark"] .topbar {
    background: var(--pico-background-color);
    border-bottom-color: var(--pico-border-color);
}

:root[data-theme="dark"] .card,
:root[data-theme="dark"] .metric {
    background: #16213a;
    border-color: var(--pico-border-color);
}

:root[data-theme="dark"] .badge {
    background: var(--pico-border-color);
    color: var(--pico-color);
}

:root[data-theme="dark"] .badge.ok {
    background: rgba(22, 163, 74, 0.18);
    color: #86efac;
}

:root[data-theme="dark"] .badge.warn {
    background: rgba(217, 119, 6, 0.18);
    color: #fcd34d;
}

:root[data-theme="dark"] .badge.err {
    background: rgba(220, 38, 38, 0.18);
    color: #fca5a5;
}

:root[data-theme="dark"] .flash.ok {
    background: rgba(22, 163, 74, 0.15);
    border-color: rgba(22, 163, 74, 0.4);
    color: #86efac;
}

:root[data-theme="dark"] .flash.err {
    background: rgba(220, 38, 38, 0.15);
    border-color: rgba(220, 38, 38, 0.4);
    color: #fca5a5;
}

:root[data-theme="dark"] .flash.warn {
    background: rgba(217, 119, 6, 0.15);
    border-color: rgba(217, 119, 6, 0.4);
    color: #fcd34d;
}

:root[data-theme="dark"] .btn-plain:hover {
    background: var(--pico-color);
}

/* --- Helpers ------------------------------------------------------------ */

.muted {
    color: var(--pico-muted-color);
}

.mono {
    font-family: var(--pico-font-family-monospace);
    font-size: 0.85em;
}

.code-cell {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

button.copy-btn {
    margin: 0;
    padding: 0.1rem 0.4rem;
    width: auto;
    font-size: 0.72rem;
    line-height: 1.4;
    background: transparent;
    color: var(--pico-muted-color);
    border: 1px solid var(--pico-border-color);
    box-shadow: none;
}

button.copy-btn:hover,
button.copy-btn:focus {
    color: var(--pico-primary);
    border-color: var(--pico-primary);
    background: transparent;
    box-shadow: none;
}

.login-card {
    max-width: 400px;
    margin: 2.5rem auto;
}

.form-card {
    max-width: 520px;
}

.or-divider {
    margin: 0.65rem 0;
    text-align: center;
    color: var(--pico-muted-color);
}
