/* ================================================================
   WPE Customize Modal — Phase 2
   ================================================================ */

/* ── Overlay ── */
.wpe-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999990;
    opacity: 0;
    transition: opacity 0.25s ease;
    overflow: hidden;
}

.wpe-modal-overlay.visible {
    opacity: 1;
}

/* ── Modal Container ── */
.wpe-modal {
    position: fixed;
    inset: 0;
    background: #fff;
    z-index: 999991;
    display: flex;
    flex-direction: column;
    transform: translateY(20px);
    opacity: 0;
    transition: transform 0.3s ease, opacity 0.3s ease;
}

.wpe-modal-overlay.visible .wpe-modal {
    transform: translateY(0);
    opacity: 1;
}

/* ── Header ── */
.wpe-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 24px;
    border-bottom: 1px solid #e5e5e5;
    background: #fff;
    flex-shrink: 0;
}

.wpe-modal-back {
    display: flex;
    align-items: center;
    gap: 6px;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.85rem;
    color: #555;
    padding: 6px 10px;
    border-radius: 4px;
    transition: background 0.15s ease;
}

.wpe-modal-back:hover {
    background: #f5f5f5;
    color: #111;
}

.wpe-modal-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: #1a1a1a;
    letter-spacing: 0.02em;
    text-align: center;
    flex: 1;
}

.wpe-modal-close-x {
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px;
    color: #888;
    border-radius: 4px;
    transition: all 0.15s ease;
    display: flex;
    align-items: center;
}

.wpe-modal-close-x:hover {
    background: #f5f5f5;
    color: #333;
}

/* ── Body (two columns) ── */
.wpe-modal-body {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* LEFT panel: controls */
.wpe-modal-left {
    width: 400px;
    min-width: 360px;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    border-right: 1px solid #e5e5e5;
    background: #fafafa;
}

/* RIGHT panel: preview */
.wpe-modal-right {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: #f0f0f0;
    position: relative;
    overflow: hidden;
    padding: 24px;
}

/* ── Sections in left panel ── */
.wpe-modal-section {
    padding: 20px 24px;
    border-bottom: 1px solid #e5e5e5;
}

/* ── Order Type Toggle (Sample vs Full Wall) ── */
.wpe-order-type-section {
    background: #fff;
}

.wpe-order-type-toggle {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.wpe-order-type-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border: 1.5px solid #ddd;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s ease;
    background: #fff;
}

.wpe-order-type-card:hover {
    border-color: #aaa;
}

.wpe-order-type-card.checked {
    border-color: #1a1a1a;
    background: #fafafa;
    box-shadow: 0 0 0 1px #1a1a1a;
}

.wpe-order-type-radio {
    width: 18px;
    height: 18px;
    border: 2px solid #ccc;
    border-radius: 50%;
    flex-shrink: 0;
    position: relative;
    transition: border-color 0.15s ease;
}

.wpe-order-type-card.checked .wpe-order-type-radio {
    border-color: #1a1a1a;
}

.wpe-order-type-card.checked .wpe-order-type-radio::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 8px;
    height: 8px;
    background: #1a1a1a;
    border-radius: 50%;
}

