:root,
[data-theme="dark"] {
    --primary-color: #3b82f6;
    --primary-hover: #2563eb;
    --bg-dark: #0f172a;
    --card-bg: #1e293b;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --border-color: rgba(255, 255, 255, 0.08);
    --input-bg: #0f172a;
    --accent-bg: rgba(59, 130, 246, 0.15);
    --alert-danger-bg: rgba(239, 68, 68, 0.2);
    --alert-danger-text: #f87171;
    --alert-success-bg: rgba(34, 197, 94, 0.2);
    --alert-success-text: #4ade80;
    --btn-theme-bg: #334155;
    --btn-theme-text: #f8fafc;
}

[data-theme="light"] {
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --bg-dark: #f8fafc;
    --card-bg: #ffffff;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --border-color: #e2e8f0;
    --input-bg: #ffffff;
    --accent-bg: rgba(37, 99, 235, 0.08);
    --alert-danger-bg: #fee2e2;
    --alert-danger-text: #dc2626;
    --alert-success-bg: #dcfce7;
    --alert-success-text: #16a34a;
    --btn-theme-bg: #e2e8f0;
    --btn-theme-text: #0f172a;
}

/* Balik warna logo PNG jika dalam mode terang */
[data-theme="light"] .brand-logo img {
    filter: invert(1) brightness(0.2);
}

/* ==========================================
   Product Page Styles (Modern & Dark Theme)
   ========================================== */

/* Layout & Container */
.product-page-wrapper {
    width: 100%;
    max-width: 480px;
    /* Samakan dengan lebar profile.php */
    margin: 0 auto;
    background: #1e293b;
    /* Warna card-bg main.css */
    color: #f8fafc;
    min-height: 100vh;
    position: relative;
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
}

/* Top Nav Bar Overlay */
.modal-top-bar {
    position: absolute;
    top: 12px;
    left: 12px;
    right: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 10;
}

