#digia_order_by_sku {
    --sku-text: #1C2724;
    --sku-muted: #66716D;
    --sku-border: #E3E8E6;
    --sku-input-border: #CBD5D1;
    --sku-green: #00664F;
    --sku-green-dark: #0B5E4D;
    --sku-green-light: #E7F2EE;
    --sku-red: #B3261E;
    margin: 0 0 50px;
    color: var(--sku-text);
    font-size: 14px;
}

#digia_order_by_sku .digia-sku-icon {
    flex: 0 0 auto;
    width: 18px;
    height: 18px;
}

#digia_order_by_sku .digia-sku-intro {
    max-width: 70ch;
    margin: 10px 0 28px;
    font-size: 16px;
    line-height: 1.6;
    color: #3A4541;
}

#digia_order_by_sku .digia-sku-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 300px;
    align-items: start;
    gap: 32px;
}

#digia_order_by_sku .digia-sku-main {
    display: flex;
    flex-direction: column;
    gap: 20px;
    min-width: 0;
}

/* Cards */
#digia_order_by_sku .digia-sku-card {
    margin: 0;
    background: #FFF;
    border: 1px solid var(--sku-border);
    border-radius: 10px;
    box-shadow: 0 1px 3px rgb(0 0 0 / 6%);
}

#digia_order_by_sku .digia-sku-card-header {
    padding: 18px 24px;
    border-bottom: 1px solid var(--sku-border);
}

#digia_order_by_sku .digia-sku-card-title {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0;
    font-family: 'Roboto SemiBold', sans-serif;
    font-size: 17px;
    line-height: 1.3;
    letter-spacing: 0;
    text-transform: none;
    color: var(--sku-text);
}

#digia_order_by_sku .digia-sku-card-title .digia-sku-icon {
    width: 20px;
    height: 20px;
    color: var(--sku-green);
}

#digia_order_by_sku .digia-sku-card-body {
    padding: 22px 24px 24px;
}

#digia_order_by_sku .digia-sku-card-footer {
    display: flex;
    justify-content: flex-end;
    padding: 18px 24px;
}

/* Paste card */
#digia_order_by_sku .digia-sku-label {
    display: block;
    margin-bottom: 10px;
    font-size: 14px;
    color: var(--sku-muted);
}

#digia_order_by_sku #csvData {
    display: block;
    box-sizing: border-box;
    width: 100%;
    min-height: 220px;
    margin: 0;
    padding: 14px 16px;
    background: #FAFBFB;
    border: 1px solid var(--sku-input-border);
    border-radius: 6px;
    color: var(--sku-text);
    font-family: Consolas, 'SFMono-Regular', Menlo, monospace;
    font-size: 14px;
    line-height: 1.9;
    tab-size: 12;
    resize: vertical;
}

#digia_order_by_sku #csvData::placeholder {
    color: #9AA5A1;
}

#digia_order_by_sku #csvData:focus,
#digia_order_by_sku .prow input:focus {
    outline: none;
    background: #FFF;
    border-color: var(--sku-green);
    box-shadow: 0 0 0 3px rgb(0 102 79 / 15%);
}

#digia_order_by_sku .digia-sku-hint {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 12px 0 0;
    font-size: 13px;
    line-height: 1.5;
    color: var(--sku-muted);
}

#digia_order_by_sku .digia-sku-hint .digia-sku-icon {
    width: 16px;
    height: 16px;
}

#digia_order_by_sku .digia-sku-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 20px;
}

/* Buttons: the Customizer's additional CSS unsets everything on #addCSV and #orderByCode and forces their font */
#digia_order_by_sku .digia-sku-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-sizing: border-box;
    height: 44px;
    margin: 0;
    padding: 0 20px;
    background: var(--sku-green-dark);
    border: 1px solid var(--sku-green-dark);
    border-radius: 6px;
    color: #FFF;
    font-family: 'Roboto SemiBold', sans-serif !important;
    font-size: 15px;
    line-height: 1;
    white-space: nowrap;
    cursor: pointer;
    transition: background 150ms ease, border-color 150ms ease;
}

#digia_order_by_sku .digia-sku-button:hover {
    background: #08493C;
    border-color: #08493C;
}

#digia_order_by_sku .digia-sku-button:focus-visible,
#digia_order_by_sku .rowactions button:focus-visible,
#digia_order_by_sku .digia-sku-help-button:focus-visible {
    outline: 2px solid var(--sku-green);
    outline-offset: 2px;
}

