/* Image Editor Styles */
.editor-container {
    background: white;
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    padding: var(--spacing-lg);
    margin-top: var(--spacing-lg);
}

.editor-workspace {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: var(--spacing-lg);
    margin-top: var(--spacing-lg);
}

.canvas-preview {
    position: relative;
    background: #f8f9fa;
    border-radius: var(--radius-lg);
    padding: var(--spacing-md);
    min-height: 500px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.canvas-preview canvas {
    max-width: 100%;
    max-height: 600px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
}

.editor-controls {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
}

.control-section {
    background: var(--color-light);
    padding: var(--spacing-md);
    border-radius: var(--radius-lg);
}

.control-section h4 {
    margin-bottom: var(--spacing-sm);
    font-size: 1rem;
    color: var(--color-dark);
}

.size-selector {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--spacing-xs);
}

.size-option {
    padding: var(--spacing-sm);
    background: white;
    border: 2px solid var(--color-gray-light);
    border-radius: var(--radius-md);
    cursor: pointer;
    text-align: center;
    transition: all var(--transition-base);
    font-size: 0.875rem;
}

.size-option:hover {
    border-color: var(--color-primary);
}

.size-option.active {
    border-color: var(--color-primary);
    background: var(--color-primary);
    color: white;
}

.orientation-selector {
    display: flex;
    gap: 10px;
}

.modal-orientation-btn,
.orientation-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 10px;
    border: 1px solid var(--color-light);
    background: #f8fafc;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s;
    color: var(--color-gray);
    font-size: 0.9rem;
}

.modal-orientation-btn:hover,
.orientation-btn:hover {
    background: #fff;
    border-color: var(--color-primary);
    color: var(--color-primary);
}

.modal-orientation-btn.active,
.orientation-btn.active {
    background: var(--color-primary);
    border-color: var(--color-primary);
    color: white;
}

.modal-orientation-btn i,
.orientation-btn i {
    font-size: 1.5rem;
    margin-bottom: 5px;
}

.modal-orientation-btn span,
.orientation-btn span {
    font-size: 0.8rem;
    font-weight: 500;
}

.slider-control {
    margin-top: var(--spacing-sm);
}

.slider-control label {
    display: flex;
    justify-content: space-between;
    margin-bottom: var(--spacing-xs);
    font-size: 0.875rem;
}

.slider-control input[type="range"] {
    width: 100%;
    height: 8px;
    border-radius: var(--radius-full);
    background: var(--color-gray-light);
    outline: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

.slider-control input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--color-primary);
    cursor: pointer;
    box-shadow: var(--shadow-md);
}

.slider-control input[type="range"]::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--color-primary);
    cursor: pointer;
    box-shadow: var(--shadow-md);
    border: none;
}

.price-display {
    background: var(--gradient-primary);
    color: white;
    padding: var(--spacing-md);
    border-radius: var(--radius-lg);
    text-align: center;
}

.price-display h3 {
    color: white;
    margin-bottom: var(--spacing-sm);
    font-size: 1rem;
}

.price-display .price {
    font-size: 2.5rem;
    font-weight: 800;
    margin-bottom: var(--spacing-xs);
}

.price-display .details {
    font-size: 0.875rem;
    opacity: 0.9;
}

.upload-zone {
    border: 3px dashed var(--color-gray-light);
    border-radius: var(--radius-xl);
    padding: var(--spacing-xl);
    text-align: center;
    background: var(--color-light);
    cursor: pointer;
    transition: all var(--transition-base);
}

.upload-zone:hover {
    border-color: var(--color-primary);
    background: rgba(99, 102, 241, 0.05);
}

.upload-zone.dragover {
    border-color: var(--color-primary);
    background: rgba(99, 102, 241, 0.1);
}

.upload-zone i {
    font-size: 4rem;
    color: var(--color-gray);
    margin-bottom: var(--spacing-md);
}

.upload-zone h3 {
    margin-bottom: var(--spacing-sm);
}

.upload-zone p {
    color: var(--color-gray);
}

.upload-zone input[type="file"] {
    display: none;
}

.custom-size-inputs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--spacing-sm);
    margin-top: var(--spacing-sm);
}

.dimension-input {
    position: relative;
}

.dimension-input input {
    padding-right: 35px;
}

.dimension-input span {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--color-gray);
    font-weight: 600;
}

/* Crop Tool */
.crop-controls {
    display: flex;
    gap: var(--spacing-xs);
    margin-top: var(--spacing-sm);
}