.wpe-order-type-info {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.wpe-order-type-info strong {
    font-size: 0.82rem;
    font-weight: 600;
    color: #1a1a1a;
}

.wpe-order-type-info span {
    font-size: 0.72rem;
    color: #888;
}

/* ── Sample Content ── */
.wpe-sample-info {
    text-align: center;
    padding: 16px 0 8px;
}

.wpe-sample-icon {
    margin-bottom: 10px;
}

.wpe-sample-info h4 {
    font-size: 0.95rem;
    font-weight: 600;
    color: #1a1a1a;
    margin: 0 0 8px 0;
}

.wpe-sample-info p {
    font-size: 0.8rem;
    color: #666;
    line-height: 1.6;
    margin: 0;
}

/* Sample material cards show their sample price */
.wpe-sample-price-tag {
    font-size: 0.82rem;
    font-weight: 600;
    color: #1a1a1a;
    white-space: nowrap;
}

.wpe-modal-section-title {
    font-size: 0.82rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #555;
    margin: 0 0 12px 0;
}

.wpe-modal-hint {
    font-size: 0.78rem;
    color: #888;
    margin: 0 0 14px 0;
    line-height: 1.5;
}

/* ── Dimension Inputs ── */
.wpe-dim-group {
    margin-bottom: 14px;
}

.wpe-dim-label {
    display: block;
    font-size: 0.78rem;
    font-weight: 500;
    color: #666;
    margin-bottom: 6px;
    letter-spacing: 0.03em;
}

.wpe-dim-inputs {
    display: flex;
    gap: 10px;
}

.wpe-dim-field {
    display: flex;
    align-items: center;
    flex: 1;
    background: #fff;
    border: 1.5px solid #ddd;
    border-radius: 6px;
    overflow: hidden;
    transition: border-color 0.15s ease;
}

.wpe-dim-field:focus-within {
    border-color: #1a1a1a;
}

.wpe-dim-input {
    flex: 1;
    border: none;
    background: transparent;
    padding: 10px 12px;
    font-size: 0.95rem;
    font-weight: 500;
    color: #1a1a1a;
    outline: none;
    width: 100%;
    -moz-appearance: textfield;
}

.wpe-dim-input::-webkit-inner-spin-button,
.wpe-dim-input::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.wpe-dim-unit {
    padding: 10px 12px;
    font-size: 0.82rem;
    color: #999;
    font-weight: 500;
    background: #f8f8f8;
    border-left: 1px solid #eee;
    white-space: nowrap;
}

/* ── Link-style buttons ── */
.wpe-link-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.78rem;
    color: #888;
    padding: 6px 0;
    transition: color 0.15s ease;
}

.wpe-link-btn:hover {
    color: #333;
}

/* ── Material Cards ── */
.wpe-modal-material-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 16px;
    border: 1.5px solid #ddd;
    border-radius: 6px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: all 0.15s ease;
    background: #fff;
}

.wpe-modal-material-card:hover {
    border-color: #aaa;
}

.wpe-modal-material-card.active {
    border-color: #1a1a1a;
    background: #fafafa;
    box-shadow: 0 0 0 1px #1a1a1a;
}

.wpe-modal-material-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.wpe-modal-material-info strong {
    font-size: 0.82rem;
    font-weight: 600;
    color: #1a1a1a;
}

.wpe-modal-material-desc {
    font-size: 0.72rem;
    color: #999;
}

.wpe-modal-material-price {
    font-size: 0.85rem;
    font-weight: 600;
    color: #1a1a1a;
    white-space: nowrap;
}

.wpe-modal-material-price small {
    font-weight: 400;
    color: #999;
    font-size: 0.72rem;
}

/* ── Comment ── */
.wpe-comment-wrap {
    margin-top: 10px;
}

.wpe-textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1.5px solid #ddd;
    border-radius: 6px;
    font-size: 0.82rem;
    font-family: inherit;
    resize: vertical;
    outline: none;
    transition: border-color 0.15s ease;
}

.wpe-textarea:focus {
    border-color: #1a1a1a;
}

/* ── Price + ATC footer ── */
.wpe-modal-footer-section {
    padding: 20px 24px;
    margin-top: auto;
    background: #fff;
    border-top: 1px solid #e5e5e5;
}

.wpe-modal-price-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 4px;
}

.wpe-modal-price-info {
    display: flex;
    flex-direction: column;
}

.wpe-modal-price-label {
    font-size: 0.72rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #999;
}

.wpe-modal-price-amount {
    font-size: 1.5rem;
    font-weight: 700;
    color: #1a1a1a;
    line-height: 1.2;
}

.wpe-modal-price-detail {
    font-size: 0.75rem;
    color: #888;
    text-align: right;
}

