/**
 * MKK Professional v4.0 - Layered Preview & Sticky Layout
 */

/* Hoved-layout: 2 kolonner */
.mkk-ultimate-wrapper {
    display: flex;
    flex-wrap: wrap;
    gap: 30px;
    margin-bottom: 40px;
    background: #ffffff;
    border: 1px solid #e2e4e7;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0,0,0,0.06);
}

/* --- KOLONNE 1: PREVIEW (Venstre) --- */
.mkk-preview-column {
    flex: 1;
    min-width: 320px;
    background: #f8f9fa;
    position: relative;
    padding: 20px;
    display: flex;
    align-items: flex-start; /* Gør det muligt for sticky at virke */
    justify-content: center;
}

/* Sticky Container: Holder koppen fast ved scroll */
.mkk-layer-stack {
    position: sticky;
    top: 30px; /* Afstand fra toppen af browseren når man scroller */
    width: 100%;
    max-width: 500px;
    aspect-ratio: 1/1;
    margin: 0 auto;
}

/* Lagene i stakken */
.mkk-layer-stack img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    transition: opacity 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none; /* Lagene skal ikke blokere for musen */
}

/* Bund-laget (Selve produktet) */
.mkk-layer-stack img.mkk-base-layer {
    position: relative;
    z-index: 1;
    opacity: 1 !important;
}

/* Dynamiske PNG lag (Glasur, figurer, tekst) */
.mkk-dynamic-layer {
    z-index: 10;
}

/* --- KOLONNE 2: FELTER (Højre) --- */
.mkk-fields-column {
    flex: 1.2;
    min-width: 320px;
    padding: 30px;
    border-left: 1px solid #f0f0f1;
    background: #fff;
}

.mkk-title {
    font-size: 1.6rem;
    font-weight: 800;
    margin-top: 0;
    margin-bottom: 25px;
    padding-bottom: 15px;
    border-bottom: 2px solid #f0f0f1;
}

/* Felt-grupper */
.mkk-field-group {
    margin-bottom: 28px;
}

.mkk-label {
    display: block;
    font-weight: 700;
    margin-bottom: 12px;
    font-size: 1rem;
    color: #1d2327;
}

.mkk-label .required {
    color: #d63638;
    margin-left: 4px;
}

/* Image Swatches */
.mkk-swatches-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(85px, 1fr));
    gap: 12px;
}

.mkk-swatch-item {
    cursor: pointer;
    border: 2px solid #e2e4e7;
    border-radius: 10px;
    padding: 8px;
    background: #fff;
    transition: all 0.2s ease;
    text-align: center;
}

.mkk-swatch-item:hover {
    border-color: #8c8f94;
    transform: translateY(-2px);
}

.mkk-swatch-item.active {
    background-color: #f0f7ff;
    /* Farve på border styres dynamisk af PHP inline CSS */
}

.mkk-swatch-item img {
    width: 100%;
    aspect-ratio: 1/1;
    object-fit: cover;
    border-radius: 6px;
    margin-bottom: 8px;
}

.mkk-swatch-name {
    font-size: 11px;
    font-weight: 600;
    line-height: 1.3;
    color: #2c3338;
}

/* --- PRIS & KNAP --- */
.mkk-total-price-display {
    margin-top: 30px;
    padding-top: 25px;
    border-top: 3px solid #f0f0f1;
    font-size: 1.2rem;
    font-weight: 800;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* --- FEJL & VALIDERING --- */
.mkk-field-error {
    animation: mkkShake 0.4s ease-in-out;
}

.mkk-error-msg {
    color: #d63638;
    font-size: 0.85rem;
    margin-top: 8px;
    display: none;
    font-weight: 600;
}

@keyframes mkkShake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-6px); }
    75% { transform: translateX(6px); }
}

/* --- RESPONSIVITET --- */
@media (max-width: 991px) {
    .mkk-preview-column {
        min-height: 350px;
    }
}

@media (max-width: 768px) {
    .mkk-ultimate-wrapper {
        flex-direction: column;
    }
    
    .mkk-preview-column {
        border-bottom: 1px solid #f0f0f1;
        min-height: auto;
    }
    
    .mkk-fields-column {
        border-left: none;
    }
    
    .mkk-layer-stack {
        position: relative;
        top: 0;
        max-width: 400px;
    }
}

