/* BizzPas WebDev Gateway: the portal and the gateway's own pages on application paths. */

:root {
    --color-ink: #1d2433;
    --color-ink-soft: #5b6475;
    --color-line: #dde2ea;
    --color-surface: #ffffff;
    --color-background: #f3f5f9;
    --color-primary: #1f3a5f;
    --color-primary-strong: #152a46;
    --color-accent: #e3792b;
    --color-focus: #2f6fd6;
    --color-ok-bg: #e5f5ec;
    --color-ok: #1d6b40;
    --color-warn-bg: #fdf0e1;
    --color-warn: #8a4b0f;
    --color-danger: #b42318;
    --color-danger-bg: #fdecea;
    --color-muted-bg: #eceff4;
    --radius: 10px;
    --shadow: 0 1px 2px rgb(16 24 40 / 6%), 0 4px 12px rgb(16 24 40 / 6%);
    --font: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
    --font-mono: "Cascadia Mono", Consolas, "SFMono-Regular", monospace;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

/* The hidden attribute always wins over display rules of components (forms, grids). */
[hidden] {
    display: none !important;
}

html {
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    min-height: 100vh;
    background: var(--color-background);
    color: var(--color-ink);
    font: 16px/1.5 var(--font);
}

h1,
h2 {
    margin: 0 0 .5rem;
    line-height: 1.25;
}

h1 {
    font-size: 1.75rem;
}

h2 {
    font-size: 1.25rem;
}

p {
    margin: 0 0 1rem;
}

a {
    color: var(--color-primary);
}

code {
    font-family: var(--font-mono);
    font-size: .875em;
}

:focus-visible {
    outline: 3px solid var(--color-focus);
    outline-offset: 2px;
}

.skip-link {
    position: absolute;
    left: 1rem;
    top: -3rem;
    padding: .5rem 1rem;
    background: var(--color-surface);
    border-radius: var(--radius);
    z-index: 10;
}

.skip-link:focus {
    top: 1rem;
}

.muted {
    color: var(--color-ink-soft);
}

.load-error {
    color: var(--color-danger);
}

/* ---- Top bar ---- */

.topbar {
    background: var(--color-primary);
    color: #fff;
}

.topbar__inner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .75rem 1.5rem;
    max-width: 1200px;
    margin: 0 auto;
    padding: .75rem 1.25rem;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: .6rem;
    margin: 0;
    font-weight: 700;
    letter-spacing: .01em;
    color: inherit;
    text-decoration: none;
}

