/**
 * MS Freshora — Product Detail Page (presentation only)
 * All class/ID names preserved for JS/backend hooks.
 */

:root {
    --pd-green: #16a34a;
    --pd-green-dark: #15803d;
    --pd-ink: #111827;
    --pd-muted: #64748b;
    --pd-border: #e2e8f0;
    --pd-surface: #ffffff;
    --pd-soft: #f8fafc;
    --pd-radius: 14px;
    --pd-radius-lg: 20px;
    --pd-touch: 44px;
    --pd-shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
}

/* ─── Page ─── */
.product-detail-page {
    background: linear-gradient(180deg, #f6faf7 0%, #f8fafc 50%, #f1f5f3 100%);
    min-height: 100vh;
    padding: 20px 0 64px;
}

.product-detail-wrap {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 16px;
}

/* ─── Breadcrumb ─── */
.breadcrumb-row {
    margin-bottom: 14px;
    color: var(--pd-muted);
    font-size: 12px;
    font-weight: 700;
    line-height: 1.5;
}

.breadcrumb-row a {
    color: var(--pd-green);
    text-decoration: none;
    font-weight: 800;
}

.breadcrumb-row a:hover {
    color: var(--pd-green-dark);
    text-decoration: underline;
}

.breadcrumb-row a:focus-visible {
    outline: 2px solid var(--pd-green);
    outline-offset: 2px;
    border-radius: 4px;
}

/* ─── Main layout ─── */
.detail-card {
    background: var(--pd-surface);
    border: 1px solid #e8f0ea;
    border-radius: var(--pd-radius-lg);
    box-shadow: var(--pd-shadow);
    padding: 20px;
    display: grid;
    grid-template-columns: minmax(280px, 0.95fr) minmax(0, 1.05fr);
    gap: 24px;
    align-items: start;
}

/* ─── Image panel ─── */
.image-panel {
    background: var(--pd-soft);
    border: 1px solid var(--pd-border);
    border-radius: var(--pd-radius-lg);
    padding: 16px;
    position: sticky;
    top: 88px;
}

.main-image-box {
    width: 100%;
    height: min(420px, 52vh);
    min-height: 260px;
    border-radius: var(--pd-radius);
    background: #fff;
    border: 1px solid var(--pd-border);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
}

.main-image-box img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    padding: 16px;
    transition: transform 0.2s ease;
}

.main-image-box:hover img {
    transform: scale(1.03);
}

.floating-badge {
    position: absolute;
    top: 12px;
    left: 12px;
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 6px 10px;
    font-size: 11px;
    font-weight: 800;
    background: #ecfdf5;
    border: 1px solid #bbf7d0;
    color: #15803d;
    letter-spacing: 0.02em;
}

.floating-badge.loose {
    background: #fff7ed;
    border-color: #fed7aa;
    color: #9a3412;
}

.image-note {
    margin-top: 12px;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
}

.image-note-box {
    background: #fff;
    border: 1px solid var(--pd-border);
    border-radius: var(--pd-radius);
    padding: 10px 12px;
    font-size: 11px;
    color: var(--pd-muted);
    font-weight: 600;
    line-height: 1.45;
}

.image-note-box strong {
    display: block;
    color: var(--pd-ink);
    font-size: 12px;
    font-weight: 800;
    margin-bottom: 2px;
}

/* ─── Info panel — flex + order for mobile-friendly hierarchy ─── */
.info-panel {
    padding: 0;
    display: flex;
    flex-direction: column;
}

.category-pill {
    display: inline-flex;
    background: #ecfdf5;
    border: 1px solid #bbf7d0;
    color: #15803d;
    border-radius: 999px;
    padding: 6px 12px;
    font-size: 11px;
    font-weight: 800;
    margin-bottom: 10px;
    order: 0;
    width: fit-content;
}

.product-title {
    font-size: clamp(22px, 3.5vw, 32px);
    font-weight: 800;
    color: var(--pd-ink);
    margin: 0 0 10px;
    letter-spacing: -0.04em;
    line-height: 1.2;
    order: 1;
}

.product-short-line {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 14px;
    order: 2;
}

