/* Stylesheets that are used both in wp-admin and in frontend */

:root {
    --owl-color-accent: #89302a;
    --owl-color-text-light: #fff;
    --owl-color-text-dark: #3a3a3a;
    --owl-color-text-print: #000;
    --owl-color-bg-light: #ebebeb;
    --owl-color-text-environment: #138200;
}

@keyframes owlSpin {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}

@keyframes owlShake {
    0% {
        transform: translateX(0);
    }
    20% {
        transform: translateX(5px);
    }
    40% {
        transform: translateX(-5px);
    }
    60% {
        transform: translateX(5px);
    }
    80% {
        transform: translateX(-5px);
    }
    100% {
        transform: translateX(0);
    }
}

/* Modal closed state */
[popover] {
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.2s ease, transform 0.2s ease, display 0.2s ease, overlay 0.2s ease;
  transition-behavior: allow-discrete;
}

/* Modal open state */
[popover]:popover-open {
  opacity: 1;
  transform: translateY(0)
}

/* Modal starting state */
@starting-style {
  [popover]:popover-open {
    opacity: 0;
    transform: translateY(10px);
  }
}

.owlShake {
    animation: owlShake 0.5s;
}

i.fa-spinner {
    animation: owlSpin 2s infinite linear;
}

.owlFlex {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
}

.owlFlexColumn {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.owlButton, .owlPlainButton {
    background-color: var(--owl-color-accent);
    color: var(--owl-color-text-light);
    padding: 1rem;
    border: none;
    font-size: 1rem;
    font-weight: 500;
    line-height: 1rem;
    text-align: center;
    border-radius: 4px;
    cursor: pointer;
    white-space: nowrap;
    width: 3rem;
    min-width: fit-content;
    transition: 0.25s background-color ease, 0.25s color ease;

    i {
        font-size: 1.1rem;
    }

    span {
        margin-left: 0.5rem;
    }

    &:hover, &:active {
        background-color: var(--owl-color-text-dark);
    }

    &:disabled {
        background-color: var(--owl-color-bg-light);
        color: #999;
        cursor: initial;
    }
}

.owlButton {
    padding: 1rem !important; /* override salient styling */
}

.owlPlainButton {
    background-color: transparent;
    color: var(--owl-color-text-dark);
    padding: 0.75rem;

    &:hover, &:active {
        background-color: var(--owl-color-accent);
        color: var(--owl-color-text-light);
    }
}

dialog.owlModal {
    max-height: 98dvh;
    position: fixed;
    top: 0;
    left: 0;
    width: 90dvw;
    max-width: 500px;
    border-radius: 4px;
    padding: 1.5rem;
    z-index: 9999;
    border: 1px solid rgb(221, 221, 221);
    box-shadow: rgba(0, 0, 0, 0.15) 0px 4px 12px;

    input {
        background-color: var(--owl-color-text-light);
        border: 2px solid var(--owl-color-accent);
    }

    h2 {
        font-size: 1.25rem;
        text-align: left;
        flex-grow: 1;
    }

    .owlFlex .owlCloseModalButton {
        flex-grow: unset;
        font-weight: bold;
        text-align: right;
    }

    .owlFlex {
        gap: 1rem;

        & > * {
            flex-grow: 1;
        }
    }

    .owlPlainButton {
        padding: 1rem;
    }
}

.owlInputWrapper {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;

    /* Add asterisk to labels of required fields */
    &:has(> :required) label::after {
        content: '*';
        color: var(--owl-color-accent);
    }
}

.owlErrorContainer {
    position: fixed;
    bottom: 15px;
    width: 100%;
    display: flex;
    justify-content: center;
    z-index: 10;
}

.owlErrorMessage {
    background-color: var(--owl-color-accent);
    color: var(--owl-color-text-light);
    padding: 0.5rem 1rem;
    border-radius: 100px;
}

.owlErrorContainer .owlErrorMessage {
    box-shadow: rgba(0, 0, 0, 0.15) 0px 4px 12px;
    animation: 0.5s owlShake;
}

dialog.owlModal .owlErrorMessage {
    background-color: var(--owl-color-bg-light);
    color: var(--owl-color-accent);
    border-radius: 4px;
}

#owlAdminWishlistProductItems .owlItemSku {
    display: inline-block;
    min-width: 120px;
}

#owlPrintButtonWrapper {
    text-align: right;
}

@media print {
    /* Only active while the admin print copy exists */
    body:has(#owlPrintClone) > *:not(#owlPrintClone) {
        display: none !important;
    }

    html:has(#owlPrintClone),
    body:has(#owlPrintClone) {
        background: #fff !important;
        margin: 0 !important;
        padding: 0 !important;
        height: auto !important;
    }

    #owlPrintClone {
        display: block !important;
        padding: 20px;
        color: #000;
        font-family: Arial, sans-serif;
        font-size: 12pt;
    }

    #owlPrintClone #owlPrintTitle {
        display: block;
        margin: 0 0 16px;
        font-size: 20pt;
    }

    #owlPrintClone h3 {
        margin: 20px 0 8px;
    }

    #owlPrintClone table {
        width: 100%;
        border-collapse: collapse;
    }

    #owlPrintClone th,
    #owlPrintClone td {
        border: 1px solid #000;
        padding: 6px 10px;
        text-align: left;
    }

    #owlPrintClone tr {
        page-break-inside: avoid;
    }
}
