/* Product detail inspired by a familiar marketplace product page. */
body.pm-modal-open {
    overflow: hidden !important;
}

.product-modal-overlay {
    z-index: 20000;
    align-items: center;
    padding: 22px;
    background: rgba(3, 10, 22, 0.82);
    backdrop-filter: blur(10px);
}

body:not(.light-theme) .product-modal {
    width: min(1180px, 100%);
    max-width: 1180px;
    max-height: calc(100dvh - 44px);
    border: 1px solid #2a3a51 !important;
    border-radius: 22px;
    color: #edf4ff !important;
    background: #101a29 !important;
    box-shadow: 0 30px 90px rgba(0, 0, 0, 0.54) !important;
}

body.light-theme .product-modal {
    width: min(1180px, 100%);
    max-width: 1180px;
    max-height: calc(100dvh - 44px);
    border: 1px solid #e2e8f0;
    border-radius: 22px;
    color: #172033;
    background: #ffffff;
    box-shadow: 0 28px 80px rgba(15, 23, 42, 0.2);
}

.product-modal .pm-layout {
    display: grid;
    grid-template-columns: minmax(0, 1.02fr) minmax(430px, 0.98fr);
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.product-modal .pm-media {
    display: flex;
    flex-direction: column;
    gap: 18px;
    min-width: 0;
    padding: 38px;
    border-right: 1px solid #26354a;
    background: #0c1522;
}

body.light-theme .product-modal .pm-media {
    border-right-color: #e7ebf1;
    background: #f7f9fc;
}

.product-modal .pm-product-stage {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    aspect-ratio: 16 / 9;
    min-height: 280px;
    overflow: hidden;
    border: 1px solid #dfe5ed;
    border-radius: 18px;
    background: #ffffff;
    box-shadow: 0 18px 44px rgba(0, 0, 0, 0.18);
}

.product-modal .pm-product-image {
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    padding: 0;
    object-fit: contain;
    background: #ffffff;
}

.product-modal .pm-product-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    width: 100%;
    height: 100%;
    color: #64748b;
    font-size: 0.9rem;
}

.product-modal .pm-product-placeholder i {
    color: #2f7df6;
    font-size: 3.2rem;
}

.product-modal .pm-stock-chip {
    position: absolute;
    top: 14px;
    right: 14px;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 8px 11px;
    border-radius: 999px;
    color: #ffffff;
    background: #0e9f6e;
    box-shadow: 0 8px 20px rgba(14, 159, 110, 0.24);
    font-size: 0.78rem;
    font-weight: 800;
}

.product-modal .pm-stock-chip.is-out-stock {
    background: #dc3545;
}

.product-modal .pm-media-note {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 14px 16px;
    border: 1px solid #27384f;
    border-radius: 14px;
    color: #aebbd0;
    background: #111e2f;
    font-size: 0.86rem;
    line-height: 1.55;
}

body.light-theme .product-modal .pm-media-note {
    border-color: #dfe6ef;
    color: #536176;
    background: #ffffff;
}

.product-modal .pm-media-note i {
    margin-top: 2px;
    color: #0e9f6e;
}

.product-modal .pm-body {
    display: flex;
    flex-direction: column;
    gap: 18px;
    min-width: 0;
    padding: 38px 40px 34px;
    overflow-y: auto;
    background: #101a29;
}

body.light-theme .product-modal .pm-body {
    background: #ffffff;
}

.product-modal .pm-eyebrow {
    color: #2f7df6;
    font-size: 0.76rem;
    font-weight: 900;
    letter-spacing: 0.1em;
}

.product-modal .pm-title {
    margin: -8px 42px 0 0;
    color: #f6f9ff;
    font-size: clamp(1.35rem, 2vw, 1.85rem);
    font-weight: 850;
    line-height: 1.34;
}

body.light-theme .product-modal .pm-title {
    color: #172033;
}

.product-modal .pm-meta-list {
    display: grid;
    gap: 0;
    padding: 12px 0;
    border-top: 1px solid #29384d;
    border-bottom: 1px solid #29384d;
}

body.light-theme .product-modal .pm-meta-list {
    border-color: #e5e9f0;
}

.product-modal .pm-meta-list > div {
    display: grid;
    grid-template-columns: 135px minmax(0, 1fr);
    gap: 12px;
    padding: 7px 0;
    font-size: 0.84rem;
}

.product-modal .pm-meta-list span {
    color: #93a1b5;
}

.product-modal .pm-meta-list strong {
    color: #e8eef9;
    font-weight: 700;
}