.top-bar-btn {
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(6px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #ffffff;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.1rem;
    transition: all 0.2s ease;
}

.top-bar-btn:hover {
    background: var(--user-primary, #3b82f6);
    color: #fff;
}

.top-bar-right {
    display: flex;
    gap: 8px;
}

.cart-btn-badge {
    position: relative;
}

.cart-count {
    position: absolute;
    top: -2px;
    right: -2px;
    background: var(--user-primary, #3b82f6);
    color: #fff;
    font-size: 0.65rem;
    font-weight: 700;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #0f172a;
}

/* Carousel Media Section */
.modal-media-section {
    position: relative;
    background: #0f172a;
    width: 100%;
    aspect-ratio: 1 / 1;
    overflow: hidden;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.modal-media-section .carousel-container {
    width: 100%;
    height: 100%;
}

.modal-media-section .carousel-slide {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: none;
}

.modal-media-section .carousel-slide.active {
    display: block;
}

.carousel-dots {
    position: absolute;
    bottom: 12px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 6px;
    z-index: 5;
    background: rgba(15, 23, 42, 0.5);
    padding: 4px 8px;
    border-radius: 12px;
    backdrop-filter: blur(4px);
}

.dot-item {
    width: 8px;
    height: 8px;
    background: rgba(255, 255, 255, 0.4);
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s ease;
}

.dot-item.active {
    background: var(--user-primary, #3b82f6);
    width: 16px;
    border-radius: 4px;
}

/* Styling tambahan untuk Carousel & Tombol Navigasi Kiri/Kanan */
.modal-media-section {
    position: relative;
}

.carousel-container {
    display: flex;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.carousel-container::-webkit-scrollbar {
    display: none;
}

.carousel-slide {
    flex: 0 0 100%;
    width: 100%;
    scroll-snap-align: start;
    object-fit: cover;
    display: block;
}

.carousel-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background-color: rgba(0, 0, 0, 0.6);
    color: #fff;
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 10;
    transition: background-color 0.2s, transform 0.2s;
}

.carousel-btn:hover {
    background-color: rgba(0, 0, 0, 0.8);
    transform: translateY(-50%) scale(1.05);
}

.carousel-prev {
    left: 12px;
}

.carousel-next {
    right: 12px;
}

/* Content & Body Details */
.modal-body-lynk {
    padding: 20px;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    background-color: var(--accent-bg);
}

.title-price-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 18px;
}

.modal-product-title {
    font-size: 1.2rem;
    font-weight: 700;
    color: #f8fafc;
    margin: 0;
    line-height: 1.35;
}

.price-container {
    text-align: right;
    white-space: nowrap;
}

.modal-price-current {
    font-size: 1.15rem;
    font-weight: 800;
    color: var(--user-primary, #3b82f6);
}

.desc-section {
    margin-bottom: 24px;
    background: rgba(15, 23, 42, 0.4);
    padding: 14px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.desc-label {
    display: block;
    font-size: 0.75rem;
    font-weight: 700;
    color: #94a3b8;
    margin-bottom: 8px;
    letter-spacing: 0.5px;
}

.modal-desc-text {
    font-size: 0.9rem;
    color: #cbd5e1;
    line-height: 1.6;
    margin: 0;
    white-space: pre-line;
}

/* Action Bar Bottom */
.modal-action-bar {
    display: flex;
    gap: 12px;
    margin-top: auto;
    padding-top: 15px;
}

.btn-cart {
    width: 48px;
    height: 48px;
    border: none;
    background: linear-gradient(135deg, #f59e0b, #d97706);
    /* Warna Amber/Gold standar profesional */
    color: #ffffff;
    border-radius: 10px;
    font-size: 1.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.3);
    /* Effect Glow kontras di latar gelap */
    transition: all 0.25 ease;
}

.btn-cart:hover {
    background: linear-gradient(135deg, #fbbf24, #f59e0b);
    color: #ffffff;
    box-shadow: 0 6px 16px rgba(245, 158, 11, 0.45);
    transform: translateY(-2px);
}

.btn-cart:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(245, 158, 11, 0.2);
}

.btn-outline-cart {
    width: 48px;
    height: 48px;
    border: 1.5px solid var(--user-primary, #3b82f6);
    background: transparent;
    color: var(--user-primary, #3b82f6);
    border-radius: 10px;
    font-size: 1.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: all 0.2s ease;
}

.btn-outline-cart:hover {
    background: rgba(59, 130, 246, 0.15);
}

.btn-buy-now {
    width: 100%;
    padding: 10px;
    flex: 1;
    height: 48px;
    background: var(--primary-hover);
    color: #ffffff;
    font-size: 1rem;
    font-weight: 700;
    border-radius: 10px;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.2s ease;
}

.btn-buy-now:hover {
    transform: translateY(-2px);
    background: #4b7eeb;
    color: #ffffff;
    box-shadow: 0 6px 16px var(--table-row-hover);
}

/* ==========================================
   Cart Modal & Item Styling (Improved Dark Theme)
   ========================================== */

.cart-modal-content {
    background: #182232 !important;
    color: #f8fafc !important;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 18px;
    padding: 22px;
    width: 100%;
    max-width: 420px !important;
    /* Sedikit lebih lebar agar fleksibel */
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6);
}

.cart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 14px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    margin-bottom: 16px;
}

.cart-header h3 {
    margin: 0;
    font-size: 1.15rem;
    font-weight: 700;
    color: #f8fafc !important;
    display: flex;
    align-items: center;
    gap: 8px;
}

.cart-close {
    font-size: 1.4rem;
    color: #94a3b8 !important;
    cursor: pointer;
    transition: color 0.2s ease;
    line-height: 1;
}

.cart-close:hover {
    color: #f8fafc !important;
}

/* Scrollable Container */
.cart-items-wrapper {
    overflow-y: auto;
    max-height: 280px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding-right: 4px;
    margin-bottom: 16px;
}

/* Item Card Layout */
.cart-item-card {
    background: #0f172a !important;
    border: 1px solid rgba(255, 255, 255, 0.08) !important;
    border-radius: 12px;
    padding: 12px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.cart-item-card img {
    width: 60px;
    height: 60px;
    object-fit: cover;
    border-radius: 8px;
    background: #1e293b;
    flex-shrink: 0;
}

.cart-item-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.cart-item-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 8px;
}

.cart-item-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: #f8fafc !important;
    margin: 0;
    line-height: 1.3;
}

.cart-item-remove-btn {
    background: transparent;
    border: none;
    color: #ef4444;
    font-size: 0.95rem;
    cursor: pointer;
    padding: 2px 4px;
    border-radius: 4px;
    transition: background 0.2s ease;
}

.cart-item-remove-btn:hover {
    background: rgba(239, 68, 68, 0.15);
}

.cart-item-bottom {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.cart-item-price {
    font-size: 0.88rem;
    font-weight: 700;
    color: var(--user-primary, #a855f7) !important;
}

/* Quantity Control Buttons */
.cart-qty-ctrl {
    display: flex;
    align-items: center;
    gap: 6px;
    background: #1e293b;
    padding: 3px 6px;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.cart-qty-ctrl button {
    background: rgba(255, 255, 255, 0.05) !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    color: #f8fafc !important;
    width: 22px;
    height: 22px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 0.8rem;
    transition: all 0.2s ease;
}

.cart-qty-ctrl button:hover {
    background: var(--user-primary, #a855f7) !important;
    border-color: var(--user-primary, #a855f7) !important;
}

.cart-qty-ctrl span {
    font-size: 0.82rem;
    font-weight: 700;
    min-width: 18px;
    text-align: center;
    color: #f8fafc;
}

/* Order Summary Section */
.cart-summary-section {
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    padding-top: 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.summary-title {
    font-size: 0.72rem;
    font-weight: 700;
    color: #94a3b8;
    letter-spacing: 0.5px;
}

.summary-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    color: #cbd5e1;
}

.summary-row.grand-total {
    font-size: 0.95rem;
    font-weight: 800;
    color: #f8fafc !important;
    margin-top: 2px;
    padding-top: 8px;
    border-top: 1px dashed rgba(255, 255, 255, 0.1);
}

.summary-row.grand-total strong {
    color: var(--user-primary, #a855f7) !important;
}

/* Action Group Buttons */
.cart-action-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 10px;
}

.btn-voucher {
    width: 100%;
    padding: 10px;
    background: rgba(168, 85, 247, 0.1) !important;
    border: 1px dashed var(--user-primary, #a855f7) !important;
    color: var(--user-primary, #a855f7) !important;
    border-radius: 10px;
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: all 0.2s ease;
}

.btn-voucher:hover {
    background: rgba(168, 85, 247, 0.2) !important;
}

.cart-buy-btn {
    width: 100%;
    height: 44px;
    border-radius: 10px;
}

.btn-continue-shopping {
    width: 100%;
    padding: 10px;
    background: transparent !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    color: #94a3b8 !important;
    border-radius: 10px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-continue-shopping:hover {
    color: #f8fafc !important;
    border-color: rgba(255, 255, 255, 0.2) !important;
}

/* ==========================================================================
   PENYESUAIAN SKALA & MODAL CART DI DALAM IFRAME MOCKUP PREVIEW
   ========================================================================== */
body.is-iframe {
    zoom: 46% !important;
    /* Menurunkan skala dari 58% ke 46% agar pas di bingkai mockup */
    -moz-transform: scale(0.60) !important;
    -moz-transform-origin: top center !important;
}

/* 1. Mencegah Wrapper Halaman Meluap */
body.is-iframe .product-page-wrapper {
    min-height: auto !important;
    box-shadow: none !important;
    border-radius: 0 !important;
    max-width: 100% !important;
}

/* 2. Mengatur Modal Keranjang Belanja (cart.php) Agar Pas di Mockup */
body.is-iframe #cartModal {
    position: absolute !important;
    /* Mengubah fixed ke absolute agar terkunci di iframe */
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    padding: 10px !important;
    box-sizing: border-box !important;
}

body.is-iframe .cart-modal-content {
    max-width: 100% !important;
    max-height: 90vh !important;
    padding: 14px !important;
}

/* 3. Menyesuaikan Ukuran Teks & Tombol Detail Produk (product_detail.php) */
body.is-iframe .modal-product-title {
    font-size: 1.05rem !important;
}

body.is-iframe .modal-price-current {
    font-size: 1rem !important;
}

body.is-iframe .modal-desc-text {
    font-size: 0.8rem !important;
}

body.is-iframe .btn-buy-now {
    height: 40px !important;
    font-size: 0.85rem !important;
}

body.is-iframe .btn-cart {
    width: 40px !important;
    height: 40px !important;
    font-size: 1rem !important;
}

/* ==========================================
   Checkout Page Styles (Matching Cart & Product)
   ========================================== */

.checkout-wrapper {
    width: 100%;
    max-width: 480px;
    margin: 0 auto;
    background: #1e293b;
    color: #f8fafc;
    min-height: 100vh;
    padding: 16px;
    box-sizing: border-box;
}

.checkout-header-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding-bottom: 14px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    margin-bottom: 20px;
}

.checkout-title-text {
    margin: 0;
    font-size: 1.15rem;
    font-weight: 700;
    color: #f8fafc;
}

.checkout-content-grid {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.checkout-card-box {
    background: #0f172a;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 16px;
}

.card-title-text {
    font-size: 0.72rem;
    font-weight: 700;
    color: #94a3b8;
    text-transform: uppercase;
    margin-bottom: 14px;
    letter-spacing: 0.5px;
}

.checkout-products-wrapper {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.checkout-item-total {
    font-weight: 700;
    font-size: 0.88rem;
    color: #f8fafc;
    white-space: nowrap;
}

/* Form inputs */
.form-group-field {
    margin-bottom: 12px;
}

.form-group-field label {
    display: block;
    font-size: 0.8rem;
    margin-bottom: 6px;
    color: #94a3b8;
}

.form-group-field label span {
    color: #ef4444;
}

.form-control-input {
    width: 100%;
    padding: 10px 12px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: #1e293b;
    color: #f8fafc;
    font-size: 0.85rem;
    box-sizing: border-box;
    transition: border-color 0.2s ease;
}

.form-control-input:focus {
    outline: none;
    border-color: var(--primary-color, #3b82f6);
}

.checkout-action-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.payment-select-btn {
    display: flex;
    align-items: center;
    justify-content: space-between;
    text-align: left;
}

.terms-checkbox-group {
    font-size: 0.75rem;
    color: #94a3b8;
    display: flex;
    gap: 8px;
    align-items: flex-start;
    margin: 4px 0 6px 0;
}

.terms-checkbox-group input {
    margin-top: 2px;
}

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 15px;
}

.payment-group-title {
    font-size: 0.75rem;
    color: #94a3b8;
    font-weight: bold;
    margin-bottom: 8px;
}

.payment-option-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: #0f172a;
    border-radius: 8px;
    margin-bottom: 8px;
    cursor: pointer;
    font-size: 0.88rem;
    transition: all 0.2s ease;
}

.payment-option-card:hover {
    border-color: var(--primary-color, #3b82f6);
    background: var(--accent-bg, rgba(59, 130, 246, 0.15));
}

.timer-box {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #f87171;
    text-align: center;
    padding: 10px;
    border-radius: 8px;
    font-weight: bold;
    margin-bottom: 15px;
    font-size: 0.85rem;
}