.product-chip {
    display: inline-flex;
    background: var(--pd-soft);
    border: 1px solid var(--pd-border);
    color: #475569;
    border-radius: 999px;
    padding: 6px 10px;
    font-size: 11px;
    font-weight: 700;
}

.product-chip.success {
    background: #ecfdf5;
    border-color: #bbf7d0;
    color: #15803d;
}

.product-chip.warning {
    background: #fff7ed;
    border-color: #fed7aa;
    color: #9a3412;
}

/* ─── Price ─── */
.price-card {
    background: linear-gradient(135deg, #f0fdf4 0%, #fff 100%);
    border: 1px solid #bbf7d0;
    border-radius: var(--pd-radius-lg);
    padding: 16px 18px;
    margin-bottom: 14px;
    order: 3;
}

.price-row {
    display: flex;
    align-items: baseline;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 4px;
}

.sell-price {
    color: var(--pd-green);
    font-size: clamp(28px, 4vw, 36px);
    font-weight: 900;
    line-height: 1;
    letter-spacing: -0.03em;
}

.old-price {
    color: #94a3b8;
    font-size: 16px;
    text-decoration: line-through;
    font-weight: 700;
}

.deal-save {
    background: #fef3c7;
    border: 1px solid #fde68a;
    color: #92400e;
    border-radius: 999px;
    padding: 5px 10px;
    font-size: 11px;
    font-weight: 800;
}

.price-unit {
    color: var(--pd-muted);
    font-size: 13px;
    font-weight: 600;
}

.description-box {
    color: #475569;
    font-size: 14px;
    font-weight: 500;
    line-height: 1.7;
    margin-bottom: 14px;
    order: 7;
    padding-top: 4px;
    border-top: 1px solid var(--pd-border);
}

/* ─── Stock ─── */
.stock-box {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    border-radius: var(--pd-radius);
    padding: 12px 14px;
    margin-bottom: 14px;
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    color: #15803d;
    order: 4;
}

.stock-box.low {
    background: #fffbeb;
    border-color: #fde68a;
    color: #b45309;
}

.stock-box.out {
    background: #fef2f2;
    border-color: #fecaca;
    color: #dc2626;
}

.stock-icon {
    width: 36px;
    height: 36px;
    min-width: 36px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 14px;
    flex: 0 0 auto;
}

.stock-box strong {
    display: block;
    font-size: 13px;
    font-weight: 800;
    margin-bottom: 2px;
}

.stock-box span {
    display: block;
    font-size: 12px;
    font-weight: 600;
    line-height: 1.45;
}

/* ─── Purchase / quantity ─── */
.purchase-card {
    background: var(--pd-surface);
    border: 1px solid var(--pd-border);
    border-radius: var(--pd-radius-lg);
    padding: 16px;
    margin-bottom: 14px;
    box-shadow: var(--pd-shadow);
    order: 5;
}

.purchase-title {
    font-size: 13px;
    color: var(--pd-ink);
    font-weight: 800;
    margin-bottom: 12px;
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

.qty-area {
    display: grid;
    grid-template-columns: var(--pd-touch) 1fr var(--pd-touch);
    gap: 8px;
    margin-bottom: 10px;
}

.qty-btn {
    min-height: var(--pd-touch);
    height: var(--pd-touch);
    border: 1px solid var(--pd-green);
    background: #f0fdf4;
    color: #15803d;
    border-radius: 12px;
    font-size: 20px;
    font-weight: 800;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}

.qty-btn:hover:not(:disabled) {
    background: var(--pd-green);
    color: #fff;
}

.qty-btn:focus-visible {
    outline: 2px solid var(--pd-green);
    outline-offset: 2px;
}

.qty-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    background: var(--pd-soft);
    color: #94a3b8;
    border-color: var(--pd-border);
}

.qty-input {
    height: var(--pd-touch);
    min-height: var(--pd-touch);
    border: 1px solid var(--pd-border);
    border-radius: 12px;
    text-align: center;
    color: var(--pd-ink);
    font-size: 16px;
    font-weight: 800;
    outline: none;
    width: 100%;
    background: #fff;
}

.qty-input:focus-visible {
    outline: 2px solid var(--pd-green);
    outline-offset: 1px;
}

.qty-input::-webkit-outer-spin-button,
.qty-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.selected-row {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
    background: var(--pd-soft);
    border: 1px solid var(--pd-border);
    border-radius: 12px;
    padding: 10px 12px;
    margin-bottom: 10px;
    color: #475569;
    font-size: 13px;
    font-weight: 600;
}

.selected-row strong {
    color: var(--pd-ink);
    font-weight: 800;
}

.action-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.add-cart-btn,
.go-cart-btn,
.disabled-btn {
    width: 100%;
    min-height: 48px;
    border-radius: 12px;
    padding: 12px 16px;
    font-size: 14px;
    font-weight: 800;
    text-decoration: none;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s ease, transform 0.15s ease;
    text-align: center;
    line-height: 1.25;
}

.add-cart-btn {
    border: none;
    background: var(--pd-green);
    color: #fff;
    box-shadow: 0 8px 20px rgba(22, 163, 74, 0.25);
    cursor: pointer;
}

.add-cart-btn:hover {
    background: var(--pd-green-dark);
    transform: translateY(-1px);
}

.add-cart-btn:focus-visible {
    outline: 2px solid var(--pd-green);
    outline-offset: 2px;
}

.go-cart-btn {
    border: 1px solid var(--pd-ink);
    background: var(--pd-ink);
    color: #fff;
}

.go-cart-btn:hover {
    background: #020617;
    color: #fff;
    transform: translateY(-1px);
}

.go-cart-btn:focus-visible {
    outline: 2px solid var(--pd-ink);
    outline-offset: 2px;
}

.disabled-btn {
    border: none;
    background: #dc2626;
    color: #fff;
    cursor: not-allowed;
    opacity: 0.85;
    width: 100%;
}

/* ─── Product details grid ─── */
.details-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-top: 4px;
    order: 6;
}