/* Order rows: the script clones .prow, removes empty ones and fills .rowtitle/.rowmessage after checking the codes */
#digia_order_by_sku .digia-sku-rows-head,
#digia_order_by_sku .prow {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 120px 76px;
    column-gap: 12px;
    padding: 0 24px;
}

#digia_order_by_sku .digia-sku-rows-head {
    padding-top: 10px;
    padding-bottom: 10px;
    background: #F3F6F5;
    border-bottom: 1px solid var(--sku-border);
    color: #3A4541;
    font-family: 'Roboto SemiBold', sans-serif;
    font-size: 13px;
}

#digia_order_by_sku .prow {
    grid-template-areas:
        "code qty actions"
        "title title title"
        "message message message";
    align-items: center;
    padding-top: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid #EEF1F0;
}

#digia_order_by_sku .prow.errorRow {
    background: #FDF6F5;
    box-shadow: inset 3px 0 0 var(--sku-red);
}

#digia_order_by_sku .rowdata-code {
    grid-area: code;
}

#digia_order_by_sku .rowdata-qty {
    grid-area: qty;
}

#digia_order_by_sku .prow input {
    box-sizing: border-box;
    width: 100%;
    height: 40px;
    margin: 0;
    padding: 0 12px;
    background: #FFF;
    border: 1px solid var(--sku-input-border);
    border-radius: 6px;
    color: var(--sku-text);
    font-size: 14px;
}

#digia_order_by_sku .errorRow input {
    border-color: #E3A8A1;
}

#digia_order_by_sku .rowactions {
    grid-area: actions;
    display: flex;
    justify-content: flex-end;
    gap: 6px;
}

/* the script shows .addrow only on the last row */
#digia_order_by_sku .rowactions button {
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    width: 34px;
    height: 34px;
    margin: 0;
    padding: 0;
    background: #FFF;
    border: 1px solid var(--sku-border);
    border-radius: 6px;
    color: var(--sku-muted);
    cursor: pointer;
    transition: background 150ms ease, border-color 150ms ease, color 150ms ease;
}

#digia_order_by_sku .rowactions .digia-sku-icon {
    width: 16px;
    height: 16px;
}

#digia_order_by_sku .rowactions .delrow:hover {
    background: #FDF1EF;
    border-color: #F1C9C3;
    color: var(--sku-red);
}

#digia_order_by_sku .rowactions .addrow {
    background: var(--sku-green-light);
    border-color: #CFE3DB;
    color: var(--sku-green);
}

#digia_order_by_sku .rowactions .addrow:hover {
    background: var(--sku-green);
    border-color: var(--sku-green);
    color: #FFF;
}

#digia_order_by_sku .rowtitle {
    grid-area: title;
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 10px;
    font-family: 'Roboto SemiBold', sans-serif;
    font-size: 14px;
    line-height: 1.35;
}

/* WooCommerce gives images max-width: 100%, which would squeeze the thumbnail next to a long name */
#digia_order_by_sku .rowtitle img {
    flex: 0 0 44px;
    width: 44px;
    max-width: none;
    height: 44px;
    margin: 0;
    object-fit: contain;
    background: #FFF;
    border: 1px solid var(--sku-border);
    border-radius: 6px;
}

#digia_order_by_sku .rowmessage {
    grid-area: message;
    margin-top: 8px;
    font-size: 13px;
    line-height: 1.4;
    color: var(--sku-red);
}

#digia_order_by_sku .rowtitle:empty,
#digia_order_by_sku .rowmessage:empty,
#digia_order_by_sku .pproduct_id {
    display: none;
}

#digia_order_by_sku .formErrors {
    display: none;
    margin: 18px 24px 0;
    padding: 12px 14px;
    background: #FDF1EF;
    border: 1px solid #F1C9C3;
    border-radius: 6px;
    color: var(--sku-red);
    font-size: 14px;
    line-height: 1.5;
}

/* Steps and help box */
#digia_order_by_sku .digia-sku-aside {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

#digia_order_by_sku .digia-sku-eyebrow {
    margin: 0 0 16px;
    font-family: 'Roboto SemiBold', sans-serif;
    font-size: 12px;
    line-height: 1.4;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--sku-green);
}

#digia_order_by_sku .digia-sku-step-list {
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin: 0;
    padding: 0;
    list-style: none;
}

#digia_order_by_sku .digia-sku-step-list li {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 0;
    font-family: 'Roboto SemiBold', sans-serif;
    font-size: 14px;
    line-height: 1.35;
}