.brand__mark {
    width: 1.4rem;
    height: 1.4rem;
    border-radius: 6px;
    background: linear-gradient(135deg, var(--color-accent) 0 50%, #f4b27a 50% 100%);
}

.topbar__nav {
    display: flex;
    gap: .25rem;
}

.topbar__link {
    padding: .35rem .75rem;
    border-radius: 999px;
    color: #dbe4f0;
    text-decoration: none;
}

.topbar__link:hover,
.topbar__link[aria-current="page"] {
    background: rgb(255 255 255 / 12%);
    color: #fff;
}

.topbar__user {
    display: flex;
    align-items: center;
    gap: .75rem;
    margin-left: auto;
    font-size: .9rem;
}

.topbar__email {
    color: #dbe4f0;
    overflow-wrap: anywhere;
}

.topbar .btn--ghost {
    border-color: rgb(255 255 255 / 35%);
    color: #fff;
    background: transparent;
}

.topbar .btn--ghost:hover {
    background: rgb(255 255 255 / 12%);
}

/* ---- Buttons ---- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .4rem;
    min-height: 2.5rem;
    padding: .5rem 1.1rem;
    border: 1px solid transparent;
    border-radius: 8px;
    font: inherit;
    font-weight: 600;
    line-height: 1.2;
    text-decoration: none;
    cursor: pointer;
    transition: background-color .15s, border-color .15s;
}

.btn:disabled {
    opacity: .6;
    cursor: default;
}

.btn--primary {
    background: var(--color-primary);
    color: #fff;
}

.btn--primary:hover:not(:disabled) {
    background: var(--color-primary-strong);
}

.btn--ghost {
    background: var(--color-surface);
    border-color: var(--color-line);
    color: var(--color-ink);
}

.btn--ghost:hover:not(:disabled) {
    border-color: #b9c1ce;
    background: #f8f9fb;
}

.btn--danger {
    background: var(--color-danger);
    color: #fff;
}

.btn--danger-ghost {
    background: var(--color-surface);
    border-color: #f1c4bf;
    color: var(--color-danger);
}

.btn--danger-ghost:hover:not(:disabled) {
    background: var(--color-danger-bg);
}

.btn--small {
    min-height: 2rem;
    padding: .3rem .7rem;
    font-size: .875rem;
}

.btn--block {
    width: 100%;
}

.link-button {
    padding: 0;
    border: 0;
    background: none;
    color: var(--color-primary);
    font: inherit;
    text-decoration: underline;
    cursor: pointer;
}

/* ---- Cards and pages ---- */

.card {
    background: var(--color-surface);
    border: 1px solid var(--color-line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.page {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem 1.25rem 3rem;
}

.page__header {
    margin-bottom: 1.5rem;
}

.page__lead {
    color: var(--color-ink-soft);
    max-width: 48rem;
}

/* ---- Sign-in ---- */

.auth,
.status {
    display: grid;
    place-items: center;
    padding: 3rem 1rem;
}

.auth__card,
.status__card {
    width: min(100%, 26rem);
    padding: 2rem;
}

.status__card {
    width: min(100%, 34rem);
}

.page-status .status {
    min-height: 100vh;
}

.status__card .brand {
    margin-bottom: 1.25rem;
    color: var(--color-primary);
}

.status__actions {
    display: flex;
    flex-wrap: wrap;
    gap: .75rem;
    margin-top: 1.5rem;
}

.auth__intro {
    color: var(--color-ink-soft);
}

.auth__links {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    margin-top: 1rem;
    font-size: .9rem;
}

/* ---- Forms ---- */

.form {
    display: grid;
    gap: 1rem;
}

.form > p {
    margin: 0;
}

.field {
    display: grid;
    gap: .35rem;
}

.field label {
    font-weight: 600;
}

.field--inline {
    grid-auto-flow: column;
    align-items: center;
    justify-content: start;
    gap: .75rem;
}

input[type="text"],
input[type="email"],
input[type="url"],
input[type="date"],
select,
textarea {
    width: 100%;
    min-height: 2.6rem;
    padding: .5rem .75rem;
    border: 1px solid #c6cdd8;
    border-radius: 8px;
    background: #fff;
    color: inherit;
    font: inherit;
}

textarea {
    resize: vertical;
    font-family: var(--font-mono);
    font-size: .9rem;
}

[aria-invalid="true"] {
    border-color: var(--color-danger);
}

.input--code {
    font-size: 1.6rem;
    letter-spacing: .4em;
    text-align: center;
    font-family: var(--font-mono);
}

/* A fixed path in front of the input, for example "/odeon/" before the path of an application. */
.input-prefix {
    display: flex;
    align-items: stretch;
}

.input-prefix input {
    min-width: 0;
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
}

.input-prefix__text {
    display: flex;
    align-items: center;
    max-width: 60%;
    padding: 0 .75rem;
    border: 1px solid #c6cdd8;
    border-right: 0;
    border-radius: 8px 0 0 8px;
    background: var(--color-muted-bg);
    color: var(--color-ink-soft);
    font-family: var(--font-mono);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.field__hint {
    margin: 0;
    font-size: .85rem;
    color: var(--color-ink-soft);
}

.field__error {
    margin: 0;
    font-size: .875rem;
    color: var(--color-danger);
}

.check {
    display: flex;
    align-items: flex-start;
    gap: .6rem;
}

.check input {
    width: 1.1rem;
    height: 1.1rem;
    margin-top: .2rem;
    flex: none;
}

/* ---- Project cards ---- */

.project-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr));
    gap: 1rem;
}

.project-card {
    display: grid;
    gap: .25rem;
    padding: 1.25rem 1.4rem;
    color: inherit;
    text-decoration: none;
    border-top: 4px solid var(--color-accent);
    transition: transform .15s, box-shadow .15s;
}

.project-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgb(16 24 40 / 12%);
}