.wpe-modal-min-notice {
    font-size: 0.75rem;
    color: #c0392b;
    margin-bottom: 8px;
    padding: 6px 10px;
    background: #fdf0ef;
    border-radius: 4px;
}

.wpe-modal-panels-info {
    font-size: 0.78rem;
    color: #555;
    margin-bottom: 10px;
    padding: 8px 12px;
    background: #f0f7ff;
    border-radius: 4px;
    border: 1px solid #d0e3f7;
}

.wpe-modal-atc-btn {
    display: block;
    width: 100%;
    padding: 16px 24px;
    background: #1a1a1a;
    color: #fff;
    border: none;
    border-radius: 4px;
    font-size: 0.88rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.1s ease;
    margin-top: 12px;
}

.wpe-modal-atc-btn:hover {
    background: #333;
}

.wpe-modal-atc-btn:active {
    transform: scale(0.98);
}

.wpe-modal-atc-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.wpe-modal-atc-btn.loading {
    position: relative;
    color: transparent;
}

.wpe-modal-atc-btn.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: wpe-spin 0.6s linear infinite;
}

.wpe-modal-atc-feedback {
    text-align: center;
    padding: 10px;
    font-size: 0.82rem;
    border-radius: 4px;
    margin-top: 8px;
}

.wpe-modal-atc-feedback.success {
    background: #e8f5e9;
    color: #2e7d32;
    padding: 0;
}

.wpe-modal-atc-feedback.error {
    background: #fbe9e7;
    color: #c62828;
}

/* ── Add to Cart success message ── */
.wpe-atc-success {
    padding: 16px;
    text-align: center;
}

.wpe-atc-success-icon {
    font-size: 1.5rem;
    margin-bottom: 4px;
}

.wpe-atc-success-msg {
    font-size: 0.85rem;
    font-weight: 600;
    color: #2e7d32;
    margin-bottom: 14px;
}

.wpe-atc-success-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.wpe-atc-goto-cart {
    display: inline-flex;
    align-items: center;
    padding: 10px 20px;
    background: #1a1a1a;
    color: #fff !important;
    border: none;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-decoration: none !important;
    cursor: pointer;
    transition: background 0.15s ease;
}

.wpe-atc-goto-cart:hover {
    background: #333;
    color: #fff !important;
}

.wpe-atc-continue {
    display: inline-flex;
    align-items: center;
    padding: 10px 20px;
    background: #fff;
    color: #1a1a1a;
    border: 1.5px solid #ddd;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    cursor: pointer;
    transition: all 0.15s ease;
}

.wpe-atc-continue:hover {
    border-color: #999;
    background: #f8f8f8;
}

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

/* ── Preview Area ── */

/* When sample is selected, show sample-specific preview */
.wpe-modal-right-sample {
    /* Don't dim — we show an actual sample preview canvas */
}

.wpe-preview-annotations {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: 2;
}

.wpe-annotation-width {
    position: absolute;
    top: 8px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0,0,0,0.7);
    color: #fff;
    font-size: 0.72rem;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 3px;
    white-space: nowrap;
    letter-spacing: 0.02em;
}

.wpe-annotation-height {
    position: absolute;
    left: 8px;
    top: 50%;
    transform: translateY(-50%) rotate(-90deg);
    background: rgba(0,0,0,0.7);
    color: #fff;
    font-size: 0.72rem;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 3px;
    white-space: nowrap;
    letter-spacing: 0.02em;
}

/* Cropper container */
.wpe-preview-cropper {
    width: 100%;
    max-width: 700px;
    max-height: calc(100vh - 180px);
    position: relative;
}

.wpe-preview-cropper img {
    max-width: 100%;
    display: block;
}

/* Grayscale toggle */
.wpe-preview-cropper.grayscale img,
.wpe-preview-cropper.grayscale .cropper-canvas {
    filter: grayscale(100%);
}

