/* ================================================================
   PCU Frontend — Customizer Modal Styles
   Scale: 1rem = 10px (Fluid Design — align with site html font-size)
   ================================================================ */

/* ── Add to cart ↔ Design (Alpine + grid stack) ───────────────────── */

.pcu-atc-switch {
    display: grid;
    grid-template-areas: stack;
    align-items: center;
    justify-items: start;
    width: 100%;
    justify-content: start;
}

.pcu-atc-switch > .single_add_to_cart_button,
.pcu-atc-switch > #pcu-design-trigger {
    grid-area: stack;
}

.pcu-atc-switch > .single_add_to_cart_button {
    transition: opacity 0.22s ease, transform 0.22s ease, visibility 0.22s ease;
}

.pcu-atc-switch.is-pcu-design > .single_add_to_cart_button {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(-0.4rem);
}

/* Không có Alpine: ẩn nút design cho đến khi có .is-pcu-design */
html:not(.pcu-alpine) .pcu-atc-switch:not(.is-pcu-design) #pcu-design-trigger {
    display: none !important;
}

/* ── Trigger button ───────────────────────────────────────────────── */

#pcu-design-trigger {
    margin: 1.2rem 0;
}



.pcu-btn-sm {
    padding: 0.8rem 1.6rem;
    font-size: 1.3rem;
    background: transparent;
    color: var(--espresso-brown);
    border-radius: 99rem;
    border: 0.1rem solid var(--espresso-brown);
    font-family: "Heading Now";
    line-height: unset;
}

.pcu-btn-danger {
    background: #fff;
    color: #ff4d4f;
    border: 0.1rem solid #ff7875;
}

.pcu-btn-danger:hover {
    background: #fff2f0;
}

.pcu-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

/* ── Modal overlay ────────────────────────────────────────────────── */

.pcu-modal {
    position: fixed;
    inset: 0;
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
}

.pcu-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(0.4rem);
}

.pcu-modal-container {
    position: relative;
    height: 92vh;
    width: 160rem;
    border-radius: 1.8rem;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 2.5rem 6rem rgba(0, 0, 0, 0.3);
    animation: pcu-modal-in 0.3s ease-out;
}

/* Close — góc trên phải trong khung modal */
.pcu-modal-close-btn--floating {
    position: absolute;
    top: 1rem;
    right: 1rem;
    z-index: 20;
}

@media (max-width: 480px) {
    .pcu-modal-close-btn--floating {
        top: 2rem;
        right: 2rem;
        font-size:2.5rem;
    }
}

@keyframes pcu-modal-in {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(2rem);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* ── Modal header ─────────────────────────────────────────────────── */

.pcu-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.6rem 2.4rem;
    border-bottom: 0.1rem solid rgb(143 73 37 / 15%);
    display:none;
}

.pcu-modal-header h2 {
    margin: 0;
    font-size: 1.8rem;
    font-weight: 700;
    color: #333;
}

.pcu-modal-close-btn {
    width: 3.6rem;
    height: 3.6rem;
    border: none;
    background: transparent;
    font-size: 3rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    color: #666;
}

/* ── Modal body ───────────────────────────────────────────────────── */

.pcu-modal-body {
    display: flex;
    flex: 1;
    min-height: 0;
    padding:2rem;
    padding-right:0;
    overflow: hidden;
    background-color: #E8DCCB;
}

.pcu-modal-canvas-col {
    flex: 1;
    min-width: 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: stretch;
    overflow: hidden;
}

.pcu-canvas-wrapper {
    flex: 1;
    width: 100%;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background: rgba(55, 40, 33, 0.10);
    border-radius: 1.2rem;
}

/* Kích thước canvas do Fabric set (pixel) — không override width/height CSS (lệch hit-test). Contain: JS. */
.pcu-canvas-wrapper canvas {
    display: block;
    vertical-align: middle;
}

/* ── Tools column ─────────────────────────────────────────────────── */

.pcu-modal-tools-col {
    width: 40%;
    flex-shrink: 0;
    padding: 3rem 6rem;
    padding-bottom:2.5rem;
    display: flex;
    flex-direction: column;
}

.pcu-modal-tools-col-inner {
    flex:1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 2rem;
    padding-right: 1rem;
}

.pcu-modal-tools-col-inner::-webkit-scrollbar {
    width: 0.3rem;
    border-radius: 99rem;
}

.pcu-modal-tools-col-inner::-webkit-scrollbar-thumb {
    background: rgb(55 40 33 / 20%);
    border-radius: 99px;
}

.pcu-modal-tools-col-inner::-webkit-scrollbar-track {
    background: transparent;
    border-radius: 99rem;
}

.pcu-modal-tools-col-header .pcu-modal-product-name {
    color: var(--light-chocolatte);
    font-size: 1.4rem;
    text-transform: uppercase;
    margin-bottom: 1.4rem;
    opacity: 0.7;
    font-family: "Gotham";
}

