/* Main Button - relying on theme classes as requested */
/* #kt-open-configurator {
    width: 100%; 
    margin-bottom: 20px; 
} */

/* Modal Overlay */
#kt-popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    z-index: 99999;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    animation: ktFadeIn 0.3s forwards;
}

@keyframes ktFadeIn {
    to {
        opacity: 1;
    }
}

/* Modal Content */
#kt-popup-content {
    background: #fff;
    width: 90%;
    max-width: 900px;
    max-height: 90vh;
    border-radius: 12px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.2);
    overflow-y: auto;
    position: relative;
    padding: 30px;
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

#kt-close-popup {
    position: absolute;
    top: 15px;
    right: 15px;
    background: transparent;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #888;
}

.kt-step h2 {
    font-size: 24px;
    margin-bottom: 25px;
    text-align: center;
    color: #333;
}

/* Grid for Step 1 */
.kt-fabrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 20px;
}

.kt-fabric-card {
    border: 1px solid #eee;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.kt-fabric-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.05);
}

.kt-fabric-card img {
    width: 100%;
    aspect-ratio: 1 / 1;
    object-fit: cover;
    display: block;
}

.kt-fabric-card h3 {
    padding: 15px;
    margin: 0;
    font-size: 16px;
    text-align: center;
    color: #444;
}

/* Step 2 Layout */
.kt-fabric-details {
    display: flex;
    gap: 30px;
    flex-wrap: wrap;
    align-items: flex-start;
    /* Essential to keep image container tight to image height */
}

.kt-selected-fabric-image {
    flex: 1;
    min-width: 300px;
    /* position: relative;  Removed, wrapper handles it now */
}

.kt-image-wrapper {
    position: relative;
    width: 100%;
    margin-bottom: 10px;
}

.kt-image-wrapper img {
    width: 100%;
    border-radius: 8px;
    object-fit: cover;
    aspect-ratio: 1/1;
    display: block;
}

#kt-preview-label {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(255, 255, 255, 0.9);
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    color: #333;
    pointer-events: none;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
    white-space: nowrap;
}

.kt-selected-fabric-info {
    flex: 1;
    min-width: 300px;
}

#kt-fabric-features {
    margin-bottom: 20px;
}

.kt-feature-item {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
    color: #555;
    font-size: 13px;
}

.kt-feature-item svg {
    width: 20px;
    height: 20px;
    color: #4CAF50;
    /* Green check */
}

.kt-price-info {
    font-size: 18px;
    font-weight: bold;
    margin-bottom: 20px;
    color: #222;
}

/* Variants Grid */
.kt-variants-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    /* Increased min size for labels */
    gap: 15px;
    margin-bottom: 30px;
}

.kt-variant-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
}

.kt-variant-item {
    width: 100%;
    border: 2px solid transparent;
    border-radius: 8px;
    overflow: hidden;
    aspect-ratio: 1/1;
    margin-bottom: 5px;
    transition: border-color 0.2s;
}

.kt-variant-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.kt-variant-item.active {
    border-color: #222;
    box-shadow: 0 0 0 2px #fff inset;
}

.kt-variant-name {
    font-size: 13px;
    text-align: center;
    color: #555;
    line-height: 1.2;
}

#kt-confirm-selection {
    width: 100%;
    padding: 15px;
    background: #000;
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 16px;
    cursor: pointer;
    transition: background 0.2s;
}

#kt-confirm-selection:disabled {
    background: #ccc;
    cursor: not-allowed;
}

#kt-confirm-selection:hover:not(:disabled) {
    background: #333;
}

#kt-back-to-step-1 {
    background: none;
    border: none;
    padding: 0;
    margin-bottom: 15px;
    cursor: pointer;
    color: #666;
    font-size: 14px;
}

#kt-back-to-step-1:hover {
    text-decoration: underline;
}

/* Responsiveness */
@media (max-width: 768px) {
    .kt-fabric-details {
        flex-direction: column;
    }
}

/* Step 3 Config Grid */
.kt-config-section {
    margin-bottom: 30px;
}

.kt-config-section h3 {
    margin-bottom: 15px;
    font-size: 18px;
    color: #333;
}

.kt-config-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 15px;
}

.kt-config-item {
    border: 1px solid #eee;
    border-radius: 8px;
    padding: 10px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
}

.kt-config-item:hover {
    transform: translateY(-3px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.05);
}

.kt-config-item.active {
    border-color: #000;
    box-shadow: 0 0 0 1px #000;
    background: #f9f9f9;
}

.kt-config-img-wrapper {
    width: 100%;
    padding-top: 100%;
    /* Force 1:1 aspect ratio robustly */
    position: relative;
    margin-bottom: 10px;
    overflow: hidden;
    border-radius: 4px;
    background: #fff;
}

.kt-config-img-wrapper img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    /* Ensure full image is visible without cropping */
}

.kt-config-item span {
    font-size: 14px;
    font-weight: 500;
    color: #444;
}

#kt-confirm-final {
    width: 100%;
    padding: 15px;
    background: #000;
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 16px;
    cursor: pointer;
    transition: background 0.2s;
    margin-top: 20px;
}

#kt-confirm-final:disabled {
    background: #ccc;
    cursor: not-allowed;
}

#kt-confirm-final:hover:not(:disabled) {
    background: #333;
}

#kt-back-to-step-2 {
    background: none;
    border: none;
    padding: 0;
    margin-bottom: 15px;
    cursor: pointer;
    color: #666;
    font-size: 14px;
}