@import url("tokens.css");

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    margin: 10px;
    font-family: inherit;
    font-weight: 600;
    font-size: 1rem;
    color: var(--color-on-accent);
    border: none;
    border-radius: var(--radius-control);
    cursor: pointer;
    text-align: center;
    text-decoration: none;
    /* Sized by its label, not by its container. This was width: 20%, which
       made every button a fifth of whatever was around it: "Go" as wide as
       "Cancel this request", and a long label clipped in a narrow column.
       No min-width here: the icon-only buttons (the "!" on a pickup row) are
       .button too, and a floor on the base class stretches them into slabs.
       Rows that want their buttons equal-width say so with .button-row. */
    width: auto;
    /* 44px is the smallest reliable tap target on a phone (Apple HIG; Material
       asks 48). height: 40px was under it, and being a fixed height it also
       clipped any label that wrapped rather than growing to fit. */
    min-height: 44px;
    -webkit-appearance: none;
}

.button:hover {
    opacity: 0.88;
}

.button-inactive {
    opacity: 0.5;
    pointer-events: none;
}

/* Buttons are named for the job they do, not the colour they happen to be.
   The colour names came first and read backwards in practice: .button-light
   is the green primary action and .button-dark the quieter one, so markup
   saying "light" meant "this is the important one". Every old name is kept
   as an alias below - the parent-facing pages still use them - but staff
   pages say primary/secondary/neutral/danger. */

.button-primary,
.button-light {
    background-color: var(--color-primary);
}

.button-secondary,
.button-dark {
    background-color: var(--color-accent-fill);
}

.button-neutral,
.button-grey {
    background-color: var(--color-neutral);
}

.button-danger,
.button-white-red {
    background-color: var(--color-surface);
    color: var(--color-danger);
    box-shadow: inset 0 0 0 1px var(--color-border-light);
    padding-left: 40px;
    padding-right: 40px;
}

/* The -no-margin pair exists only because .button bakes in margin: 10px, so
   anything laid out by a flex container has to undo it. Prefer .button-row,
   which owns the spacing, and leave these for the pages not yet moved over. */

.button-dark-no-margin {
    background-color: var(--color-accent-fill);
    margin: 0px;
    margin-top: 10px;
    width: 100%;
}

.button-light-no-margin {
    background-color: var(--color-primary);
    margin: 0px;
    margin-top: 10px;
    flex: 1;
}

/* A row of actions that belong together: the container owns the spacing, so
   the buttons in it need no margin of their own and no -no-margin variant.
   Every button in the row is the same width, because a row of actions where
   one is wider than another reads as one of them being more important. An
   icon-only button (aria-label, no text) keeps its own width. */

.button-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: stretch;
}

.button-row > .button,
.button-row > input[type="submit"] {
    flex: 1 1 0;
    width: auto;
    min-width: 0;
    max-width: none;
    margin: 0;
}

.button-row > .button-icon {
    flex: 0 0 44px;
    min-width: 44px;
    padding: 0;
}

/* Pushed to the end of the row rather than sharing its width - for the one
   action that is not a peer of the others, like a destructive one. */
.button-row > .button-trailing {
    flex: 0 0 auto;
    margin-left: auto;
}

@media (max-width: 600px) {
    .button-row {
        flex-direction: column;
    }

    .button-row > .button-trailing {
        margin-left: 0;
    }
}

.facebookButton {
    background-color: #3B5999;
}

.googleButton {
    background-color: #4386F4;
}

.emailButton {
    background-color: var(--color-neutral);
}

#submit-button {
    margin: 0px;
    border-radius: var(--radius-control);
    max-width: unset;
    -webkit-appearance: none;
}

.selected-item-inactive {
    display: inline-block;
    margin: 5px;
    padding: 8px 14px;
    border: 1px solid var(--color-border);
    background-color: var(--color-surface);
    border-radius: 999px;
    cursor: pointer;
}

.selected-item-inactive:hover {
    background-color: var(--color-surface-muted);
}

.selected-item-active {
    display: inline-block;
    margin: 5px;
    padding: 8px 14px;
    border: 1px solid var(--color-primary);
    background-color: var(--color-primary-light);
    color: var(--color-success-text);
    font-weight: 600;
    border-radius: 999px;
    cursor: pointer;
}

.loading-indicator {
    max-height: 80px;
}

select,
input[type="text"],
input[type="email"],
input[type="password"],
input[type="confirm_password"],
input[type="date"],
input[type="time"],
input[type="number"] {
    font-family: inherit;
    font-weight: 400;
    width: 100%;
    max-width: 300px;
    padding: 12px 14px;
    margin: 10px;
    color: var(--color-text);
    background-color: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-control);
    font-size: 1rem;
    line-height: 1.25;
    transition: border-color 0.15s, box-shadow 0.15s;
}

select:focus,
input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
input[type="date"]:focus,
input[type="time"]:focus,
input[type="number"]:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px var(--color-primary-light);
}

/* A short line under a field - what it is for, or what is wrong with it. */
.field-hint {
    font-size: 0.8rem;
    color: var(--color-text-secondary);
    margin: -6px 14px 6px;
    text-align: left;
}

.field-hint-error {
    color: var(--color-danger);
}

input.input-error {
    border-color: var(--color-danger);
}

input[type="submit"] {
    font-family: inherit;
    font-weight: 600;
    width: 100%;
    max-width: 300px;
    padding: 10px 20px;
    margin: 10px;
    /* Matches .button above: the two sit side by side in several staff forms
       and were a few pixels different in height, which reads as misalignment
       rather than as two kinds of control. */
    min-height: 44px;
    border: none;
    border-radius: var(--radius-control);
    font-size: 1rem;
    line-height: 1.25;
    background-color: var(--color-primary);
    color: var(--color-on-accent);
    cursor: pointer;
}

input[type="submit"]:hover {
    opacity: 0.88;
}

.select2 {
    margin: 5px;
    width: 100%;
}

.select2-selection__choice {
    display: none;
}

select.child-select {
    width: 100%;
    margin-bottom: 10px;
}

@media (max-width: 600px) {
    .button {
        /* Full width on a phone, where a row of buttons has nowhere to sit
           side by side anyway. 80% left an off-centre gap that read as a
           mistake rather than as deliberate breathing room. */
        width: 100%;
    }

    .button-dark-no-margin {
        width: 100%;
    }
}

/* Shared confirmation dialog (scripts/confirm-dialog.js) - replaces native
   confirm() for destructive one-click actions (cancel request, vehicle
   departed, sent to gate) with something that looks like the rest of the
   app instead of the browser's own unstylable dialog. */

.confirm-dialog-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background-color: rgba(20, 32, 31, 0.45);
    z-index: 10000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.confirm-dialog-backdrop.confirm-dialog-open {
    display: flex;
}

.confirm-dialog-card {
    background-color: var(--color-surface);
    border-radius: 20px;
    box-shadow: 0 20px 50px rgba(20, 32, 31, 0.2);
    padding: 28px 22px 22px 22px;
    width: 100%;
    max-width: 320px;
    text-align: center;
}

.confirm-dialog-message {
    margin: 0 0 20px 0;
    font-size: 1rem;
    color: var(--color-text);
}

.confirm-dialog-actions {
    display: flex;
    gap: 10px;
}

.confirm-dialog-actions .button {
    width: 100%;
    max-width: none;
    margin: 0;
}