/* Base rules, layout helpers and the few components used by every page, and in particular by the static pages
   (account, Invite, Error), which can't use MudBlazor. Written against the tokens at the top of app.css. Kept small on
   purpose: if a page needs something new, add the one rule it needs here. */

*, *::before, *::after { box-sizing: border-box; }

body { margin: 0; font-size: 1rem; line-height: 1.5; -webkit-text-size-adjust: 100%; }

h1, h2, h3, h4, h5, h6, .h4, .h5, .h6 { margin: 0 0 0.5rem; font-weight: 600; line-height: 1.2; }
h1 { font-size: 2rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.25rem; }
h4 { font-size: 1.125rem; }
.h4 { font-size: 1.25rem; }
h5, .h5 { font-size: 1.125rem; }
h6, .h6 { font-size: 1rem; }
p { margin: 0 0 1rem; }
ul, ol { margin: 0 0 1rem; padding-left: 2rem; }
hr { margin: 1rem 0; border: 0; border-top: 1px solid var(--di-line); }
a { color: var(--di-accent); }
a:hover { color: var(--di-accent-hover); }
img, svg { vertical-align: middle; }
table { border-collapse: collapse; }
button, input, select, textarea { font: inherit; color: inherit; }
label { display: inline-block; }
/* On the public static pages, hidden means hidden even when a class sets a display (e.g. a .btn that script reveals). */
.public-main [hidden] { display: none !important; }
code { font-size: 0.875em; }

/* --- Layout --- */
.container { width: 100%; max-width: 1140px; margin-inline: auto; padding-inline: 12px; }
/* As wide as the interactive app's MudContainer (Large), for the public pages that sit beside it. */
.container-wide { max-width: 1280px; }
.row { display: flex; flex-wrap: wrap; margin-inline: -0.75rem; }
.row > * { flex-shrink: 0; width: 100%; max-width: 100%; padding-inline: 0.75rem; }
@media (min-width: 768px) {
    .col-md-4 { flex: 0 0 auto; width: 33.3333%; }
    .col-md-6 { flex: 0 0 auto; width: 50%; }
    .col-md-8 { flex: 0 0 auto; width: 66.6667%; }
    .col-md-12 { flex: 0 0 auto; width: 100%; }
}
@media (min-width: 992px) {
    .col-lg-3 { flex: 0 0 auto; width: 25%; }
    .col-lg-4 { flex: 0 0 auto; width: 33.3333%; }
    .col-lg-6 { flex: 0 0 auto; width: 50%; }
    .col-lg-9 { flex: 0 0 auto; width: 75%; }
}
@media (min-width: 1200px) {
    .col-xl-6 { flex: 0 0 auto; width: 50%; }
}