.pcu-modal-tools-col-header .pcu-modal-product-name:empty {
    display: none;
}

.pcu-modal-tools-col-header {
    margin-bottom: 2.5rem;
}

.pcu-modal-tools-col-header h3 {
    margin: 0;
    font-size: 3.4rem;
    color: var(--espresso-brown);
}

.pcu-tool-label {
    display: block;
    font-size: 1.3rem;
    color: var(--light-chocolatte);
    margin-bottom: 1rem;
    text-transform: uppercase;
}

.pcu-tool-hint {
    margin: 0.6rem 0 0;
    font-size: 1.1rem;
    line-height: 1.35;
    color: #888;
    font-weight: 400;
    text-transform: none;
    letter-spacing: 0;
    display:none;
}

.pcu-align-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.8rem;
    align-items: center;
}

.pcu-btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 4.4rem;
    height: 4.4rem;
    min-width: 4.4rem;
    padding: 0;
    border-radius: 0.8rem;
    background: rgba(143, 73, 37, 0.10);
    color: rgb(55 40 33 / 80%);
    border: 0.1rem solid rgb(23 22 20 / 10%);
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s, color 0.2s;
}

.pcu-btn-icon:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.pcu-btn-icon.pcu-btn-icon--danger {
    color: var(--brown-red);
}

.pcu-delete-selected-wrap {
    display: inline-flex;
    align-items: center;
}

.pcu-align-icon {
    width: 2.4rem;
    height: 2.4rem;
    display: block;
}

.pcu-sr-only {
    position: absolute;
    width: 0.1rem;
    height: 0.1rem;
    padding: 0;
    margin: -0.1rem;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.pcu-tool-row {
    display: flex;
    gap: 0.8rem;
}

.pcu-input {
    flex: 1;
    padding: 0.4rem 1.4rem;
    padding-left: 0;
    padding-bottom: 0.8rem;
    font-size: 1.6rem;
    outline: none;
    background-color:transparent;
    line-height: unset;
    border:0;
    border-bottom:0.1rem solid rgb(55 40 33 / 15%);
    transition:0.3s ease all;
}

.pcu-input::placeholder {
    color: rgb(55 40 33 / 50%);
}

.pcu-input:focus {
    border-color: rgb(55 40 33 / 100%);
}

.pcu-select {
    width: 100%;
    padding: 1rem 1.4rem;
    border: 0.1rem solid #d9d9d9;
    border-radius: 0.8rem;
    font-size: 1.4rem;
    background: #fff;
    cursor: pointer;
    outline: none;
}

.pcu-select:focus {
    border-color: var(--brown-red);
}

/* ── Icon grid ────────────────────────────────────────────────────── */

.pcu-icon-grid {
    display: flex;
    flex-wrap: wrap;    
    gap: 0.8rem;
    transition: opacity 0.2s;
}

.pcu-icon-grid-item {
    aspect-ratio: 1;
    border: 1px solid rgba(23, 22, 20, 0.20);
    border-radius: 0.8rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: 0.3s ease all;
    gap: 0.4rem;
    height: 6rem;
    width: 6rem;
    padding: 1.8rem;
}

.pcu-icon-grid-item:hover {
    border-color: var(--brown-red);
    background: rgba(143, 73, 37, 0.10);
}

.pcu-icon-grid-item img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* ── Font grid (similar to icon grid) ────────────────────────────── */

.pcu-font-grid {
    display: flex;
    gap: 0.8rem;
    transition: opacity 0.2s;
    flex-wrap: wrap;
}

.pcu-font-grid.pcu-disabled {
    opacity: 0.4;
    pointer-events: none;
}

.pcu-font-grid-item {
    border: 0.1rem solid rgba(23, 22, 20, 0.20);
    border-radius: 0.8rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: 0.3s ease all;
    gap: 0.4rem;
    height: 6rem;
    width: 6rem;
}

.pcu-font-grid-item:hover span {
    transition:0.3s ease all;
}

.pcu-font-grid-item:hover, .pcu-font-grid-item.active {
    border-color: var(--brown-red);
    background: rgba(143, 73, 37, 0.10);
}

.pcu-font-grid-item:hover span, .pcu-font-grid-item.active span {
    color: var(--brown-red);
}

.pcu-font-grid-preview {
    font-size: 2rem;
    line-height: 1.1;
    color: rgb(55 40 33 / 80%);
}

.pcu-font-grid-name {
    font-size: 0.9rem;
    color: var(--espresso-brown);
    text-align: center;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
    display:none;
}

/* ── Color swatches ───────────────────────────────────────────────── */

.pcu-color-swatches {
    display: flex;
    flex-wrap: wrap;
    gap: 0.8rem;
}

.pcu-color-swatch {
    width: 4rem;
    height: 4rem;
    border-radius: 99rem;
    border: 0.5rem solid #E8DCCB;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: inset 0 0 0 0.1rem rgba(0, 0, 0, 0.08);
    margin-left:0.6rem;
    outline: 0.2rem solid transparent;
    outline-offset: 0.2rem;
}

.pcu-color-swatch:hover {
    outline: 0.2rem solid #3d2b1f;
    outline-offset: 0.2rem;
}

@media (max-width: 450px) {
    .pcu-color-swatch {
        width: 3rem;
        height: 3rem;
        border-width: 0.15rem;
    }
    .pcu-icon-grid-item {
        padding: 1.3rem;
    }
}

/* ── Modal footer ─────────────────────────────────────────────────── */

.pcu-modal-footer {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    padding-top:2rem;
    gap:1.5rem;
}

.pcu-pricing {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    font-size: 1.3rem;
    color: #555;
    width:100%;
    font-family: "Heading Now";
    color:var(--light-chocolatte);
    background-color: rgb(217 202 181 / 60%);
    padding:2rem;
    border-radius: 1.2rem;
}

.pcu-pricing .pru-pricing-item--total span {
    font-size: 1.6rem;
    color: var(--brown-red);
}

.pcu-pricing-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
}

