/**
 * Estilos para Backend DEV - Configurador de Vistas
 */

.dev-configurator {
    padding: 20px 0;
}

.dev-configurator .card {
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    border: 1px solid #e0e0e0;
}

.dev-configurator .card-header {
    background: linear-gradient(135deg, #1e3a5f 0%, #2c5282 100%);
    color: white;
    font-weight: 600;
}

.dev-configurator .card-header h5 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
}

.dev-configurator h6 {
    color: #000;
    font-weight: 600;
}

/* Tabs */
.dev-configurator .nav-tabs {
    border-bottom: 2px solid #2c5282;
}

.dev-configurator .nav-tabs .nav-link {
    color: #666;
    font-weight: 500;
    border: none;
    border-bottom: 3px solid transparent;
    transition: all 0.3s;
}

.dev-configurator .nav-tabs .nav-link:hover {
    color: #2c5282;
    border-bottom-color: #2c5282;
}

.dev-configurator .nav-tabs .nav-link.active {
    color: #2c5282;
    border-bottom-color: #2c5282;
    background: transparent;
}

/* Tablas */
.dev-configurator .table {
    margin-bottom: 0;
}

.dev-configurator .table thead th {
    background: white;
    color: #2c5282;
    font-weight: 600;
    font-size: 0.9rem;
    border-bottom: 2px solid #dee2e6;
}

.dev-configurator .table tbody tr:hover {
    background: #f8f9fa;
}

.dev-configurator .table code {
    background: #e9ecef;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 0.85rem;
}

/* Labels en Información Básica - texto blanco */
.dev-configurator #basicInfoSection .form-label {
    color: white !important;
}

/* Botones Cargar Estructura - bordes y texto blanco */
.dev-configurator #btnLoadStructure,
.dev-configurator #btnLoadDetailStructure {
    color: white !important;
    border-color: white !important;
}

.dev-configurator #btnLoadStructure:hover,
.dev-configurator #btnLoadDetailStructure:hover {
    background-color: rgba(255, 255, 255, 0.1) !important;
    color: white !important;
    border-color: white !important;
}

/* Títulos de pestañas en paneles de columnas - texto blanco */
.dev-configurator .nav-tabs .nav-link {
    color: white !important;
}

.dev-configurator .nav-tabs .nav-link.active {
    color: #2c5282 !important;
    background: white !important;
}

.dev-configurator .nav-tabs .nav-link:hover {
    color: #2c5282 !important;
    background: rgba(255, 255, 255, 0.8) !important;
}

/* Formulario de construcción */
.dev-configurator #viewBuilderForm .card {
    margin-bottom: 1.5rem;
}

.dev-configurator #viewBuilderForm .form-label {
    font-weight: 600;
    color: #000;
    margin-bottom: 0.5rem;
    font-size: 0.95rem;
}

.dev-configurator #viewBuilderForm .form-control:focus,
.dev-configurator #viewBuilderForm .form-select:focus {
    border-color: #2c5282;
    box-shadow: 0 0 0 0.2rem rgba(44, 82, 130, 0.25);
}

/* Configuración de columnas */
#columnsContainer .table-responsive {
    max-height: 500px;
    overflow-y: auto;
}

#columnsContainer .table th {
    position: sticky;
    top: 0;
    background: #2c5282;
    color: white;
    z-index: 10;
    font-size: 0.9rem;
}

#columnsContainer .table td {
    color: #000;
}

#columnsContainer .form-control-sm,
#columnsContainer .form-select-sm {
    font-size: 0.85rem;
}

#columnsContainer .form-check-input {
    cursor: pointer;
}

/* Opciones de hooks */
#hooksOptions {
    background: #f8f9fa;
    padding: 1rem;
    border-radius: 6px;
    border: 1px solid #dee2e6;
}

#hooksOptions h6 {
    color: #000;
    font-weight: 600;
    margin-bottom: 0.75rem;
    font-size: 0.95rem;
}

#hooksOptions .form-check {
    margin-bottom: 0.5rem;
}

#hooksOptions .form-check-label {
    font-size: 0.9rem;
    color: #000;
}

/* Modal de vista previa */
#previewModal pre {
    border-radius: 6px;
    font-size: 0.85rem;
    line-height: 1.4;
}

/* Modal de estructura */
#structureModal .table {
    font-size: 0.9rem;
}

#structureModal .list-group-item {
    padding: 0.5rem 0.75rem;
    font-size: 0.9rem;
}

/* Badges */
.dev-configurator .badge {
    font-weight: 500;
    padding: 0.35em 0.65em;
}

/* Botones */
.dev-configurator .btn-sm {
    padding: 0.25rem 0.5rem;
    font-size: 0.875rem;
}

.dev-configurator .btn-outline-primary:hover {
    background: #2c5282;
    border-color: #2c5282;
}

.dev-configurator .btn-outline-success:hover {
    background: #28a745;
    border-color: #28a745;
}

