/*
 * Shared components of the events plugin: one button, one notice, one field
 * and one table, built only from the design tokens (tokens.css, and the
 * theme's variables.css where it loads). Every events stylesheet depends on
 * this one, so a screen's own stylesheet only adds what is particular to it.
 *
 * The selectors are chosen to outrank the theme's element rules (`button`,
 * `input[type='text']` and friends) by specificity rather than by load order,
 * because WordPress does not promise which stylesheet prints first.
 */

/* Buttons
   The primary look is the theme's own button (DECISIONS item 34): solid
   primary blue, white, sentence case. Everything the theme's `button` rule
   sets is set again here, so this renders the same with or without it. */
.vsc-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: var(--tap-min);
    margin: 0;
    padding: 10px 20px;
    border: 2px solid var(--color-primary);
    border-radius: var(--radius-control);
    background: var(--color-primary);
    color: var(--color-white);
    font-family: inherit;
    font-size: var(--font-size-sm);
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: normal;
    text-align: center;
    text-decoration: none;
    text-transform: none;
    cursor: pointer;
    -webkit-appearance: none;
    transition:
        background-color var(--transition-base),
        border-color var(--transition-base),
        color var(--transition-base);
}

.vsc-btn:hover {
    border-color: var(--color-primary-dark);
    background: var(--color-primary-dark);
    color: var(--color-white);
    text-decoration: none;
}

.vsc-btn:focus-visible {
    outline: var(--focus-ring);
    outline-offset: var(--focus-offset);
}

.vsc-btn--secondary {
    background: var(--color-white);
    color: var(--color-primary);
}

.vsc-btn--secondary:hover {
    border-color: var(--color-primary);
    background: var(--color-primary);
    color: var(--color-white);
}

.vsc-btn--danger {
    border-color: var(--color-danger);
    background: var(--color-danger);
    color: var(--color-white);
}

.vsc-btn--danger:hover {
    border-color: var(--color-danger-dark);
    background: var(--color-danger-dark);
    color: var(--color-white);
}

/* Reads as the link it sits beside. Inline text, so it is exempt from the
   44px target size (WCAG 2.5.8, "inline"); it keeps the text's own height. */
.vsc-btn--link {
    display: inline;
    min-height: 0;
    padding: 0;
    border: none;
    background: none;
    color: var(--color-primary);
    font-weight: inherit;
    font-size: inherit;
    line-height: inherit;
    text-align: inherit;
    text-decoration: underline;
}

.vsc-btn--link:hover {
    border: none;
    background: none;
    color: var(--color-primary-dark);
    text-decoration: underline;
}

.vsc-btn--link.vsc-btn--danger,
.vsc-btn--link.vsc-btn--danger:hover {
    color: var(--color-danger);
}

.vsc-btn:disabled,
.vsc-btn.disabled {
    border-color: var(--color-gray-400);
    background: var(--color-gray-100);
    color: var(--color-text-disabled);
    cursor: not-allowed;
}

.vsc-btn--link:disabled,
.vsc-btn--link.disabled {
    background: none;
}

/* Notices
   One box for every message: the status colour carries the kind, and the left
   edge carries it again so it does not rest on the fill alone. */
.vsc-notice {
    margin: 0 0 16px;
    padding: 12px 16px;
    border-left: 4px solid var(--color-primary);
    border-radius: var(--radius-control);
    background: var(--color-info-bg);
    color: var(--color-gray-900);
}

.vsc-notice--info {
    border-left-color: var(--color-primary);
    background: var(--color-info-bg);
    color: var(--color-primary-dark);
}

.vsc-notice--success {
    border-left-color: var(--color-success-accent);
    background: var(--color-success-bg);
    color: var(--color-success);
}

.vsc-notice--warning {
    border-left-color: var(--color-warning-accent);
    background: var(--color-warning-bg);
    color: var(--color-warning);
}

.vsc-notice--error {
    border-left-color: var(--color-danger);
    background: var(--color-error-bg);
    color: var(--color-error);
}

.vsc-notice ul {
    margin: 8px 0 0;
    padding: 0 0 0 20px;
}

.vsc-notice li {
    margin-bottom: 4px;
}

.vsc-notice > :last-child {
    margin-bottom: 0;
}

/* The public form puts an icon beside the text. */
.vsc-notice:has(> .message-icon) {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.vsc-notice .message-icon {
    flex-shrink: 0;
}

.vsc-notice .message-text {
    flex: 1;
}

/* Fields
   Every text input, select and textarea on the public form, the desk form, the
   portal, the overview and the manager. Written once; a screen may set width,
   never the look. (0,2,1) outranks the theme's input[type='text'] (0,1,1).
   1rem is also what stops iOS from zooming into a field. */
:is(
        .vsc-field,
        .vsc-edit-field,
        .vilstaler-registration-wrapper,
        .vilstaler-internal-registration-form,
        .vilstaler-internal-portal,
        .registration-controls
    )
    :is(
        input:not(
            [type='checkbox'],
            [type='radio'],
            [type='submit'],
            [type='button'],
            [type='hidden']
        ),
        select,
        textarea
    ) {
    box-sizing: border-box;
    width: 100%;
    max-width: 100%;
    min-height: var(--tap-min);
    margin: 0;
    padding: 8px 12px;
    border: 1px solid var(--color-border-control);
    border-radius: var(--radius-control);
    background-color: var(--color-white);
    color: var(--color-text);
    font: inherit;
    font-size: var(--font-size-md);
    line-height: 1.4;
}

:is(
        .vsc-field,
        .vsc-edit-field,
        .vilstaler-registration-wrapper,
        .vilstaler-internal-registration-form,
        .vilstaler-internal-portal,
        .registration-controls
    )
    select {
    padding-right: 40px;
    background-position: calc(100% - 14px) center;
    cursor: pointer;
}

:is(
        .vsc-field,
        .vsc-edit-field,
        .vilstaler-registration-wrapper,
        .vilstaler-internal-registration-form,
        .vilstaler-internal-portal,
        .registration-controls
    )
    :is(
        input:not(
            [type='checkbox'],
            [type='radio'],
            [type='submit'],
            [type='button'],
            [type='hidden']
        ),
        select,
        textarea
    ):focus-visible {
    border-color: var(--color-primary);
    outline: var(--focus-ring);
    outline-offset: var(--focus-offset);
}

.vsc-field {
    display: flex;
    flex-direction: column;
    margin-bottom: 14px;
}

.vsc-field label {
    font-weight: 600;
    margin-bottom: 4px;
}

/* Tables: wide ones scroll rather than pushing the page sideways */
.vsc-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 20px;
    display: block;
    overflow-x: auto;
}

.vsc-table th,
.vsc-table td {
    padding: 8px 10px;
    text-align: left;
    border-bottom: 1px solid var(--color-border);
    vertical-align: top;
}

.vsc-table th {
    font-weight: 600;
    border-bottom-width: 2px;
    white-space: nowrap;
}

@media (prefers-reduced-motion: reduce) {
    .vsc-btn {
        transition: none;
    }
}
