/*
 * Copyright © OurGroceries, Inc. All rights reserved.
 */

:root {
    --dialog-padding: 15px;
}

input[type=text], input[type=password], input[type=url], input[type=email], input[type=search], textarea, select {
    color: fieldtext;
    background: var(--your-lists-text-field-background-color);
    border-radius: 4px;
    padding: 5px 8px;
    border: 1px solid var(--your-lists-button-border-color);

    &:focus-visible {
        outline: var(--icon-dark-green) auto 5px;
    }

    &:disabled {
        color: color-mix(in srgb-linear, fieldtext 80%, var(--your-lists-text-field-background-color));
        background: color-mix(in srgb-linear, fieldtext 20%, var(--your-lists-text-field-background-color));
    }
}

button:focus-visible, :not([tabindex="-1"]):focus-visible {
    outline: var(--icon-dark-green) auto 5px;
}

select.rounded {
    border-radius: 10px;
}

.select-wrapper {
    background: var(--your-lists-text-field-background-color);
    border-radius: 10px;
    border: 1px solid var(--your-lists-button-border-color);
    padding: 5px 10px 5px 8px;

    select {
        border: none;
        padding: 0;
        border-radius: 0;
        width: 100%;

        &.rounded {
            border-radius: 0;
        }

        &:focus-visible {
            outline: none;
        }
    }

    &:focus-within {
        outline: var(--icon-dark-green) auto 5px;
    }
}

.equal-width-buttons {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: 1fr;
    align-items: center;
    gap: 10px;
}

/* --------------------------------------------------------------------------------- */
/* Override jQuery UI. */

.ui-widget-content {
    color: var(--jquery-ui-dialog-text-color);
    background-color: var(--jquery-ui-dialog-background-color);
}

.ui-widget-content a {
    color: var(--your-lists-light-text-color);
}

.ui-widget-header {
    background: #419639;
    border: none;
    text-transform: uppercase;
    font-weight: normal;
    color: white;
    font-family: var(--display-font-family);
}

.ui-dialog-title {
    color: white;
}

.ui-dialog {
    /* Fit on narrow screens. */
    max-width: calc(100% - 10px);
    box-shadow: var(--shadow);
    padding: 0;
    border-radius: 10px;
    overflow: hidden;
    border: 0 !important;
}

.ui-dialog .ui-dialog-titlebar {
    border-radius: 0;
}

.ui-dialog .ui-dialog-titlebar-close {
    right: 1em;
}

.ui-dialog .ui-dialog-content {
    padding: 1em;
}

.ui-widget {
    font-family: var(--body-font-family);
}

.ui-state-default a,
.ui-state-default a:link,
.ui-state-default a:visited,
a.ui-button,
a:link.ui-button,
a:visited.ui-button {
    color: #222;
}

.ui-state-default,
.ui-widget-content .ui-state-default,
.ui-widget-header .ui-state-default,
html .ui-button.ui-state-disabled:hover,
html .ui-button.ui-state-disabled:active {

    background: #f6f6f6;
}

.ui-button,
.ui-button:focus,
.ui-widget .ui-button,
.ui-widget .ui-button:focus {
    font-family: var(--display-font-family);
    white-space: nowrap;
    background: var(--your-lists-button-background-color);
    color: var(--your-lists-button-text-color);
    border: 1px solid var(--your-lists-button-border-color);
}

