/* Frontend CSS for Mix and Match Embed Plugin */

.mame-embed {
    max-width: 100%;
    margin: 20px 0;
    font-family: inherit;
    color: inherit;
}

.mame-embed-title {
    font-size: 1.5em;
    margin-bottom: 20px;
    font-weight: bold;
    color: inherit;
}

.mame-embed-container {
    display: flex;
    gap: 20px;
    align-items: flex-start;
}

.mame-image-container {
    flex: 1;
    max-width: 50%;
    position: relative;
}

.mame-product-image {
    width: 100%;
    height: auto;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    transition: opacity 0.3s ease;
}

.mame-image-fade {
    opacity: 0;
}

.mame-controls {
    flex: 1;
    max-width: 50%;
}

.mame-category {
    margin-bottom: 25px;
}

.mame-category-title {
    font-size: 1.1em;
    font-weight: bold;
    margin-bottom: 12px;
    color: inherit;
}

.mame-variations {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.mame-variation-option {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: 6px;
    transition: background-color 0.2s ease;
    cursor: pointer;
}

.mame-variation-option:hover {
    background-color: rgba(0,0,0,0.05);
}

.mame-variation-option.disabled {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
}

.mame-variation-option input[type="radio"] {
    margin: 0;
    accent-color: currentColor;
}

.mame-variation-label {
    cursor: pointer;
    user-select: none;
}

/* Accordion styles for mobile and overflow cases */
.mame-accordion {
    border: 1px solid rgba(0,0,0,0.1);
    border-radius: 8px;
    overflow: hidden;
}

.mame-accordion-header {
    background: rgba(0,0,0,0.05);
    padding: 15px;
    cursor: pointer;
    font-weight: bold;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(0,0,0,0.1);
    transition: background-color 0.2s ease;
}

.mame-accordion-header:hover {
    background: rgba(0,0,0,0.08);
}

.mame-accordion-header.active {
    background: rgba(0,0,0,0.1);
}

.mame-accordion-content {
    padding: 15px;
    display: none;
}

.mame-accordion-content.active {
    display: block;
}

.mame-accordion-icon {
    transition: transform 0.2s ease;
}

.mame-accordion-header.active .mame-accordion-icon {
    transform: rotate(180deg);
}

/* Mobile responsive design */
@media (max-width: 768px) {
    .mame-embed-container {
        flex-direction: column;
    }
    
    .mame-image-container,
    .mame-controls {
        max-width: 100%;
    }
    
    .mame-controls {
        order: 2;
    }
    
    .mame-image-container {
        order: 1;
    }
    
    /* Use accordion on mobile */
    .mame-category:not(.mame-models-category) {
        border: 1px solid rgba(0,0,0,0.1);
        border-radius: 8px;
        margin-bottom: 10px;
        overflow: hidden;
    }
    
    .mame-category:not(.mame-models-category) .mame-category-title {
        background: rgba(0,0,0,0.05);
        padding: 15px;
        margin: 0;
        cursor: pointer;
        display: flex;
        justify-content: space-between;
        align-items: center;
        border-bottom: 1px solid rgba(0,0,0,0.1);
    }
    
    .mame-category:not(.mame-models-category) .mame-category-title::after {
        content: '▼';
        transition: transform 0.2s ease;
    }
    
    .mame-category:not(.mame-models-category) .mame-category-title.active::after {
        transform: rotate(180deg);
    }
    
    .mame-category:not(.mame-models-category) .mame-variations {
        padding: 15px;
        display: none;
    }
    
    .mame-category:not(.mame-models-category) .mame-variations.active {
        display: flex;
    }
    
    /* Models category stays open on mobile */
    .mame-models-category .mame-variations {
        display: flex !important;
    }
}

/* Tablet responsive design */
@media (max-width: 1024px) and (min-width: 769px) {
    .mame-embed-container {
        gap: 15px;
    }
    
    /* Check if height is limited, use accordion if needed */
    .mame-height-limited .mame-category:not(.mame-models-category) {
        border: 1px solid rgba(0,0,0,0.1);
        border-radius: 8px;
        margin-bottom: 10px;
        overflow: hidden;
    }
    
    .mame-height-limited .mame-category:not(.mame-models-category) .mame-category-title {
        background: rgba(0,0,0,0.05);
        padding: 12px;
        margin: 0;
        cursor: pointer;
        display: flex;
        justify-content: space-between;
        align-items: center;
        border-bottom: 1px solid rgba(0,0,0,0.1);
    }
    
    .mame-height-limited .mame-category:not(.mame-models-category) .mame-category-title::after {
        content: '▼';
        transition: transform 0.2s ease;
    }
    
    .mame-height-limited .mame-category:not(.mame-models-category) .mame-category-title.active::after {
        transform: rotate(180deg);
    }
    
    .mame-height-limited .mame-category:not(.mame-models-category) .mame-variations {
        padding: 12px;
        display: none;
    }
    
    .mame-height-limited .mame-category:not(.mame-models-category) .mame-variations.active {
        display: flex;
    }
}

/* Dark theme support */
@media (prefers-color-scheme: dark) {
    .mame-variation-option:hover {
        background-color: rgba(255,255,255,0.1);
    }
    
    .mame-accordion-header {
        background: rgba(255,255,255,0.05);
        border-bottom-color: rgba(255,255,255,0.1);
    }
    
    .mame-accordion-header:hover {
        background: rgba(255,255,255,0.08);
    }
    
    .mame-accordion-header.active {
        background: rgba(255,255,255,0.1);
    }
    
    .mame-category:not(.mame-models-category) {
        border-color: rgba(255,255,255,0.1);
    }
    
    .mame-category:not(.mame-models-category) .mame-category-title {
        background: rgba(255,255,255,0.05);
        border-bottom-color: rgba(255,255,255,0.1);
    }
}

/* Loading state */
.mame-embed.loading .mame-product-image {
    opacity: 0.6;
}

.mame-no-image-placeholder {
    width: 100%;
    aspect-ratio: 4/3;
    background: rgba(0,0,0,0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    color: rgba(0,0,0,0.4);
    font-style: italic;
}

/* Ensure compatibility with various themes */
.mame-embed * {
    box-sizing: border-box;
}

.mame-embed input[type="radio"] {
    appearance: auto;
    -webkit-appearance: radio;
    -moz-appearance: radio;
}