/* Flipped */
.wpe-preview-cropper.flipped img,
.wpe-preview-cropper.flipped .cropper-canvas {
    transform: scaleX(-1);
}

/* ── Wallpaper panel preview ── */
.wpe-preview-panels {
    width: 100%;
    max-width: 700px;
}

.wpe-panels-grid {
    display: flex;
    gap: 2px;
    border: 2px solid #bbb;
    background: #ddd;
    overflow: hidden;
    border-radius: 4px;
}

.wpe-panel-strip {
    flex: 1;
    background-size: cover;
    background-position: center;
    background-repeat: repeat;
    border-right: 1px dashed rgba(0,0,0,0.15);
    position: relative;
    min-height: 300px;
}

.wpe-panel-strip:last-child {
    border-right: none;
}

.wpe-panel-strip-label {
    position: absolute;
    bottom: 4px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.65rem;
    color: rgba(0,0,0,0.5);
    background: rgba(255,255,255,0.7);
    padding: 1px 6px;
    border-radius: 2px;
    white-space: nowrap;
}

/* ── Toolbar ── */
.wpe-preview-toolbar {
    display: flex;
    gap: 8px;
    padding: 12px 0;
    justify-content: center;
}

.wpe-toolbar-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 7px 14px;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 0.75rem;
    color: #555;
    cursor: pointer;
    transition: all 0.15s ease;
}

.wpe-toolbar-btn:hover {
    border-color: #999;
    color: #222;
}

.wpe-toolbar-btn.active {
    background: #1a1a1a;
    color: #fff;
    border-color: #1a1a1a;
}

/* ── How to Measure popup ── */
.wpe-measure-popup {
    position: fixed;
    inset: 0;
    z-index: 999999;
    background: rgba(0,0,0,0.4);
    display: flex;
    align-items: center;
    justify-content: center;
}

.wpe-measure-popup-inner {
    background: #fff;
    border-radius: 10px;
    padding: 28px 32px;
    max-width: 440px;
    width: 90%;
    position: relative;
    box-shadow: 0 20px 60px rgba(0,0,0,0.15);
}

.wpe-measure-popup-inner h4 {
    font-size: 1rem;
    margin: 0 0 14px 0;
    color: #1a1a1a;
}

.wpe-measure-popup-inner ol {
    padding-left: 20px;
    margin: 0 0 14px 0;
    font-size: 0.85rem;
    color: #444;
    line-height: 1.6;
}

.wpe-measure-popup-inner p {
    font-size: 0.82rem;
    color: #888;
    margin: 0;
}

.wpe-measure-close {
    position: absolute;
    top: 12px;
    right: 14px;
    background: none;
    border: none;
    font-size: 1.4rem;
    cursor: pointer;
    color: #999;
    padding: 4px;
    line-height: 1;
}

.wpe-measure-close:hover {
    color: #333;
}

/* ================================================================
   Responsive
   ================================================================ */

@media (max-width: 900px) {
    .wpe-modal-body {
        flex-direction: column-reverse;
    }

    .wpe-modal-left {
        width: 100%;
        min-width: unset;
        border-right: none;
        border-top: 1px solid #e5e5e5;
        max-height: 55vh;
    }

    .wpe-modal-right {
        max-height: 45vh;
        padding: 16px;
    }

    .wpe-preview-cropper {
        max-height: 40vh;
    }

    .wpe-modal-section {
        padding: 16px 20px;
    }

    .wpe-modal-footer-section {
        padding: 16px 20px;
    }
}

@media (max-width: 600px) {
    .wpe-modal-header {
        padding: 10px 16px;
    }

    .wpe-modal-title {
        font-size: 0.82rem;
    }

    .wpe-dim-inputs {
        gap: 8px;
    }

    .wpe-modal-material-card {
        flex-direction: column;
        align-items: flex-start;
        gap: 6px;
    }

    .wpe-modal-price-amount {
        font-size: 1.25rem;
    }
}
