/* Scoped Styles for Cake Builder Application - Modern & Mobile First */

#cake-builder-app {
    font-family: 'Outfit', sans-serif;
    color: var(--text-dark);
    margin: 0;
    padding: 0;
    width: 100%;
    /* Altura adaptativa al viewport completo menos el header superior */
    height: calc(100vh - 80px);
    /* Ajustar 80px según header real */
    min-height: 600px;
    background-color: #faf8f5;
    /* Fondo más suave para resaltar pasteles */
    position: relative;
    overflow: hidden;
    /* Evitar scrolls innecesarios */
    display: flex;
    flex-direction: column;
}

/* Héroe: El Lienzo SVG */
.builder-preview {
    flex: 1 1 auto;
    /* Ocupa el espacio disponible */
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    /* Que el SVG no desborde */
}

/* El SVG escala automáticamente gracias a viewBox en HTML */
#cake-svg-canvas {
    max-width: 800px;
    max-height: 800px;
    z-index: 10;
}

/* Overlay para elementos interactivos en HTML que estén SOBRE el SVG */
#html-overlay-layer {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    /* Dejar pasar clics al SVG inicialmente */
    z-index: 20;
}

/* --- UI Flotante / Mobile Bottom Sheet --- */

.builder-ui-overlay {
    background: #ffffff;
    border-radius: 24px 24px 0 0;
    box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.05);
    z-index: 50;
    /* Bottom sheet logic para móvil */
    position: relative;
    flex: 0 0 auto;
    max-height: 50vh;
    /* Mitad de la pantalla en móvil */
    display: flex;
    flex-direction: column;
}

/* Header del panel de controles */
.ui-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.2rem 1.5rem;
    border-bottom: 1px solid #f0f0f0;
}

.title-pacifico {
    font-family: 'Pacifico', cursive;
    color: var(--primary);
    font-size: 1.4rem;
    margin: 0;
}

.price-pill {
    background: var(--primary-light);
    color: white;
    font-weight: 700;
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-size: 1.1rem;
    box-shadow: var(--shadow-sm);
}

/* Navegación por Tabs (Scroll horizontal en móvil) */
.builder-tabs {
    display: flex;
    overflow-x: auto;
    scrollbar-width: none;
    /* Hide scrollbar Firefox */
    -ms-overflow-style: none;
    /* Hide scrollbar IE/Edge */
    padding: 0.5rem 1rem;
    border-bottom: 1px solid #f0f0f0;
    gap: 0.5rem;
}

.builder-tabs::-webkit-scrollbar {
    display: none;
    /* Safari/Chrome */
}

.tab-btn {
    background: transparent;
    border: none;
    padding: 0.8rem 1.2rem;
    font-family: 'Outfit', sans-serif;
    font-weight: 600;
    color: #888;
    white-space: nowrap;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.tab-btn.active {
    background: var(--secondary-light);
    color: var(--primary-dark);
}

/* Paneles de Contenido (Tabs) */
.builder-panels-container {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 1.5rem;
    background: #fafafa;
}

.tab-panel {
    display: none;
    animation: fadeIn 0.3s ease;
}

.tab-panel.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.control-section {
    margin-bottom: 2rem;
}

.control-section h4 {
    font-size: 1rem;
    color: #555;
    margin-bottom: 1rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Grid Options (Visual buttons) */
.options-grid {
    display: grid;
    gap: 1rem;
}

.options-grid.forms,
.options-grid.flavors {
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
}

.options-grid.sizes,
.options-grid.toppings-grid {
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
}

.options-grid.icing-colors {
    grid-template-columns: repeat(auto-fill, minmax(50px, 1fr));
    gap: 0.8rem;
}

/* Visual Button Cards (Swatches & Icons) */
.visual-btn {
    background: white;
    border: 2px solid transparent;
    border-radius: 12px;
    padding: 1rem 0.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.8rem;
    cursor: pointer;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.02), 0 1px 3px rgba(0, 0, 0, 0.05);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.visual-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.05);
}

.visual-btn.active {
    border-color: var(--primary);
    background: #fffafa;
    /* Tinte super ligero primario */
    box-shadow: 0 0 0 1px var(--primary);
}

.visual-btn span {
    font-family: 'Outfit', sans-serif;
    font-size: 0.85rem;
    font-weight: 600;
    color: #444;
}

/* Text / Basic Buttons */
.text-btn {
    background: white;
    border: 2px solid #eee;
    padding: 0.8rem;
    border-radius: 10px;
    cursor: pointer;
    font-family: 'Outfit', sans-serif;
    font-weight: 600;
    color: #444;
    transition: all 0.2s;
    text-align: center;
}

.text-btn.active,
.text-btn.checkable.active {
    border-color: var(--primary);
    background: var(--primary-light);
    color: white;
}

/* Icons / Swatches within buttons */
.icon-round,
.icon-square {
    width: 40px;
    height: 30px;
    background: #e0e0e0;
    border-bottom: 6px solid #ccc;
    /* 3D effect fake */
}

.icon-round {
    border-radius: 50% / 30%;
}

.icon-square {
    border-radius: 4px;
}

.visual-btn.active .icon-round,
.visual-btn.active .icon-square {
    background: var(--primary-light);
    border-color: var(--primary);
}

.swatch {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.2);
}

.texture-vainilla {
    background: #fdf6e3;
}

.texture-choco {
    background: #4a3424;
}

.texture-redv {
    background: #8b1c24;
}

.color-swatch {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    border: 3px solid white;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    cursor: pointer;
    transition: transform 0.2s;
}

.color-swatch.active {
    transform: scale(1.15);
    box-shadow: 0 0 0 2px var(--primary);
}

.fancy-input {
    width: 100%;
    padding: 1rem;
    border: 2px solid #eee;
    border-radius: 10px;
    font-family: 'Outfit', sans-serif;
    font-size: 1rem;
    transition: border-color 0.3s;
}

.fancy-input:focus {
    outline: none;
    border-color: var(--primary);
}

/* Summary Card */
.summary-card {
    background: white;
    padding: 1.5rem;
    border-radius: 16px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.05);
}

#summary-details {
    list-style: none;
    padding: 0;
    margin: 0 0 1.5rem 0;
    line-height: 2;
    color: #555;
}

.summary-total-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 2px dashed #eee;
    padding-top: 1rem;
    margin-bottom: 1.5rem;
    font-size: 1.2rem;
    font-weight: 700;
}

#summary-total-price {
    font-size: 1.8rem;
    color: var(--secondary);
}

.btn-action-primary {
    width: 100%;
    padding: 1rem;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 30px;
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(103, 58, 183, 0.3);
    /* Usa variable de color primaria si está definida */
    transition: transform 0.2s;
}

.btn-action-primary:active {
    transform: scale(0.98);
}


/* --- Modo Escritorio (Tablet/Desktop) --- */
@media (min-width: 900px) {
    #cake-builder-app {
        flex-direction: row;
        /* Layout horizontal lado a lado */
        border-radius: 16px;
        /* Borde suave general */
        margin: 2rem auto;
        max-width: 1400px;
        /* Ancho máximo para pantallas ultrawide */
        height: 80vh;
        box-shadow: 0 10px 40px rgba(0, 0, 0, 0.05);
    }

    .builder-preview {
        flex: 1;
        /* Ocupa centro/izquierda */
        background: transparent;
    }

    .builder-ui-overlay {
        width: 400px;
        /* Panel lateral derecho fijo */
        max-height: 100%;
        border-radius: 0 16px 16px 0;
        box-shadow: -5px 0 30px rgba(0, 0, 0, 0.03);
    }
}