.crop-controls button {
    flex: 1;
    padding: var(--spacing-xs);
    background: white;
    border: 2px solid var(--color-gray-light);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-base);
    font-weight: 600;
    color: var(--color-dark);
}

.crop-controls button:hover {
    border-color: var(--color-primary);
    color: var(--color-primary);
}

/* Responsive */
@media (max-width: 968px) {
    .editor-workspace {
        grid-template-columns: 1fr;
    }

    .size-selector {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 640px) {
    .size-selector {
        grid-template-columns: repeat(2, 1fr);
    }

    .custom-size-inputs {
        grid-template-columns: 1fr;
    }
}

/* Room View Styles */
.room-preview-container {
    position: relative;
    width: 100%;
    height: 0;
    padding-bottom: 56.25%;
    /* 16:9 Aspect Ratio */
    background: #f0f0f0;
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.1);
}

#room-background {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    z-index: 1;
}

.canvas-on-wall {
    position: absolute;
    top: 40%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 2;
    /* Layered shadows for realism */
    box-shadow:
        0 20px 50px rgba(0, 0, 0, 0.3),
        0 5px 15px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
}

/* 3D Edge Effect */
.canvas-on-wall::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: inset 2px 2px 4px rgba(255, 255, 255, 0.2);
    pointer-events: none;
}

.canvas-on-wall img {
    display: block;
    width: 100%;
    height: auto;
    filter: contrast(1.05) brightness(1.02);
    border-radius: 2px;
    /* Slight rounding for wrap effect */
}

.room-btn {
    padding: 10px 20px;
    background: white;
    border: 1px solid var(--color-light);
    border-radius: var(--radius-full);
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 500;
    color: var(--color-gray);
}

.room-btn:hover {
    background: #f8fafc;
    border-color: var(--color-primary);
    color: var(--color-primary);
}

.room-btn.active {
    background: var(--color-primary);
    border-color: var(--color-primary);
    color: white;
}

/* =========================================
   NUEVA ESTRUCTURA DEL EDITOR (MODAL)
   ========================================= */

/* Estructura Principal del Modal Editor */
.editor-layout {
    display: flex;
    flex-direction: row;
    height: 100%; /* Ocupar toda la altura del modal-content */
    overflow: hidden; /* Evitar scroll en el contenedor padre */
}

/* Zona Izquierda: Canvas */
.zone-canvas {
    flex: 1;
    background: #eef2f6;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    overflow: hidden;
}

.canvas-wrapper {
    box-shadow: 0 10px 30px rgba(0,0,0,0.15);
    line-height: 0;
}