.detail-mini-card {
    background: var(--pd-soft);
    border: 1px solid var(--pd-border);
    border-radius: var(--pd-radius);
    padding: 12px;
}

.detail-mini-card span {
    display: block;
    color: var(--pd-muted);
    font-size: 10px;
    font-weight: 700;
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.detail-mini-card strong {
    display: block;
    color: var(--pd-ink);
    font-size: 13px;
    font-weight: 800;
    line-height: 1.4;
}

/* ─── Trust strip ─── */
.trust-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-top: 20px;
}

.trust-box {
    background: var(--pd-surface);
    border: 1px solid var(--pd-border);
    border-radius: var(--pd-radius);
    padding: 14px;
    box-shadow: var(--pd-shadow);
}

.trust-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: #ecfdf5;
    color: var(--pd-green);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    margin-bottom: 8px;
    font-size: 16px;
}

.trust-box strong {
    display: block;
    color: var(--pd-ink);
    font-size: 13px;
    font-weight: 800;
    margin-bottom: 4px;
}

.trust-box span {
    color: var(--pd-muted);
    font-size: 11px;
    font-weight: 600;
    line-height: 1.45;
}

/* ─── Related products ─── */
.related-section {
    margin-top: 24px;
    background: var(--pd-surface);
    border: 1px solid var(--pd-border);
    border-radius: var(--pd-radius-lg);
    padding: 20px;
    box-shadow: var(--pd-shadow);
}

.related-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 14px;
    margin-bottom: 16px;
}

.related-kicker {
    display: inline-flex;
    background: #fff7ed;
    border: 1px solid #fed7aa;
    color: #9a3412;
    border-radius: 999px;
    padding: 5px 10px;
    font-size: 11px;
    font-weight: 800;
    margin-bottom: 6px;
}

.related-title {
    color: var(--pd-ink);
    font-size: clamp(18px, 2.5vw, 22px);
    font-weight: 800;
    margin: 0;
    letter-spacing: -0.03em;
    line-height: 1.25;
}

.related-subtitle {
    color: var(--pd-muted);
    font-size: 12px;
    font-weight: 600;
    margin: 6px 0 0;
    line-height: 1.5;
}

.related-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
}

.related-card {
    background: #fff;
    border: 1px solid var(--pd-border);
    border-radius: var(--pd-radius-lg);
    padding: 12px;
    text-decoration: none;
    color: inherit;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.related-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 28px rgba(15, 23, 42, 0.08);
    border-color: #bbf7d0;
}

