/* =========================
Form
========================= */

input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,
input:-webkit-autofill:active {
    -webkit-box-shadow: 0 0 0px 1000px var(--color-bg) inset;
    -webkit-text-fill-color: var(--color-text);
    transition: background-color 5000s ease-in-out 0s;
    /* prevents flash */
}

.form {
    display: flex;
    flex-direction: column;
    text-align: left;
    margin-top: .5rem;
}

.form__actions {
    display: flex;
    justify-content: center;
    margin-top: 1rem;
}

.form__field {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    margin: 0.4rem;
    font-family: "JUSTSans", "Open Sans", sans-serif;
}

.form__field input,
.custom-select {
    width: 100%;
    padding: 0.65rem 0.9rem;
    border-radius: var(--radius);
    border: 1px solid var(--color-surface-alt);
    background: var(--color-bg);
    color: var(--color-text);
    font: inherit;
    box-sizing: border-box;
}

.custom-select {
    position: relative;
    cursor: pointer;
    user-select: none;
}

.form__field.checkbox {
    display: flex;
    gap: 0.5rem;
    flex-direction: row;
    align-items: center;
}

.form__field.checkbox input {
    appearance: none;
    -webkit-appearance: none;

    width: 24px;
    height: 24px;
    border: 1px solid var(--color-surface-alt);
    border-radius: 3px;

    padding: 0;
    display: inline-grid;
    place-content: center;
}

.form__field.checkbox input::before {
    content: "";
    width: 12px;
    height: 12px;
    transform: scale(0);
    transition: transform 120ms ease-in-out;
    background-color: var(--color-accent);
}

.form__field.checkbox input:checked::before {
    transform: scale(1);
}

/* =========================
Clear button
========================= */

.custom-select__selected {
    position: relative;
    padding-right: 1.5rem;
}

.custom-select__clear {
    position: absolute;
    right: 0.8rem;
    top: 50%;
    transform: translateY(-50%);
    cursor: pointer;
    font-size: 1.2rem;
    opacity: 0.6;
    display: none;
}

.custom-select.has-value .custom-select__clear {
    display: inline;
}

/* =========================
Placeholder text
========================= */

.form__field input::placeholder,
.custom-select__selected.placeholder,
label.placeholder {
    color: var(--color-text-placeholder);
}

/* =========================
Field highlights
========================= */

input.u-required,
.custom-select.u-required {
    border-color: var(--color-error);
    box-shadow: 0 0 5px rgba(231, 76, 60, 0.5);
}

.form__field input:focus,
.custom-select:focus {
    outline: none;
    border-color: var(--color-accent);
}

/* =========================
Select options
========================= */

.custom-select__options {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    max-height: calc(4 * 2.4rem);
    overflow-y: auto;
    background: var(--color-bg);
    border: 1px solid var(--color-surface-alt);
    border-radius: var(--radius);
    margin: 0;
    padding: 0.25rem 0.5rem;
    list-style: none;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    z-index: 10;
}

.custom-select__options li {
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    white-space: nowrap;
}

.custom-select__options li:hover {
    background: rgba(61, 174, 69, 0.15);
}

.custom-select.open .custom-select__options {
    display: block;
}

.custom-select__options {
    display: none;
}

/* =========================
Toast notifications
========================= */

.toast-container {
    position: fixed;
    bottom: 5rem;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    align-items: center;
    z-index: 1000;
}

.toast {
    min-width: 200px;
    max-width: 90vw;
    text-align: center;
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    color: black;
    font-size: 1rem;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
    opacity: 0;
    transform: translateY(-10px);
    transition: opacity 0.25s ease, transform 0.25s ease;
}

.toast--success {
    background: var(--color-accent);
}

.toast--error {
    background: var(--color-error);
    ;
}

.toast.show {
    opacity: 1;
    transform: translateY(0);
}

@media (max-width: 1023px) {
    .card:has(form) {
        padding: 0.5rem;
        display: grid;
        align-content: space-evenly;
    }

    .form__field {
        font-size: .9rem;
    }

    .form__field input, .form__field div  {
        padding: 0.5rem 0.65rem;
    }

    .form__field.checkbox input {
        width: 20px;
        height: 20px;
    }

    .form__field.checkbox input::before {
        width: 9px;
        height: 10px;
    }
}

@media (max-width: 640px) {
    .card:has(form) {
        padding: 1.5rem 1rem;
    }
}