/* Styling til swatches UDEN billede */
.mkk-swatch-item.no-image {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 50px; /* Giver den lidt højde så den ligner en knap */
    padding: 10px;
    background-color: #f9f9f9;
}

.mkk-swatch-item.no-image .mkk-swatch-info {
    margin-top: 0; /* Fjerner top-margin da der ikke er et billede over */
    width: 100%;
}

/* Sørg for at billeder i swatches ikke fylder for meget */
.mkk-swatch-item img {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 0 auto 8px;
}

.mkk-summary-box {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 15px;
    margin-top: 20px;
    border-left: 4px solid #2271b1; /* Din brand-farve */
}

.mkk-summary-box h4 {
    margin: 0 0 10px 0;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #666;
}

.mkk-summary-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.mkk-summary-list li {
    font-size: 0.95rem;
    padding: 4px 0;
    display: flex;
    justify-content: space-between;
    border-bottom: 1px dashed #ddd;
}

.mkk-summary-list li:last-child {
    border-bottom: none;
}

.mkk-summary-list li span {
    font-weight: bold;
}

/* Styling til rabatter (negative tal) */
.mkk-price-tag.discount {
    color: #46b450; /* Grøn farve til rabat */
}

.mkk-summary-list li span.discount-val {
    color: #46b450;
}

/* Input & Select Styling */
.mkk-select, .mkk-input-text {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #e2e4e7;
    border-radius: 10px;
    font-size: 1rem;
    color: #1d2327;
    background-color: #fff;
    transition: border-color 0.2s ease;
    box-sizing: border-box;
}

.mkk-select:focus, .mkk-input-text:focus {
    outline: none;
    border-color: #2271b1; /* Din brand farve */
}

/* Små prisskilte under tekstfelter */
.mkk-text-price-hint {
    display: block;
    margin-top: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    color: #646970;
}

/* Sikrer bløde animationer */
.mkk-field-group {
    overflow: hidden; /* Forhindrer tekst i at hoppe under slide animation */
}

/* Gør opsummerings-boksen blødere når den fader ind */
.mkk-summary-box {
    transition: opacity 0.4s ease, transform 0.4s ease;
}

/* Købsknap kontrol */
button.single_add_to_cart_button.disabled {
    cursor: not-allowed;
    filter: grayscale(0.5);
    transition: all 0.3s ease;
}

.mkk-total-price-display span {
    color: #2271b1; /* Din accent farve */
    font-size: 1.6rem;
    letter-spacing: -1px;
}

/* Gør valgte swatches ekstra tydelige med en lille skygge og løft */
.mkk-swatch-item.active { 
    border-color: ' . esc_attr($primary_color) . ' !important; 
    box-shadow: 0 0 10px rgba(0,0,0,0.1);
    transform: translateY(-2px);
}

/* Gør det tydeligt at man kan klikke (hover) */
.mkk-swatch-item:hover {
    border-color: #aaa;
}

/* --- KASSE & KURV GRID FIX (Blocksy Overwrite) --- */

/* 1. Nulstil containeren - vi tvinger den til at stable vertikalt */
.shop_table .variation, 
.woocommerce-cart-form dl.variation,
.woocommerce-checkout-review-order-table dl.variation {
    display: flex !important;
    flex-direction: column !important;
    gap: 5px !important;
    border: none !important;
}

/* 2. Nulstil Label (dt) - stopper Blocksy fra at tvinge dem til venstre-kolonne */
.shop_table .variation dt, 
dl.variation dt {
    display: block !important;
    float: none !important;
    width: 100% !important;
    margin: 0 !important;
    padding: 5px 0 0 0 !important;
    text-align: left !important;
    font-weight: 700 !important;
    font-size: 0.9em !important;
    color: #1d2327 !important;
}

/* 3. Nulstil Værdien (dd) - stopper Blocksy fra at tvinge dem til højre-kolonne */
.shop_table .variation dd, 
dl.variation dd {
    display: block !important;
    float: none !important;
    width: 100% !important;
    margin: 0 !important;
    padding: 0 0 10px 0 !important; /* Giver luft ned til næste punkt */
    text-align: left !important;
    margin-inline-start: 0 !important;
    color: #666 !important;
}

/* 4. Fjern eventuelle p-tags indeni dd, som Blocksy nogle gange bruger til styling */
.shop_table .variation dd p, 
dl.variation dd p {
    margin: 0 !important;
    padding: 0 !important;
    display: inline !important;
}