body.light-theme .product-modal .pm-meta-list span {
    color: #667085;
}

body.light-theme .product-modal .pm-meta-list strong {
    color: #273449;
}

.product-modal .is-in-stock {
    color: #13b981 !important;
}

.product-modal .is-out-stock {
    color: #f05252 !important;
}

.product-modal .pm-stock-chip.is-in-stock,
.product-modal .pm-stock-chip.is-out-stock {
    color: #ffffff !important;
}

.product-modal .pm-price-block {
    display: block;
    padding: 18px 20px;
    border: 1px solid #2d4059;
    border-radius: 14px;
    background: #152338;
}

body.light-theme .product-modal .pm-price-block {
    border-color: #e1e6ed;
    background: #f6f8fb;
}

.product-modal .pm-price-copy {
    display: flex;
    align-items: baseline;
    gap: 12px;
    flex-wrap: wrap;
}

.product-modal .pm-price-label {
    width: 100%;
    margin: 0;
    color: #91a0b5;
    font-size: 0.8rem;
    font-weight: 700;
}

.product-modal .pm-price-value {
    color: #30a0ff;
    background: none;
    -webkit-text-fill-color: currentColor;
    font-size: 1.8rem;
    font-weight: 900;
    line-height: 1;
}

.product-modal .pm-price-saving {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    color: #8f9db0;
    font-size: 0.82rem;
}

.product-modal .pm-price-saving b {
    padding: 4px 8px;
    border-radius: 999px;
    color: #ffffff;
    background: #ff4d63;
    font-size: 0.72rem;
}

.product-modal .pm-section-heading {
    margin-bottom: 10px;
    color: #e8eef9;
    font-size: 0.88rem;
    font-weight: 800;
}

body.light-theme .product-modal .pm-section-heading {
    color: #253047;
}

.product-modal .pm-duration-choice {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    max-width: 100%;
    min-height: 44px;
    padding: 11px 15px;
    border: 1px solid #2f7df6;
    border-radius: 10px;
    color: #ffffff;
    background: #2f7df6;
    box-shadow: 0 7px 18px rgba(47, 125, 246, 0.24);
    font-family: inherit;
    font-size: 0.82rem;
    font-weight: 750;
    text-align: left;
}

.product-modal .pm-duration-choice span {
    overflow: hidden;
    text-overflow: ellipsis;
}

.product-modal .pm-desc {
    max-height: 112px;
    padding: 13px 15px;
    border: 1px solid #29394f;
    border-radius: 11px;
    color: #aab7ca;
    background: #0d1725;
    font-size: 0.84rem;
    line-height: 1.6;
}

body.light-theme .product-modal .pm-desc {
    border-color: #e1e6ee;
    color: #58667a;
    background: #f8fafc;
}

.product-modal .pm-purchase-row {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 12px;
    align-items: end;
}

.product-modal .pm-qty-wrap {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    padding: 0;
    border: 0;
    background: transparent;
}

.product-modal .pm-qty-wrap label {
    color: #a8b4c6;
    font-size: 0.78rem;
    font-weight: 700;
}

.product-modal .pm-qty-control {
    display: grid;
    grid-template-columns: 42px 58px 42px;
    height: 44px;
    overflow: hidden;
    border: 1px solid #34465e;
    border-radius: 10px;
    background: #101b2b;
}

body.light-theme .product-modal .pm-qty-control {
    border-color: #d8dee8;
    background: #ffffff;
}

.product-modal .pm-qty-control button,
.product-modal .pm-qty-input {
    width: 100%;
    min-width: 0;
    height: 100%;
    padding: 0;
    border: 0;
    border-radius: 0;
    color: #eef4ff;
    background: transparent;
    font-family: inherit;
    text-align: center;
}

body.light-theme .product-modal .pm-qty-control button,
body.light-theme .product-modal .pm-qty-input {
    color: #253047;
}

.product-modal .pm-qty-control button {
    cursor: pointer;
}

.product-modal .pm-qty-control button:hover {
    color: #ffffff;
    background: #2f7df6;
}

.product-modal .pm-qty-input {
    border-right: 1px solid #34465e;
    border-left: 1px solid #34465e;
    outline: none;
    font-size: 0.95rem;
    font-weight: 800;
    appearance: textfield;
}

body.light-theme .product-modal .pm-qty-input {
    border-color: #d8dee8;
}