/* --- Utilities (the ones MudBlazor doesn't provide) --- */
.align-items-start { align-items: flex-start; }
.align-items-center { align-items: center; }
.align-items-baseline { align-items: baseline; }
.justify-content-between { justify-content: space-between; }
.justify-content-center { justify-content: center; }
.text-start { text-align: start; }
.text-center { text-align: center; }
.text-end { text-align: end; }
.text-nowrap { white-space: nowrap; }
.text-danger { color: var(--di-danger); }
.text-success { color: var(--di-success); }
.text-info { color: var(--di-info); }
.text-secondary, .text-muted { color: var(--di-muted); }
.fw-bold { font-weight: 700; }
.fw-semibold { font-weight: 600; }
.font-monospace { font-family: Menlo, Consolas, monospace; }
.small { font-size: 0.875em; }
.w-100 { width: 100%; }
.h-100 { height: 100%; }
.p-0 { padding: 0; }
.list-unstyled { padding-left: 0; list-style: none; }
.visually-hidden {
    position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden;
    clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

/* --- Buttons --- */
.btn {
    display: inline-block;
    padding: 0.375rem 0.75rem;
    border: 1px solid transparent;
    border-radius: 6px;
    background: none;
    font-weight: 600;
    line-height: 1.5;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
}
.btn:disabled, .btn.disabled { opacity: 0.6; pointer-events: none; }
.btn-lg { padding: 0.6rem 1.1rem; font-size: 1.125rem; }
.btn-primary { background: var(--di-primary); border-color: var(--di-primary); color: var(--di-on-primary); }
.btn-primary:hover { background: color-mix(in srgb, var(--di-primary) 88%, black); color: var(--di-on-primary); }
.btn-danger { background: var(--di-danger); border-color: var(--di-danger); color: var(--di-on-primary); }
.btn-danger:hover { background: color-mix(in srgb, var(--di-danger) 88%, black); color: var(--di-on-primary); }
.btn-outline-primary { border-color: var(--di-primary); color: var(--di-primary); }
.btn-outline-primary:hover { background: color-mix(in srgb, var(--di-primary) 10%, transparent); color: var(--di-primary); }
.btn-link { color: var(--di-accent); text-decoration: underline; }
.btn-outline-secondary, .btn-outline-dark { border-color: var(--di-line-strong); color: var(--di-ink); }
.btn-outline-secondary:hover, .btn-outline-dark:hover { background: color-mix(in srgb, var(--di-ink) 8%, transparent); color: var(--di-ink); }

/* --- Forms --- */
.form-label { display: inline-block; margin-bottom: 0.5rem; }
.form-control {
    display: block;
    width: 100%;
    padding: 0.375rem 0.75rem;
    border: 1px solid var(--di-line-strong);
    border-radius: 6px;
    background: var(--di-surface);
    color: var(--di-ink);
    line-height: 1.5;
}
.form-control::placeholder { color: var(--di-muted); opacity: 0.8; }
.form-check-input { width: 1.1em; height: 1.1em; margin-right: 0.4rem; vertical-align: middle; }
.checkbox { margin-bottom: 1rem; }

.form-floating { position: relative; }
.form-floating > .form-control { height: 3.5rem; padding: 1.5rem 0.75rem 0.4rem; }
.form-floating > label {
    position: absolute;
    top: 0;
    left: 0;
    padding: 0.95rem 0.75rem;
    color: var(--di-muted);
    pointer-events: none;
    transform-origin: 0 0;
    transition: transform 0.1s ease-out;
}
/* The placeholder is a trick to detect a filled field; keep it invisible until focus so it doesn't collide with the label. */
.form-floating > .form-control::placeholder { color: transparent; }
.form-floating > .form-control:focus::placeholder { color: var(--di-muted); }
.form-floating > .form-control:focus ~ label,
.form-floating > .form-control:not(:placeholder-shown) ~ label {
    transform: scale(0.8) translateY(-0.5rem) translateX(0.15rem);
}

.input-group { display: flex; align-items: stretch; width: 100%; }
.input-group > .form-control { flex: 1 1 auto; width: 1%; min-width: 0; }
.input-group-text {
    display: flex;
    align-items: center;
    padding: 0.375rem 0.75rem;
    border: 1px solid var(--di-line-strong);
    background: color-mix(in srgb, var(--di-ink) 6%, var(--di-surface));
    color: var(--di-muted);
}
.input-group-append { display: flex; }

/* --- Alerts --- */
.alert { margin-bottom: 1rem; padding: 0.75rem 1rem; border: 1px solid; border-radius: 6px; }
.alert-danger { color: var(--di-danger); background: color-mix(in srgb, var(--di-danger) 12%, var(--di-surface)); border-color: color-mix(in srgb, var(--di-danger) 45%, transparent); }
.alert-success { color: var(--di-success); background: color-mix(in srgb, var(--di-success) 12%, var(--di-surface)); border-color: color-mix(in srgb, var(--di-success) 45%, transparent); }
.alert-warning { color: var(--di-warning); background: color-mix(in srgb, var(--di-warning) 14%, var(--di-surface)); border-color: color-mix(in srgb, var(--di-warning) 45%, transparent); }
.alert-info { color: var(--di-info); background: color-mix(in srgb, var(--di-info) 12%, var(--di-surface)); border-color: color-mix(in srgb, var(--di-info) 45%, transparent); }

/* --- Cards and tables --- */
.card { background: var(--di-surface); border: 1px solid var(--di-line); border-radius: 8px; }
.card-body { padding: 1rem; }
.table { width: 100%; margin-bottom: 1rem; }
.table th, .table td { padding: 0.5rem; border-bottom: 1px solid var(--di-line); text-align: start; vertical-align: middle; }
.table th.text-end, .table td.text-end { text-align: end; }
.table-dense th, .table-dense td { padding: 0.3rem 0.5rem; }

/* --- Navigation pills (the account settings menu) --- */
.nav { display: flex; flex-wrap: wrap; margin: 0; padding: 0; list-style: none; }
.nav-link { display: block; padding: 0.5rem 1rem; border-radius: 6px; color: var(--di-accent); text-decoration: none; }
.nav-link:hover { background: color-mix(in srgb, var(--di-ink) 8%, transparent); }
.nav-pills .nav-link.active { background: var(--di-primary); color: var(--di-on-primary); }

/* --- The static top bar (AccountLayout / NavMenu): the same look as the interactive app bar --- */
.static-bar { background: var(--di-appbar); border-bottom: 1px solid rgba(255, 214, 107, 0.16); }
.static-bar-inner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    max-width: 1140px;
    min-height: 52px;
    margin-inline: auto;
    padding-inline: 12px;
}
.static-nav { display: flex; flex: 1; align-items: center; gap: 0.25rem; }
.static-nav .spacer { flex: 1; }
.static-nav form { margin: 0; }
.nav-toggle { position: absolute; opacity: 0; pointer-events: none; }
.static-toggle { display: none; margin-left: auto; padding: 0.5rem; cursor: pointer; color: #efedf6; font-size: 1.4rem; line-height: 1; }
.nav-toggle:focus-visible + .static-toggle { outline: 2px solid var(--di-bulb); }
@media (max-width: 767.98px) {
    .static-toggle { display: block; }
    .static-nav { display: none; flex: 1 0 100%; flex-direction: column; align-items: stretch; padding-bottom: 0.5rem; }
    .nav-toggle:checked ~ .static-nav { display: flex; }
    .static-nav .spacer { display: none; }
}