.dev-configurator .btn-outline-info:hover {
    background: #17a2b8;
    border-color: #17a2b8;
}

/* Responsive */
@media (max-width: 768px) {
    .dev-configurator {
        padding: 10px 0;
    }
    
    .dev-configurator .card-body {
        padding: 1rem;
    }
    
    #columnsContainer .table {
        font-size: 0.8rem;
    }
}

/* Loading state */
.dev-configurator .loading {
    text-align: center;
    padding: 2rem;
    color: #6c757d;
}

.dev-configurator .loading::after {
    content: "Cargando...";
    display: block;
    margin-top: 0.5rem;
}

/* Empty state */
.dev-configurator .empty-state {
    text-align: center;
    padding: 3rem;
    color: #6c757d;
}

.dev-configurator .empty-state i {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

/* Drag and Drop - Sortable */
.sortable-ghost {
    opacity: 0.4;
    background: #e3f2fd;
}

.sortable-drag {
    opacity: 1;
    cursor: move;
}

#columnsTableBody tr,
#formColumnsTableBody tr,
#detailColumnsTableBody tr,
#detailFormColumnsTableBody tr {
    cursor: move;
    transition: background-color 0.2s;
    position: relative;
}

#columnsTableBody tr:hover,
#formColumnsTableBody tr:hover,
#detailColumnsTableBody tr:hover,
#detailFormColumnsTableBody tr:hover {
    background-color: #f0f7ff;
}

/* Indicador visual de drag - solo icono, sin cuadro blanco */
#columnsTableBody tr td:first-child::before,
#formColumnsTableBody tr td:first-child::before,
#detailColumnsTableBody tr td:first-child::before,
#detailFormColumnsTableBody tr td:first-child::before {
    content: '\f0c9';
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    margin-right: 8px;
    color: #ccc;
    opacity: 0;
    transition: opacity 0.2s;
}

#columnsTableBody tr:hover td:first-child::before,
#formColumnsTableBody tr:hover td:first-child::before,
#detailColumnsTableBody tr:hover td:first-child::before,
#detailFormColumnsTableBody tr:hover td:first-child::before {
    opacity: 1;
}

/* Botones "Cargar Estructura" - cambiar de gris a azul */
.btn-secondary {
    background-color: #0d6efd !important;
    border-color: #0d6efd !important;
    color: white !important;
}

.btn-secondary:hover {
    background-color: #0b5ed7 !important;
    border-color: #0a58ca !important;
}

/* Textos en labels sobre fondo azul - cambiar a blanco/amarillo claro */
.card-header label,
.card-header .form-label,
.card-body label.text-white,
.card-body .form-label.text-white {
    color: #fff !important;
}

/* Labels en card-body con fondo azul */
#detailSection label,
#detailSection .form-label,
#detailSection small {
    color: #fff !important;
}

/* Mejorar visibilidad de selects en fondo azul */
#columnsContainer select.form-select,
#formColumnsContainer select.form-select,
#detailColumnsContainer select.form-select,
#detailFormColumnsContainer select.form-select {
    background-color: #fff !important;
    color: #000 !important;
    border: 1px solid #ced4da !important;
}

/* Headers de tabs - cambiar texto blanco a color visible */
.nav-tabs .nav-link {
    color: #495057 !important;
}

.nav-tabs .nav-link.active {
    color: #2c5282 !important;
    font-weight: 600;
}

/* Botones de acción sticky en la parte inferior del formulario */
#actionButtonsPanel {
    position: sticky;
    bottom: 0;
    z-index: 100;
    box-shadow: 0 -4px 12px rgba(0,0,0,0.15);
    margin-top: 20px;
    background: white;
}

/* Agregar padding al formulario para mejor espaciado */
#viewBuilderForm {
    padding-bottom: 20px;
}

/* ============================================
   LAYOUT EDITOR STYLES
   ============================================ */

/* Sidebar - campos disponibles */
.layout-editor-sidebar {
    width: 260px;
    min-width: 260px;
    background: #f8f9fa;
    border-right: 2px solid #dee2e6;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    max-height: calc(100vh - 120px);
}

.layout-editor-sidebar h6 {
    color: #2c5282;
    font-size: 0.9rem;
}

/* Campo disponible (draggable) */
.layout-available-field {
    background: white;
    border: 1px solid #ced4da;
    border-radius: 4px;
    padding: 6px 10px;
    margin-bottom: 4px;
    cursor: grab;
    font-size: 0.82rem;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.15s;
    user-select: none;
}

.layout-available-field:hover {
    background: #e3f2fd;
    border-color: #2196f3;
}

.layout-available-field:active {
    cursor: grabbing;
}

.layout-available-field .field-icon {
    color: #6c757d;
    font-size: 0.75rem;
}

.layout-available-field .field-name {
    font-weight: 600;
    color: #333;
}

.layout-available-field .field-label {
    color: #6c757d;
    font-size: 0.75rem;
    margin-left: auto;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100px;
}

