/**
 * =====================================================
 * LAYOUT EDITOR - Estilos para modo edición de layout
 * =====================================================
 * Estilos para el modo de edición de características
 * Solo visible para tenant 1
 */

/* ============================================
   BOTÓN DE MODO EDICIÓN
   ============================================ */
.btn-layout-edit {
    background: linear-gradient(135deg, #6571ff 0%, #8b5cf6 100%);
    border: none;
    color: white;
    padding: 0.375rem 0.75rem;
    border-radius: 0.375rem;
    font-size: 0.875rem;
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-layout-edit:hover {
    background: linear-gradient(135deg, #5461e6 0%, #7c4ce0 100%);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(101, 113, 255, 0.35);
}

.btn-layout-edit.active {
    background: linear-gradient(135deg, #f59e0b 0%, #f97316 100%);
    animation: pulse-glow 2s infinite;
}

@keyframes pulse-glow {
    0%, 100% { box-shadow: 0 0 5px rgba(245, 158, 11, 0.4); }
    50% { box-shadow: 0 0 20px rgba(245, 158, 11, 0.6); }
}

.btn-layout-save {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    border: none;
    color: white;
    padding: 0.375rem 0.75rem;
    border-radius: 0.375rem;
    font-size: 0.875rem;
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    cursor: pointer;
    margin-left: 0.5rem;
}

.btn-layout-save:hover {
    background: linear-gradient(135deg, #059669 0%, #047857 100%);
}

/* ============================================
   MODO EDICIÓN ACTIVO
   ============================================ */
.layout-edit-mode .caracteristicas-section {
    background: #fef3c7;
    border: 2px dashed #f59e0b;
    border-radius: 0.5rem;
    padding: 1rem;
}

.layout-edit-mode .agrupacion-card {
    border: 2px dashed #d1d5db !important;
    background: #f9fafb;
}

.layout-edit-mode .agrupacion-card.agrupacion-empty {
    border-color: #fca5a5 !important;
    background: #fef2f2;
    opacity: 0.8;
}

.layout-edit-mode .agrupacion-card.agrupacion-empty .agrupacion-header {
    color: #dc2626;
}

/* ============================================
   CAMPOS EN MODO EDICIÓN
   ============================================ */
.layout-edit-mode .carac-field-wrapper {
    position: relative;
    border: 2px dashed transparent;
    border-radius: 0.375rem;
    transition: all 0.2s ease;
    padding: 0.25rem;
    margin: -0.25rem;
}

.layout-edit-mode .carac-field-wrapper:hover {
    border-color: #6571ff;
    background: rgba(101, 113, 255, 0.05);
}

.layout-edit-mode .carac-field-wrapper.ui-sortable-helper {
    background: white;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
    border-color: #6571ff;
    z-index: 1000;
}

.layout-edit-mode .carac-field-wrapper.ui-sortable-placeholder {
    visibility: visible !important;
    background: #e0e7ff;
    border: 2px dashed #6571ff;
    border-radius: 0.375rem;
}

/* Handle de arrastre */
.layout-edit-mode .drag-handle {
    display: block !important;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 24px;
    background: linear-gradient(135deg, #6571ff 0%, #8b5cf6 100%);
    border-radius: 0.25rem 0.25rem 0 0;
    cursor: move;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.layout-edit-mode .carac-field-wrapper:hover .drag-handle {
    opacity: 1;
}

.drag-handle::before {
    content: '⋮⋮';
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: white;
    font-size: 14px;
    letter-spacing: 2px;
}

/* Selector de ancho */
.layout-edit-mode .width-selector {
    display: flex !important;
    position: absolute;
    top: 2px;
    right: 2px;
    z-index: 10;
    background: white;
    border-radius: 0.25rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.layout-edit-mode .carac-field-wrapper:hover .width-selector {
    opacity: 1;
}

.width-selector .width-btn {
    padding: 0.125rem 0.375rem;
    font-size: 0.6875rem;
    border: none;
    background: white;
    color: #6b7280;
    cursor: pointer;
    transition: all 0.15s ease;
}

.width-selector .width-btn:hover {
    background: #e0e7ff;
    color: #6571ff;
}

.width-selector .width-btn.active {
    background: #6571ff;
    color: white;
}

/* Ocultar en modo normal */
.drag-handle,
.width-selector {
    display: none;
}

/* ============================================
   ACORDEONES DE AGRUPACIONES
   ============================================ */
.agrupacion-card {
    border: 1px solid #e5e7eb;
    border-radius: 0.5rem;
    margin-bottom: 0.75rem;
    background: white;
    overflow: hidden;
}

.agrupacion-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    cursor: pointer;
    user-select: none;
    transition: background 0.2s ease;
}

.agrupacion-header:hover {
    background: linear-gradient(135deg, #e2e8f0 0%, #e5e7eb 100%);
}

.agrupacion-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
    color: #374151;
}

.agrupacion-title .mdi {
    font-size: 1.25rem;
    color: #6571ff;
    transition: transform 0.3s ease;
}

.agrupacion-card.collapsed .agrupacion-title .mdi-chevron-down {
    transform: rotate(-90deg);
}

.agrupacion-badge {
    font-size: 0.75rem;
    padding: 0.125rem 0.5rem;
    background: #e0e7ff;
    color: #6571ff;
    border-radius: 1rem;
    font-weight: 500;
}

.agrupacion-body {
    padding: 1rem;
    border-top: 1px solid #e5e7eb;
}

.agrupacion-card.collapsed .agrupacion-body {
    display: none;
}

/* Agrupación vacía */
.agrupacion-empty .agrupacion-header {
    background: #fef2f2;
}

.agrupacion-empty .agrupacion-title {
    color: #9ca3af;
    font-style: italic;
}

.agrupacion-empty .agrupacion-badge {
    background: #fee2e2;
    color: #dc2626;
}

/* ============================================
   ROW PARA CAMPOS DENTRO DE AGRUPACIONES
   ============================================ */
.agrupacion-fields-row {
    display: flex;
    flex-wrap: wrap;
    margin: -0.375rem;
}

.agrupacion-fields-row > .carac-field-wrapper {
    padding: 0.375rem;
}

/* ============================================
   INDICADOR DE GUARDADO
   ============================================ */
.layout-saving-indicator {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: #10b981;
    color: white;
    padding: 0.75rem 1.25rem;
    border-radius: 0.5rem;
    box-shadow: 0 4px 15px rgba(16, 185, 129, 0.4);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    z-index: 9999;
    animation: slideInRight 0.3s ease;
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(100px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.layout-saving-indicator .spinner {
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
    .layout-edit-mode .width-selector {
        display: none !important;
    }
    
    .btn-layout-edit span {
        display: none;
    }
}