@media (hover: hover) {
    .ui-button:hover,
    .ui-widget .ui-button:hover {
        background: color-mix(in srgb, var(--your-lists-button-background-color) 80%, #888);
        color: var(--your-lists-button-text-color);
        border: 1px solid var(--your-lists-button-border-color);
    }
}

.ui-button:not(.icon-only-button) i {
    margin-right: 7px;
}

.ui-button {
    border-radius: 10px;
    padding-bottom: 7px;
}

.submit-button,
.submit-button:hover,
.submit-button:focus,
.ui-widget .submit-button,
.ui-widget .submit-button:hover,
.ui-widget .submit-button:focus {
    background-color: var(--icon-dark-green);
    color: white;
    border: 1px solid var(--icon-dark-green);
}

.danger-button,
.danger-button:hover,
.danger-button:focus,
.ui-widget .danger-button,
.ui-widget .danger-button:hover,
.ui-widget .danger-button:focus {
    background-color: var(--icon-red);
    color: white;
    border: 1px solid var(--icon-red);
}

.ui-widget-overlay {
    background: #000;
    opacity: .5;
    filter: Alpha(Opacity=50);
}

/* --------------------------------------------------------------------------------- */

.dialog {
    background-color: var(--your-lists-background-color);
    border: 0;
    padding: 0;
    border-radius: 10px;
    overflow: hidden;
    width: 500px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 12px 20px 0 rgb(43 43 43 / 50%);
}

.dialog-tall {
    height: 75vh;
}

.dialog-narrow {
    width: 350px;
}

.dialog::backdrop {
    background: var(--your-lists-dialog-backdrop-color);
    backdrop-filter: blur(10px);
    transition: background 500ms ease-out, backdrop-filter 500ms ease-out;
}

.dialog.dialog-moved::backdrop {
    /* so user can see what's behind the dialog box as they move it */
    background: var(--your-lists-dialog-backdrop-moved-color);
    backdrop-filter: none;
}

.dialog-header {
    display: flex;
    flex-direction: column;
    gap: 10px;

    color: white;
    background: var(--your-lists-top-nav-background);
    padding: var(--dialog-padding);
}

.dialog-title {
    font-size: 32px;
    line-height: 1.1;
    font-family: var(--display-font-family);
    font-weight: 300;
    cursor: ew-resize;
    user-select: none;

    &.smaller-font {
        font-size: 24px;
    }
}

.dialog-subtitle {
    font-size: 20px;
    line-height: 1.1;
    font-family: var(--display-font-family);
    font-weight: 300;
    user-select: none;
}

/* iOS-like app bar that has the title in the middle and optional buttons
on the left and right. This must always have exactly three children divs,
with the content in those divs. Make this the first child of the dialog
body. */
.dialog-header-centered-title {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    white-space: nowrap;
    font-size: 17px;
    letter-spacing: -0.43px;
    font-weight: 400;
    padding-bottom: 5px;

    > :nth-child(1) {
        text-align: left;

        > button {
            padding-inline: 10px;
            margin-left: -10px;
        }
    }

    > :nth-child(2) {
        font-weight: 500;
        text-align: center;

        /* So that the title is the one to clip, not the buttons: */
        overflow: clip;
        text-overflow: ellipsis;
        min-width: 0;
    }

    > :nth-child(3) {
        text-align: right;

        > button {
            padding-inline: 10px;
            margin-right: -10px;
        }
    }

    button {
        color: var(--icon-dark-green);
        border: none;
        background: none;
        font-size: 17px;
        letter-spacing: -0.43px;
    }
}

/* Not the title, but the part of the header that sometimes
has the title on mobile, or the part that has an input field on both. */
.dialog-header-title-bar {
    display: flex;
    gap: 16px;
    align-items: center;

    > button {
        color: white;
        border: none;
        background: none;
        padding: 0;
        font-size: 120%;
    }

    .dialog-header-title-bar-title {
        font-weight: bold;
        font-size: 130%;
    }
}

.dialog-body {
    flex-grow: 1;
    color: var(--body-color);
    overflow: auto;
    background: var(--your-lists-primary-background);

    /* This will force the body to fit inside the dialog box, which will allow any
    large element (e.g., master list) to scroll. */
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.dialog-body-padded {
    padding: var(--dialog-padding);
}

.dialog-body-gap {
    gap: 16px;
}

.dialog-button-panel {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    padding: var(--dialog-padding);
    background: var(--your-lists-primary-background);
}

.dialog-button-group {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: auto;
    gap: 10px;
}

.dialog-button-group-equal-width {
    grid-auto-columns: 1fr;
}

.dialog-footer {
    padding-top: 10px;
    padding-bottom: var(--dialog-padding);
    padding-inline: var(--dialog-padding);
    color: var(--your-lists-placeholder-color);
    font-size: 85%;
    line-height: 1.4;
}

.dialog-body-padded .dialog-footer {
    padding-inline: 0;
}