/* Botones flotantes canvas */
.canvas-floating-tools {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 10px;
    background: white;
    padding: 5px;
    border-radius: 30px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.btn-float {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: transparent;
    cursor: pointer;
    color: #555;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.btn-float:hover {
    background: #f0f0f0;
    color: var(--color-primary, #0d6efd);
}

/* Zona Derecha: Controles */
.zone-controls {
    width: 380px;
    display: flex;
    flex-direction: column; /* Apila elementos verticalmente */
    background: white;
    border-left: 1px solid #ddd;
    z-index: 10;
    height: 100%; /* Importante para el cálculo de flex */
}

/* Pestañas de Navegación */
.mobile-tabs {
    display: flex;
    border-bottom: 1px solid #eee;
    background: #fff;
    padding: 0 5px;
    flex-shrink: 0; /* No encoger */
}

.tab-link {
    flex: 1;
    padding: 15px 5px;
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    cursor: pointer;
    font-weight: 600;
    color: #888;
    font-size: 0.9rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
}

.tab-link.active {
    color: var(--color-primary, #0d6efd);
    border-bottom-color: var(--color-primary, #0d6efd);
}

/* Contenido de las Pestañas (Scrollable) */
.tabs-content {
    flex: 1; /* Ocupa todo el espacio disponible restante */
    overflow-y: auto; /* Habilita el SCROLL aquí */
    padding: 20px;
    background: #fff;
    min-height: 0; /* Crucial para Firefox/Flexbox scroll */
}

.tab-panel {
    display: none;
    animation: fadeIn 0.3s ease;
}

.tab-panel.active {
    display: block;
}

/* Footer (Precio y Botón) */
.zone-footer {
    padding: 15px 20px;
    background: white;
    border-top: 1px solid #eee;
    box-shadow: 0 -4px 10px rgba(0,0,0,0.03);
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
    flex-shrink: 0; /* Asegura que no se aplaste */
}

.price-block { display: flex; flex-direction: column; }
.price-tag { font-size: 1.4rem; font-weight: 800; color: #333; }
.details-small { font-size: 0.75rem; color: #888; }
.btn-add { padding: 12px 25px; border-radius: 30px; font-weight: 600; display: flex; align-items: center; gap: 8px; }

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(5px); }
    to { opacity: 1; transform: translateY(0); }
}

/* --- RESPONSIVE MOBILE --- *//* --- RESPONSIVE MOBILE --- */
/* --- RESPONSIVE MOBILE (40% IMAGEN / 60% CONTROLES) --- */
@media (max-width: 768px) {
    /* Layout principal */
    .editor-layout {
        flex-direction: column;
        height: 100%; 
        width: 100%;
    }

    /* Cabecera ultra-compacta */
    .modal-content > div:first-child {
        padding: 4px 10px !important;
        min-height: 36px;
    }
    .modal-content h2 {
        font-size: 0.95rem !important;
    }
    .modal-close {
        font-size: 1.2rem !important;
    }

    /* 1. ZONA LIENZO: 40% */
    .zone-canvas {
        flex: none; 
        height: 40%; /* Reducido para dar más aire abajo */
        width: 100%;
        padding: 10px;
        background: #eef2f6;
        border-bottom: 1px solid #ddd;
    }
    
    /* 2. ZONA CONTROLES: 60% */
    .zone-controls {
        width: 100%;
        height: 60%; /* Ganamos un 10% extra aquí */
        flex: none; 
        border: none;
        display: flex;
        flex-direction: column;
        background: white;
    }

    /* --- COMPACTACIÓN MÁXIMA DE INTERIORES --- */
    
    /* Barra de Pestañas */
    .mobile-tabs {
        min-height: 32px;
        padding: 0;
        background: #f8f9fa;
        border-bottom: 1px solid #e0e0e0;
    }
    .tab-link {
        padding: 6px 4px;
        font-size: 0.8rem;
        gap: 3px;
    }
    .tab-link i { font-size: 0.9rem; }
    
    /* Área de contenido con scroll */
    .tabs-content {
        flex: 1;
        overflow-y: auto;
        padding: 8px; /* Menos relleno lateral */
        -webkit-overflow-scrolling: touch; 
    }
    
    /* Secciones (cajas grises) */
    .control-section {
        padding: 8px !important;
        margin-bottom: 8px;
        border-radius: 6px;
    }
    .control-section h4 {
        margin-bottom: 6px !important;
        font-size: 0.85rem !important;
    }
    
    /* Grid de Materiales más denso */
    .material-options-grid {
        gap: 6px !important; /* Menos espacio entre botones */
    }

    /* Botones de opción (Materiales y Tamaños) */
    .material-option, 
    .size-option {
        padding: 6px 4px !important;
        font-size: 0.75rem !important; /* Texto más pequeño */
        border-radius: 6px !important;
        min-height: auto !important;
    }
    .material-option i {
        font-size: 1.1rem !important;
        margin-bottom: 2px !important;
    }
    
    /* Inputs de medidas */
    .control-group { margin-bottom: 10px; }
    .group-label { 
        font-size: 0.8rem; 
        margin-bottom: 4px; 
    }
    .form-control {
        font-size: 0.85rem;
        padding: 6px 8px;
        height: auto;
    }
    
    /* Footer minimalista */
    .zone-footer {
        padding: 6px 10px;
        background: #fff;
        border-top: 1px solid #eee;
        padding-bottom: max(6px, env(safe-area-inset-bottom));
        flex-shrink: 0;
        gap: 10px;
    }
    .price-block .details-small { display: none; } /* Ocultamos detalles extra en móvil para ahorrar espacio */
    .price-tag { font-size: 1.1rem !important; margin: 0; }
    .btn-add { 
        padding: 6px 16px !important; 
        font-size: 0.85rem !important; 
        height: 36px;
    }
}
/* --- DESKTOP (Pantallas grandes) --- */
@media (min-width: 769px) {
    .mobile-tabs {
        display: none !important;
    }

    .tab-panel {
        display: block !important;
        opacity: 1 !important;
        transform: none !important;
        animation: none !important;
        margin-bottom: 20px;
        padding-bottom: 20px;
        border-bottom: 1px solid #f0f0f0;
    }

    .tab-panel:last-child {
        border-bottom: none;
        margin-bottom: 0;
    }
    
    /* CAMBIO CLAVE: Asegurar que el scroll ocupe todo */
    .tabs-content {
        padding: 20px;
        overflow-y: auto;
        height: 100%;
    }

    /* CAMBIO CLAVE: En desktop, reducimos padding del canvas para que la imagen crezca */
    .zone-canvas {
        padding: 10px; 
    }
}
/* --- AÑADIR AL FINAL DE EDITOR.CSS --- */

/* Estilo del botón de medida personalizada */
.btn-outline-toggle {
    width: 100%;
    padding: 12px;
    background: white;
    border: 2px dashed #cbd5e1; /* Borde más visible */
    border-radius: 8px;
    color: #64748b;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-bottom: 10px;
}

.btn-outline-toggle:hover {
    border-color: var(--color-primary, #0d6efd);
    color: var(--color-primary, #0d6efd);
    background: #f0f9ff;
}

.btn-outline-toggle.active {
    background: #eff6ff;
    color: var(--color-primary, #0d6efd);
    border-color: var(--color-primary, #0d6efd);
    border-style: solid; /* Cambia de dashed a solid al activar */
}

/* Contenedor de inputs */
.custom-size-inputs {
    display: grid; /* Grid por defecto */
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: 10px;
    padding: 10px;
    background: #f8fafc; /* Fondo gris claro para destacar */
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    animation: fadeIn 0.3s ease;
}

/* Forzar que se vean en móvil */
@media (max-width: 768px) {
    .custom-size-inputs {
        grid-template-columns: 1fr 1fr; /* Mantener 2 columnas en móvil */
        margin-bottom: 20px; /* Espacio extra abajo para el scroll */
    }
}
/* --- AÑADIR AL FINAL DE EDITOR.CSS --- */

/* Indicador de Arrastrar (Móvil) */
/* --- REEMPLAZAR EN EDITOR.CSS --- */

/* Indicador de Arrastrar (Mejorado para móvil) */
.drag-hint {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.7); /* Un poco más oscuro para contraste */
    color: white;
    padding: 10px 20px;
    border-radius: 50px;
    display: flex;
    flex-direction: row; /* CAMBIO: Horizontal para ahorrar altura */
    align-items: center;
    justify-content: center;
    gap: 12px; /* Espacio entre mano y texto */
    pointer-events: none;
    z-index: 50; /* Z-index alto para asegurar que se ve */
    opacity: 1;
    transition: opacity 0.5s ease;
    width: max-content; /* Asegura que la caja crezca lo necesario */
    max-width: 90%; /* Evita que se salga si la pantalla es enana */
}

.drag-hint.fade-out {
    opacity: 0;
    visibility: hidden; /* Asegura que no estorbe */
}

.drag-hint .hand-icon {
    font-size: 1.5rem; /* Icono un poco más controlado */
    display: flex; /* Centrar icono */
    animation: dragAnimation 2s infinite ease-in-out;
}

.drag-hint span {
    font-size: 0.9rem;
    font-weight: 600;
    white-space: nowrap; /* CRUCIAL: Impide que el texto se parta en líneas */
    line-height: 1; /* Evita superposiciones */
    text-shadow: 0 1px 2px rgba(0,0,0,0.5); /* Sombra para leer mejor */
}

@keyframes dragAnimation {
    0%, 100% { transform: translateX(-5px); }
    50% { transform: translateX(5px); }
}

/* Nuevos Botones de Filtros */
.filters-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}

.filter-btn {
    padding: 10px;
    background: white;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    color: #64748b;
    font-size: 0.9rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s;
}

.filter-btn:hover {
    border-color: var(--color-primary, #0d6efd);
    color: var(--color-primary, #0d6efd);
}

.filter-btn.active {
    background: #eff6ff;
    border-color: var(--color-primary, #0d6efd);
    color: var(--color-primary, #0d6efd);
    font-weight: 600;
}

/* Ajustes Responsive para Filtros */
@media (max-width: 768px) {
    .filters-grid {
        grid-template-columns: repeat(4, 1fr); /* En una fila en móvil */
        overflow-x: auto;
    }
    .filter-btn {
        flex-direction: column;
        font-size: 0.75rem;
        padding: 8px 4px;
        white-space: nowrap;
    }
    .filter-btn i {
        font-size: 1.1rem;
        margin-bottom: 2px;
    }
}