.pcu-pricing-item.pru-pricing-item--total {
    border-top: 0.1rem solid #cab9a1;
    padding-top: 1rem;
    margin-top: 0.5rem;
}

.pcu-actions {
    display: flex;
    gap: 1.2rem;
    width:100%;
}

.pcu-actions button {
    flex: 1;
}

/* ── Loading spinner ──────────────────────────────────────────────── */

.pcu-loading {
    position: absolute;
    inset: 0;
    background: rgb(232 220 203 / 65%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    border-radius: 1.6rem;
}

.pcu-spinner {
    width: 4rem;
    height: 4rem;
    border: 0.3rem solid #f0f0f0;
    border-top-color: var(--brown-red);
    border-radius: 50%;
    animation: pcu-spin 0.7s linear infinite;
}

@keyframes pcu-spin {
    to {
        transform: rotate(360deg);
    }
}

/* ── Empty states ─────────────────────────────────────────────────── */

.pcu-empty {
    text-align: center;
    padding: 1.6rem;
    color: #bbb;
    font-size: 1.3rem;
}

/* ── Responsive ───────────────────────────────────────────────────── */

@media (max-width: 991px) {
    .pcu-modal-container {
        width: 100dvw;
        height: 100dvh;
        border-radius: 0;
    }

    .pcu-modal-body {
        flex-direction: column;
        padding-right:2rem;
    }

    .pcu-modal-canvas-col {
        height: 45vh;
        min-height: 45vh;
        max-height: 45vh;
    }
    .pcu-modal-tools-col {
        width: 100%;
        padding: 3rem 1.5rem;
        border-left: none;
        padding-bottom:1rem;
        max-height:unset;
        flex: 1;
        overflow-y: auto;
    }

    .pcu-modal-footer {
        flex-direction: column;
        gap: 1.2rem;
        padding-top:1rem;
    }

    .pcu-pricing {
        flex-wrap: wrap;
        justify-content: center;
        padding:1.5rem;
    }
}

@media (max-width: 450px) {
    .pcu-actions {
        gap:0.8rem;
    }
    .pcu-actions .brxe-button {
        padding-top:1rem;
        padding-bottom:1rem;
    }

    .pcu-modal-tools-col {
        padding: 2rem 0 0rem;
    }

    .pcu-modal-tools-col-header .pcu-modal-product-name {
        font-size:1.2rem;
        margin-bottom:0.8rem;
    }
    .pcu-modal-tools-col-header h3 {
        font-size:2rem;
    }
    .pcu-pricing {
        font-size: 0.9rem;
        gap:0.3rem;
        padding: 1rem 1.5rem;
    }
    .pcu-pricing .pru-pricing-item--total span {
        font-size: 1.3rem;
        color: var(--brown-red);
    }
    .pcu-pricing-item.pru-pricing-item--total {
        padding-top: 0.75rem;
        margin-top: 0.25rem;
    }
    .pcu-tool-label {
        margin-bottom:0.5rem;
        font-size:1.15rem;
    }
    .pcu-btn-sm {
        font-size:1.15rem;
        height: 3.4rem;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    .pcu-tool-row {
        align-items: flex-end;
    }
    .pcu-modal-tools-col-header {
        margin-bottom: 1.25rem;
    }
    .pcu-modal-tools-col-inner {
        gap: 1.25rem;
    }
    .pcu-font-grid-item {
        height: 4.5rem;
        width: 4.5rem;
    }
    .pcu-font-grid-preview {
        font-size: 1.6rem;
    }
    .pcu-icon-grid-item {
        height: 4.5rem;
        width: 4.5rem;
    }
    .pcu-pricing-item.pru-pricing-item--total {
        display:none;
    }
}