.related-card:focus-visible {
    outline: 2px solid var(--pd-green);
    outline-offset: 2px;
}

.related-img {
    height: 120px;
    border-radius: var(--pd-radius);
    background: var(--pd-soft);
    border: 1px solid var(--pd-border);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    margin-bottom: 10px;
}

.related-img img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    padding: 8px;
    transition: transform 0.2s ease;
}

.related-card:hover .related-img img {
    transform: scale(1.03);
}

.related-tag {
    position: absolute;
    top: 18px;
    left: 18px;
    background: #ecfdf5;
    border: 1px solid #bbf7d0;
    color: #15803d;
    border-radius: 999px;
    padding: 4px 8px;
    font-size: 10px;
    font-weight: 800;
    z-index: 2;
}

.related-name {
    color: var(--pd-ink);
    font-size: 13px;
    font-weight: 800;
    line-height: 1.35;
    margin-bottom: 4px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    min-height: 35px;
}

.related-meta {
    color: var(--pd-muted);
    font-size: 11px;
    font-weight: 600;
    margin-bottom: 8px;
}

.related-price-row {
    display: flex;
    align-items: baseline;
    gap: 6px;
    flex-wrap: wrap;
    margin-bottom: 10px;
}

.related-price {
    color: var(--pd-green);
    font-size: 16px;
    font-weight: 900;
}

.related-old-price {
    color: #94a3b8;
    font-size: 12px;
    text-decoration: line-through;
    font-weight: 600;
}

.related-view-btn {
    min-height: 40px;
    border-radius: 10px;
    background: var(--pd-green);
    border: none;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 800;
    margin-top: auto;
    transition: background 0.15s ease;
}

.related-card:hover .related-view-btn {
    background: var(--pd-green-dark);
}

/* ─── Responsive ─── */
@media (max-width: 1024px) {
    .related-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (max-width: 950px) {
    .detail-card {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .image-panel {
        position: static;
    }

    .main-image-box {
        height: min(340px, 45vh);
        min-height: 240px;
    }

    .trust-grid {
        grid-template-columns: 1fr;
    }

    .related-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 768px) {
    .product-detail-page {
        padding: 12px 0 72px;
    }

    .product-detail-wrap {
        padding: 0 12px;
    }

    .detail-card {
        padding: 14px;
    }

    .action-row {
        grid-template-columns: 1fr;
    }

    .add-cart-btn {
        min-height: 52px;
        font-size: 15px;
    }

    /* Related: horizontal rail */
    .related-grid {
        display: flex;
        flex-wrap: nowrap;
        overflow-x: auto;
        gap: 10px;
        padding-bottom: 6px;
        scroll-snap-type: x proximity;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }

    .related-grid::-webkit-scrollbar {
        display: none;
    }

    .related-card {
        flex: 0 0 calc(50% - 5px);
        min-width: 160px;
        max-width: 220px;
        scroll-snap-align: start;
    }
}

@media (max-width: 620px) {
    .main-image-box {
        height: min(280px, 42vh);
        min-height: 220px;
    }

    .product-title {
        font-size: 22px;
    }

    .sell-price {
        font-size: 28px;
    }

    .image-note,
    .details-grid {
        grid-template-columns: 1fr;
    }

    .selected-row {
        align-items: flex-start;
        flex-direction: column;
        gap: 4px;
    }

    .related-section {
        padding: 14px;
    }

    .related-head {
        display: block;
    }

    .related-img {
        height: 100px;
    }
}

@media (max-width: 430px) {
    .qty-area {
        grid-template-columns: 40px 1fr 40px;
    }

    .qty-btn,
    .qty-input {
        min-height: 42px;
        height: 42px;
    }

    .related-card {
        flex: 0 0 46%;
        min-width: 148px;
    }
}

@media (min-width: 1440px) {
    .product-detail-wrap {
        max-width: 1280px;
    }

    .related-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

@media (min-width: 1600px) {
    .product-detail-wrap {
        max-width: 1320px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .main-image-box img,
    .related-img img,
    .related-card,
    .add-cart-btn,
    .go-cart-btn {
        transition: none;
    }

    .related-card:hover,
    .add-cart-btn:hover,
    .go-cart-btn:hover {
        transform: none;
    }
}