.project-card__name {
    font-size: 1.15rem;
    font-weight: 700;
}

.project-card__url {
    color: var(--color-primary);
    font-family: var(--font-mono);
    font-size: .875rem;
    overflow-wrap: anywhere;
}

.project-card__meta {
    color: var(--color-ink-soft);
    font-size: .85rem;
}

/* ---- Administration ---- */

.tabs {
    display: flex;
    gap: .25rem;
    border-bottom: 1px solid var(--color-line);
    margin-bottom: 1.25rem;
    overflow-x: auto;
}

.tabs__tab {
    padding: .65rem 1rem;
    border: 0;
    border-bottom: 3px solid transparent;
    background: none;
    color: var(--color-ink-soft);
    font: inherit;
    font-weight: 600;
    cursor: pointer;
}

.tabs__tab[aria-selected="true"] {
    color: var(--color-primary);
    border-bottom-color: var(--color-accent);
}

.panel__toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
}

.panel__toolbar p {
    margin: 0;
    max-width: 44rem;
}

.table-wrap {
    overflow-x: auto;
    background: var(--color-surface);
    border: 1px solid var(--color-line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.table-wrap > p {
    margin: 0;
    padding: 1.25rem;
}

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: .95rem;
}

.table th,
.table td {
    padding: .7rem 1rem;
    border-bottom: 1px solid var(--color-line);
    text-align: left;
    vertical-align: middle;
}

.table th {
    background: #f8f9fb;
    color: var(--color-ink-soft);
    font-size: .8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
    white-space: nowrap;
}

.table tbody tr:last-child td {
    border-bottom: 0;
}

.table td code {
    white-space: nowrap;
}

.row-actions {
    display: flex;
    flex-wrap: nowrap;
    justify-content: flex-end;
    gap: .4rem;
}

.badge {
    display: inline-block;
    padding: .15rem .55rem;
    border-radius: 999px;
    font-size: .8rem;
    font-weight: 600;
    white-space: nowrap;
}

.badge--ok {
    background: var(--color-ok-bg);
    color: var(--color-ok);
}

.badge--warn {
    background: var(--color-warn-bg);
    color: var(--color-warn);
}

.badge--muted {
    background: var(--color-muted-bg);
    color: var(--color-ink-soft);
}

.badge--accent {
    background: #e6edf7;
    color: var(--color-primary);
}

/* ---- Modal ---- */

.modal {
    width: min(100% - 2rem, 28rem);
    padding: 0;
    border: 0;
    border-radius: var(--radius);
    box-shadow: 0 20px 50px rgb(16 24 40 / 25%);
    color: inherit;
}

.modal--form {
    width: min(100% - 2rem, 34rem);
}

.modal::backdrop {
    background: rgb(16 24 40 / 45%);
}

.modal__inner {
    padding: 1.5rem;
}

.modal__message {
    white-space: pre-line;
}

.modal__actions {
    display: flex;
    justify-content: flex-end;
    gap: .75rem;
    margin-top: .5rem;
}

/* ---- Toasts ---- */

.toast-region {
    position: fixed;
    right: 1rem;
    bottom: 1rem;
    display: grid;
    gap: .5rem;
    z-index: 20;
}

.toast {
    max-width: 24rem;
    padding: .75rem 1rem;
    border-radius: 8px;
    background: var(--color-ink);
    color: #fff;
    box-shadow: var(--shadow);
    transition: opacity .3s;
}

.toast.is-leaving {
    opacity: 0;
}

@media (max-width: 640px) {
    .topbar__user {
        margin-left: 0;
        width: 100%;
        justify-content: space-between;
    }

    .auth__card,
    .status__card {
        padding: 1.5rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        transition: none !important;
    }
}