.product-modal .pm-qty-input::-webkit-inner-spin-button,
.product-modal .pm-qty-input::-webkit-outer-spin-button {
    margin: 0;
    appearance: none;
}

.product-modal .pm-info-row {
    min-height: 44px;
    padding: 10px 13px;
    border: 1px solid #2b3c53;
    border-radius: 10px;
    background: #121f31;
}

body.light-theme .product-modal .pm-info-row {
    border-color: #dfe5ed;
    background: #f8fafc;
}

.product-modal .pm-checklist {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
}

.product-modal .pm-check {
    align-items: flex-start;
    min-width: 0;
    padding: 11px;
    border: 1px solid #29394e;
    border-radius: 10px;
    color: #9fadbf;
    background: #111d2d;
    font-size: 0.75rem;
    line-height: 1.45;
}

body.light-theme .product-modal .pm-check {
    border-color: #e0e6ee;
    color: #5f6c7e;
    background: #f8fafc;
}

.product-modal .pm-check i {
    margin-top: 2px;
    color: #2f9df7;
}

.product-modal .pm-footer {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.product-modal .pm-btn-buy,
.product-modal .pm-btn-cart,
.product-modal .pm-btn-deposit {
    min-height: 48px;
    padding: 12px 16px;
    border-radius: 10px;
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 800;
    cursor: pointer;
}

.product-modal .pm-btn-buy {
    border: 1px solid #3295ed;
    color: #ffffff;
    background: linear-gradient(135deg, #5ba8f3, #2196de);
    box-shadow: 0 8px 20px rgba(33, 150, 222, 0.25);
}

.product-modal .pm-btn-cart {
    border: 1px solid #3a4a60;
    color: #dce6f4;
    background: #152235;
}

body.light-theme .product-modal .pm-btn-cart {
    border-color: #d7dde6;
    color: #283347;
    background: #ffffff;
}

.product-modal .pm-btn-deposit {
    width: 100%;
    border: 1px solid #f59e0b;
    color: #fbbf24;
    background: rgba(245, 158, 11, 0.09);
}

.product-modal .pm-btn-buy:hover,
.product-modal .pm-btn-cart:hover,
.product-modal .pm-btn-deposit:hover {
    transform: translateY(-1px);
    filter: brightness(1.06);
}

.product-modal .pm-btn-buy:disabled,
.product-modal .pm-btn-cart:disabled {
    border-color: #354154;
    color: #7c8797;
    background: #202938;
    box-shadow: none;
    cursor: not-allowed;
    filter: none;
    transform: none;
}

.product-modal .pm-close {
    top: 16px;
    right: 16px;
    width: 38px;
    height: 38px;
    border: 1px solid #33445b;
    color: #cbd6e6;
    background: #172438;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.18);
}

body.light-theme .product-modal .pm-close {
    border-color: #dce2ea;
    color: #4d5b70;
    background: #ffffff;
}

#header-cart-count.has-items {
    color: #ffffff;
    background: #ef3f61;
}

@media (max-width: 900px) {
    .product-modal-overlay {
        align-items: flex-end;
        padding: 0;
    }

    body:not(.light-theme) .product-modal,
    body.light-theme .product-modal {
        width: 100%;
        max-width: none;
        max-height: calc(100dvh - 6px);
        border-right: 0 !important;
        border-bottom: 0 !important;
        border-left: 0 !important;
        border-radius: 20px 20px 0 0;
    }

    .product-modal .pm-layout {
        display: block;
        overflow-y: auto;
    }

    .product-modal .pm-media {
        gap: 0;
        padding: 16px 16px 10px;
        border-right: 0;
        border-bottom: 1px solid #26364b;
    }

    body.light-theme .product-modal .pm-media {
        border-bottom-color: #e4e9f0;
    }

    .product-modal .pm-product-stage {
        min-height: 0;
        max-height: 220px;
        border-radius: 14px;
    }

    .product-modal .pm-media-note {
        display: none;
    }

    .product-modal .pm-body {
        gap: 15px;
        padding: 20px 16px calc(18px + env(safe-area-inset-bottom));
        overflow: visible;
    }

    .product-modal .pm-title {
        margin-top: -7px;
        font-size: 1.18rem;
    }

    .product-modal .pm-meta-list {
        padding: 8px 0;
    }

    .product-modal .pm-meta-list > div {
        grid-template-columns: 108px minmax(0, 1fr);
        padding: 6px 0;
        font-size: 0.78rem;
    }

    .product-modal .pm-price-block {
        padding: 15px 16px;
    }

    .product-modal .pm-price-value {
        font-size: 1.55rem;
    }

    .product-modal .pm-purchase-row {
        grid-template-columns: 1fr;
    }

    .product-modal .pm-checklist {
        grid-template-columns: 1fr;
    }

    .product-modal .pm-check {
        padding: 9px 11px;
    }

    .product-modal .pm-footer {
        position: sticky;
        bottom: 0;
        z-index: 3;
        margin: 0 -4px;
        padding: 10px 4px 2px;
        background: #101a29;
    }

    body.light-theme .product-modal .pm-footer {
        background: #ffffff;
    }

    .product-modal .pm-btn-buy,
    .product-modal .pm-btn-cart {
        min-height: 50px;
        padding: 10px;
        font-size: 0.82rem;
    }

    .product-modal .pm-close {
        top: 12px;
        right: 12px;
    }
}

@media (max-width: 420px) {
    .product-modal .pm-product-stage {
        max-height: 176px;
    }

    .product-modal .pm-duration-choice {
        width: 100%;
    }

    .product-modal .pm-footer {
        grid-template-columns: 1.05fr 0.95fr;
    }
}

/* Standalone product route */
#view-product-detail {
    width: 100%;
    max-width: 1240px;
    margin: 0 auto;
    padding: 18px 0 54px;
}