/* Canvas del editor */
.layout-editor-canvas {
    background: #eef2f7;
    overflow-y: auto;
    max-height: calc(100vh - 120px);
}

/* Contenedor de filas */
.layout-rows-container {
    min-height: 200px;
}

/* Fila del layout */
.layout-row {
    background: white;
    border: 2px dashed #ced4da;
    border-radius: 6px;
    margin-bottom: 10px;
    padding: 8px;
    min-height: 60px;
    position: relative;
    transition: border-color 0.2s;
}

.layout-row:hover {
    border-color: #2196f3;
}

.layout-row.sortable-ghost {
    opacity: 0.4;
}

/* Header de la fila */
.layout-row-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
    padding: 2px 4px;
}

.layout-row-header .row-label {
    font-size: 0.7rem;
    color: #6c757d;
    font-weight: 600;
    text-transform: uppercase;
}

.layout-row-header .row-actions {
    display: flex;
    gap: 4px;
}

.layout-row-header .row-actions .btn {
    padding: 0 4px;
    font-size: 0.7rem;
    line-height: 1.4;
}

/* Grid de campos dentro de una fila */
.layout-row-fields {
    display: flex;
    flex-wrap: nowrap;
    gap: 6px;
    min-height: 44px;
    align-items: stretch;
}

/* Campo dentro del canvas */
.layout-field {
    background: linear-gradient(135deg, #e3f2fd 0%, #bbdefb 100%);
    border: 1px solid #90caf9;
    border-radius: 4px;
    padding: 6px 8px;
    position: relative;
    cursor: grab;
    min-height: 40px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    transition: all 0.15s;
    flex-shrink: 0;
}

.layout-field:hover {
    border-color: #1976d2;
    box-shadow: 0 2px 6px rgba(25, 118, 210, 0.2);
}

.layout-field:active {
    cursor: grabbing;
}

.layout-field.sortable-ghost {
    opacity: 0.4;
}

.layout-field .field-info {
    display: flex;
    align-items: center;
    gap: 4px;
}

.layout-field .field-info .field-code {
    font-weight: 700;
    font-size: 0.78rem;
    color: #1565c0;
}

.layout-field .field-info .field-title {
    font-size: 0.72rem;
    color: #555;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Controles del campo en el canvas */
.layout-field-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 4px;
    gap: 4px;
}

.layout-field-controls select {
    font-size: 0.7rem;
    padding: 1px 4px;
    height: 22px;
    border: 1px solid #90caf9;
    border-radius: 3px;
    background: white;
    color: #333;
    flex: 1;
    max-width: 90px;
}

.layout-field-controls .btn-remove-field {
    background: none;
    border: none;
    color: #e53935;
    cursor: pointer;
    padding: 0 2px;
    font-size: 0.75rem;
    line-height: 1;
    opacity: 0.6;
    transition: opacity 0.15s;
}

.layout-field-controls .btn-remove-field:hover {
    opacity: 1;
}

/* Sección separator */
.layout-section {
    background: linear-gradient(135deg, #fff3e0 0%, #ffe0b2 100%);
    border: 1px solid #ffb74d;
    border-radius: 4px;
    padding: 8px 12px;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.layout-section .section-title {
    font-weight: 600;
    color: #e65100;
    font-size: 0.85rem;
}

.layout-section .section-title i {
    margin-right: 6px;
}

.layout-section .btn-remove-section {
    background: none;
    border: none;
    color: #e53935;
    cursor: pointer;
    font-size: 0.8rem;
    opacity: 0.6;
}

.layout-section .btn-remove-section:hover {
    opacity: 1;
}

/* Drop zone visual */
.layout-row-fields.sortable-drag-over {
    background: #e8f5e9;
    border: 2px dashed #4caf50;
}

/* Fila vacía placeholder */
.layout-row-empty {
    color: #aaa;
    font-size: 0.8rem;
    text-align: center;
    padding: 10px;
    font-style: italic;
}

/* Preview panel */
.layout-editor-preview {
    width: 400px;
    min-width: 400px;
    background: #fff;
    border-left: 2px solid #dee2e6;
    overflow-y: auto;
    max-height: calc(100vh - 120px);
}

/* Responsive: en pantallas pequeñas apilar paneles */
@media (max-width: 992px) {
    .layout-editor-sidebar {
        width: 200px;
        min-width: 200px;
    }
    .layout-editor-preview {
        width: 300px;
        min-width: 300px;
    }
}

/* Indicador de ancho Bootstrap en el campo */
.layout-field-width-indicator {
    position: absolute;
    top: 2px;
    right: 6px;
    font-size: 0.6rem;
    color: #1565c0;
    font-weight: 700;
    opacity: 0.7;
}

/* Sortable placeholder */
.sortable-placeholder {
    background: #e8f5e9 !important;
    border: 2px dashed #4caf50 !important;
    border-radius: 4px;
    min-height: 40px;
}

