/* ========================================
   SEAT-EDITOR.CSS - Estilos del editor de layouts
   ======================================== */

/* ===== CONTENEDOR PRINCIPAL ===== */

.seat-layout-editor {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    padding: 20px;
    max-width: 1600px;
    margin: 0 auto;
    min-height: 80vh;
}

.editor-panel {
    border: 1px solid var(--color-border, #ddd);
    border-radius: 8px;
    padding: 20px;
    background: var(--color-surface, #fff);
    overflow-y: auto;
    max-height: 85vh;
}

.editor-left-panel {
    overflow-y: auto;
}

.editor-right-panel {
    position: sticky;
    top: 20px;
    align-self: start;
}

/* ===== TÍTULOS ===== */

.editor-title {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 20px;
    color: var(--color-text-primary, #111);
}

/* ===== CONTROLES GENERALES ===== */

.editor-controls {
    margin-bottom: 20px;
    padding: 15px;
    background: var(--color-bg-light, #f9f9f9);
    border-radius: 6px;
}

.editor-control-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.95rem;
    cursor: pointer;
    user-select: none;
}

.editor-control-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

/* ===== LISTA DE SECCIONES ===== */

.sections-list {
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin-bottom: 20px;
}

.section-item {
    border: 2px solid var(--color-border, #ddd);
    border-radius: 8px;
    padding: 15px;
    background: var(--color-surface, #fff);
    transition: border-color 0.2s;
}

.section-item:hover {
    border-color: var(--color-primary, #4f46e5);
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--color-border, #ddd);
}

.section-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--color-text-primary, #111);
}

.section-delete-btn {
    background: var(--color-danger, #ef4444);
    color: white;
    border: none;
    border-radius: 4px;
    padding: 6px 12px;
    cursor: pointer;
    font-size: 1rem;
    transition: background 0.2s;
}

.section-delete-btn:hover {
    background: var(--color-danger-dark, #dc2626);
}

.section-content {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.section-content label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 0.9rem;
    font-weight: 500;
}

.section-content input[type="number"],
.section-content input[type="text"] {
    padding: 8px 12px;
    border: 1px solid var(--color-border, #ddd);
    border-radius: 4px;
    font-size: 0.95rem;
    transition: border-color 0.2s;
}

.section-content input:focus {
    outline: none;
    border-color: var(--color-primary, #4f46e5);
}

/* ===== EDITOR DE FILAS DE ASIENTOS ===== */

.seats-section-editor {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.seat-row-editor {
    border: 1px solid var(--color-border-light, #e5e5e5);
    border-radius: 6px;
    padding: 12px;
    background: var(--color-bg-lighter, #fafafa);
}

.seat-row-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.seat-row-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--color-text-secondary, #555);
}

.seat-row-controls {
    display: flex;
    gap: 6px;
}

.seat-row-control-btn {
    background: var(--color-bg-light, #f0f0f0);
    border: 1px solid var(--color-border, #ddd);
    border-radius: 4px;
    padding: 4px 8px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.seat-row-control-btn:hover {
    background: var(--color-primary-light, #6366f1);
    color: white;
    border-color: var(--color-primary, #4f46e5);
}

.seat-row-control-delete {
    background: var(--color-danger-light, #fca5a5);
}

.seat-row-control-delete:hover {
    background: var(--color-danger, #ef4444);
    color: white;
}

/* ===== GRID DE POSICIONES ===== */

.seat-positions-grid {
    display: flex;
    flex-wrap: nowrap;
    gap: 8px;
    margin-bottom: 10px;
    overflow-x: auto;
    padding: 0 8px 8px 8px; /* Padding horizontal para ver el primer y último asiento completos */
}

/* Estilo de scrollbar para el grid de posiciones */
.seat-positions-grid::-webkit-scrollbar {
    height: 6px;
}

.seat-positions-grid::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.seat-positions-grid::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 3px;
}

.seat-positions-grid::-webkit-scrollbar-thumb:hover {
    background: #555;
}

.seat-position-cell {
    position: relative;
    display: flex;
    align-items: center;
    gap: 4px;
}

.seat-position-cell.focused {
    z-index: 10;
}

.seat-position-input {
    width: 60px;
    height: 50px;
    padding: 4px 6px;
    border: 2px solid var(--color-border, #ddd);
    border-radius: 4px;
    font-size: 0.85rem;
    text-align: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.seat-position-input:focus {
    outline: none;
    border-color: var(--color-primary, #4f46e5);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

/* Estilos según tipo de posición */

.seat-position-input[data-position-type="empty"] {
    background: #f5f5f5;
    color: #999;
    font-style: italic;
}

.seat-position-input[data-position-type="seat"] {
    background: #e0f2fe;
    border-color: #0284c7;
    font-weight: 600;
}

.seat-position-input[data-position-type="wc"],
.seat-position-input[data-position-type="luggage"],
.seat-position-input[data-position-type="table"],
.seat-position-input[data-position-type="pmr"],
.seat-position-input[data-position-type="wheelchair"] {
    background: #fef3c7;
    border-color: #f59e0b;
    font-weight: 600;
}

.seat-position-input[data-position-type="space"] {
    background: #e5e7eb;
    border-color: #6b7280;
}

.seat-position-delete {
    position: absolute;
    top: -6px;
    right: -6px;
    background: var(--color-danger, #ef4444);
    color: white;
    border: none;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
    display: none;
    transition: background 0.2s;
}

.seat-position-cell:hover .seat-position-delete {
    display: flex;
    align-items: center;
    justify-content: center;
}

.seat-position-delete:hover {
    background: var(--color-danger-dark, #dc2626);
}

/* ===== BOTONES DE AGREGAR ===== */

.seat-row-add-position,
.add-row-btn {
    background: var(--color-primary, #4f46e5);
    color: white;
    border: none;
    border-radius: 6px;
    padding: 10px 16px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: background 0.2s;
    width: 100%;
}

.seat-row-add-position:hover,
.add-row-btn:hover {
    background: var(--color-primary-dark, #4338ca);
}

/* ===== BOTONES DE ACCIÓN ===== */

.editor-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding-top: 20px;
    border-top: 2px solid var(--color-border, #ddd);
}

.editor-action-btn {
    background: var(--color-success, #10b981);
    color: white;
    border: none;
    border-radius: 6px;
    padding: 12px 20px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 500;
    transition: background 0.2s;
}

.editor-action-btn:hover {
    background: var(--color-success-dark, #059669);
}

.editor-action-btn-primary {
    background: var(--color-primary, #4f46e5);
    font-weight: 600;
}

.editor-action-btn-primary:hover {
    background: var(--color-primary-dark, #4338ca);
}

/* ===== VISTA PREVIA ===== */

.layout-preview {
    position: sticky;
    top: 0;
}

.layout-preview-title {
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 15px;
    text-align: center;
    color: var(--color-text-primary, #111);
}

.layout-preview-coach {
    border: 2px solid var(--color-border, #ddd);
    border-radius: 8px;
    padding: 20px;
    background: var(--color-bg-lighter, #fafafa);
    min-height: 400px;
    max-height: 70vh;
    overflow-y: auto;
}

.layout-preview-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 200px;
    color: var(--color-text-tertiary, #999);
    font-style: italic;
}

/* Estilos de elementos en vista previa */

.layout-preview-coach .seat {
    margin: 4px;
    padding: 10px 14px;
    font-size: 0.9rem;
}

.layout-preview-coach .seat-row {
    display: flex;
    justify-content: center;
    gap: 4px;
    margin-bottom: 8px;
}

.layout-preview-coach .seat-empty {
    width: 48px;
    height: 48px;
    margin: 4px;
    background: transparent;
    border: 2px dashed #ddd;
    border-radius: 4px;
}

.layout-preview-coach .space {
    width: 100%;
    background: repeating-linear-gradient(
        90deg,
        transparent,
        transparent 10px,
        #e5e5e5 10px,
        #e5e5e5 20px
    );
    border-radius: 4px;
    margin: 10px 0;
}

.layout-preview-coach .door-space {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin: 10px 0;
}

.layout-preview-coach .pmr-bathroom {
    width: 100%;
    margin: 10px 0;
}

/* ===== PALETA DE ELEMENTOS ===== */

.element-palette {
    margin-bottom: 20px;
    padding: 15px;
    border: 1px solid var(--color-border, #ddd);
    border-radius: 8px;
    background: var(--color-surface, #fff);
}

.element-palette-title {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 12px;
    color: var(--color-text-primary, #111);
}

.element-palette-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 10px;
}

.element-palette-button {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 12px 8px;
    background: var(--color-bg-light, #f9f9f9);
    border: 2px solid var(--color-border, #ddd);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.element-palette-button:hover {
    background: var(--color-primary-light, #eef2ff);
    border-color: var(--color-primary, #4f46e5);
    transform: translateY(-2px);
}

.element-palette-icon {
    font-size: 1.5rem;
}

.element-palette-label {
    font-size: 0.8rem;
    font-weight: 500;
    text-align: center;
    color: var(--color-text-secondary, #555);
}

/* ===== RESPONSIVE ===== */

@media (max-width: 1024px) {
    .seat-layout-editor {
        grid-template-columns: 1fr;
    }

    .editor-right-panel {
        position: static;
    }

    .layout-preview-coach {
        max-height: 50vh;
    }
}

@media (max-width: 640px) {
    .seat-layout-editor {
        padding: 10px;
        gap: 15px;
    }

    .editor-panel {
        padding: 15px;
    }

    .seat-positions-grid {
        /* Removido justify-content: center para que el scroll funcione correctamente */
        padding: 0 12px 8px 12px; /* Aumentado padding horizontal en móvil */
    }

    .element-palette-grid {
        grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    }
}

/* ===== MODO OSCURO ===== */

body.dark-mode .editor-panel,
body.dark-mode .section-item,
body.dark-mode .seat-row-editor,
body.dark-mode .element-palette {
    background: var(--color-dark-surface, #1f2937);
    border-color: var(--color-dark-border, #374151);
}

body.dark-mode .editor-controls,
body.dark-mode .seat-row-editor {
    background: var(--color-dark-bg-lighter, #111827);
}

body.dark-mode .editor-title,
body.dark-mode .section-title,
body.dark-mode .layout-preview-title {
    color: var(--color-dark-text, #f9fafb);
}

body.dark-mode .seat-position-input {
    background: var(--color-dark-input-bg, #374151);
    border-color: var(--color-dark-border, #4b5563);
    color: var(--color-dark-text, #f9fafb);
}

body.dark-mode .seat-position-input:focus {
    border-color: var(--color-primary, #4f46e5);
}

body.dark-mode .layout-preview-coach {
    background: var(--color-dark-bg-lighter, #111827);
    border-color: var(--color-dark-border, #374151);
}

body.dark-mode .seat-empty {
    border-color: var(--color-dark-border, #4b5563);
}