.product-detail-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
}

.product-detail-topbar button {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    min-height: 42px;
    padding: 9px 14px;
    border: 1px solid #33455e;
    border-radius: 10px;
    color: #dce6f4;
    background: #132033;
    font-family: inherit;
    font-size: 0.84rem;
    font-weight: 750;
    cursor: pointer;
}

body.light-theme .product-detail-topbar button {
    border-color: #dce3eb;
    color: #263348;
    background: #ffffff;
}

.product-detail-topbar > span {
    color: #8fa0b7;
    font-size: 0.82rem;
    font-weight: 700;
}

body.light-theme .product-detail-topbar > span {
    color: #667085;
}

body:not(.light-theme) #view-product-detail .product-detail-page.product-modal,
body.light-theme #view-product-detail .product-detail-page.product-modal {
    width: 100%;
    max-width: none;
    max-height: none;
    margin: 0;
    overflow: visible;
    animation: productPageEnter 0.28s ease both;
}

#view-product-detail .product-detail-page .pm-layout,
#view-product-detail .product-detail-page .pm-body {
    overflow: visible;
}

#view-product-detail .product-detail-page .pm-close {
    display: none !important;
}

.product-detail-route-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    min-height: 360px;
    padding: 40px 20px;
    border: 1px solid #2a3a51;
    border-radius: 18px;
    color: #aebbd0;
    background: #101a29;
    text-align: center;
}

body.light-theme .product-detail-route-state {
    border-color: #e1e6ee;
    color: #667085;
    background: #ffffff;
}

.product-detail-route-state > i {
    color: #2f8ff4;
    font-size: 2rem;
}

.product-detail-route-state strong {
    color: #eef4ff;
    font-size: 1.1rem;
}

body.light-theme .product-detail-route-state strong {
    color: #172033;
}

.product-detail-route-state button {
    min-height: 44px;
    margin-top: 4px;
    padding: 10px 16px;
    border: 0;
    border-radius: 10px;
    color: #ffffff;
    background: #2f7df6;
    font: inherit;
    font-weight: 800;
    cursor: pointer;
}

@keyframes productPageEnter {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 900px) {
    body[data-active-view="product-detail"] {
        padding-bottom: calc(112px + env(safe-area-inset-bottom)) !important;
    }

    #view-product-detail {
        padding: 8px 0 34px;
    }

    .product-detail-topbar {
        margin-bottom: 10px;
        padding: 0 2px;
    }

    .product-detail-topbar button {
        min-height: 40px;
        padding: 8px 11px;
    }

    .product-detail-topbar > span {
        max-width: 42%;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    body:not(.light-theme) #view-product-detail .product-detail-page.product-modal,
    body.light-theme #view-product-detail .product-detail-page.product-modal {
        max-height: none;
        border: 1px solid #2a3a51 !important;
        border-radius: 16px;
    }

    body.light-theme #view-product-detail .product-detail-page.product-modal {
        border-color: #e2e8f0 !important;
    }

    #view-product-detail .product-detail-page .pm-layout {
        overflow: visible;
    }

    #view-product-detail .product-detail-page .pm-footer {
        position: static;
    }

    .product-detail-route-state {
        min-height: 300px;
    }
}