#digia_order_by_sku .digia-sku-step-number {
    flex: 0 0 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 32px;
    background: var(--sku-green-light);
    border: 1px solid #CFE3DB;
    border-radius: 6px;
    color: var(--sku-green);
    font-family: 'Roboto Regular', sans-serif;
    font-size: 13px;
    font-variant-numeric: tabular-nums;
}

#digia_order_by_sku .digia-sku-note {
    margin: 18px 0 0;
    font-size: 13px;
    line-height: 1.6;
    color: var(--sku-muted);
}

#digia_order_by_sku .digia-sku-note + .digia-sku-note {
    margin-top: 8px;
}

#digia_order_by_sku .digia-sku-help {
    display: flex;
    flex-direction: column;
    gap: 20px;
    padding: 22px;
    border-radius: 10px;
    background: linear-gradient(135deg, #0F5545 0%, #0B3D33 100%);
    box-shadow: 0 1px 3px rgb(0 0 0 / 10%);
    color: #FFF;
}

#digia_order_by_sku .digia-sku-help-header {
    display: flex;
    align-items: flex-start;
    gap: 14px;
}

#digia_order_by_sku .digia-sku-help-icon svg {
    display: block;
    width: 40px;
    height: 40px;
}

#digia_order_by_sku .digia-sku-help-title {
    margin: 0 0 6px;
    font-family: 'Roboto SemiBold', sans-serif;
    font-size: 20px;
    line-height: 1.25;
    text-transform: none;
    color: #FFF;
}

#digia_order_by_sku .digia-sku-help-text {
    margin: 0;
    font-size: 14px;
    line-height: 1.5;
    color: rgb(255 255 255 / 85%);
}

#digia_order_by_sku .digia-sku-help-button {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 16px;
    background: #FFF;
    border-radius: 6px;
    color: var(--sku-text);
    font-family: 'Roboto SemiBold', sans-serif;
    font-size: 14px;
    text-decoration: none;
    transition: background 150ms ease;
}

#digia_order_by_sku .digia-sku-help-button:hover {
    background: var(--sku-green-light);
}

#digia_order_by_sku .digia-sku-help-button .digia-sku-icon {
    width: 16px;
    height: 16px;
}

/* Loading overlay while the codes are checked and added to the cart */
#loading-data {
    position: fixed;
    inset: 0;
    z-index: 999;
    display: none;
    background: rgb(255 255 255 / 60%);
}

#loading-data::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 40px;
    height: 40px;
    margin: -20px 0 0 -20px;
    box-sizing: border-box;
    border: 3px solid #CFE3DB;
    border-top-color: #00664F;
    border-radius: 50%;
    animation: digia-sku-spin 800ms linear infinite;
}

@keyframes digia-sku-spin {
    to {
        transform: rotate(360deg);
    }
}

@media (max-width: 960px) {
    /* style.css gives the page content width: 100% plus padding here, which pushes the cards' right edge off screen */
    body.page-template-default #content:has(#digia_order_by_sku) {
        box-sizing: border-box;
    }

    #digia_order_by_sku .digia-sku-layout {
        grid-template-columns: minmax(0, 1fr);
    }
}

@media (max-width: 600px) {
    #digia_order_by_sku .digia-sku-card-header,
    #digia_order_by_sku .digia-sku-card-body,
    #digia_order_by_sku .digia-sku-card-footer {
        padding-left: 16px;
        padding-right: 16px;
    }

    #digia_order_by_sku .digia-sku-rows-head,
    #digia_order_by_sku .prow {
        grid-template-columns: minmax(0, 1fr) 84px auto;
        column-gap: 8px;
        padding-left: 16px;
        padding-right: 16px;
    }

    #digia_order_by_sku .formErrors {
        margin-left: 16px;
        margin-right: 16px;
    }

    #digia_order_by_sku .digia-sku-actions .digia-sku-button,
    #digia_order_by_sku .digia-sku-card-footer .digia-sku-button {
        width: 100%;
    }
}

#digia_order_by_sku .rowtitle {
    flex-wrap: wrap;
    overflow-wrap: anywhere;
}

#digia_order_by_sku .rowtitle label {
    flex-basis: 100%;
}

#digia_order_by_sku .erp-product-name {
    display: block;
    width: 100%;
    max-width: 32rem;
    margin-top: 8px;
    box-sizing: border-box;
}
