﻿/* styles.css - Estilos corregidos para el árbol jerárquico */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f5f5f5;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

header {
    background: #2c3e50;
    color: white;
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

header h1 {
    font-size: 24px;
    font-weight: 300;
}

.company-info {
    display: flex;
    align-items: center;
    gap: 15px;
}

.status-ok {
    color: #27ae60;
    font-weight: 500;
}

.status-error {
    color: #e74c3c;
    font-weight: 500;
}

.filters-section {
    background: white;
    padding: 25px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    margin-bottom: 20px;
}

.filter-form .form-row {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

.form-group {
    flex: 1;
    min-width: 200px;
}

.form-group.full-width {
    flex: 1 0 100%;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    color: #555;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
}

.form-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s ease;
}

.btn-primary {
    background: #3498db;
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background: #2980b9;
}

.btn-secondary {
    background: #95a5a6;
    color: white;
}

.btn-secondary:hover:not(:disabled) {
    background: #7f8c8d;
}

.btn:disabled {
    background: #bdc3c7;
    cursor: not-allowed;
}

.btn-success {
    background: #27ae60;
    color: white;
}

.btn-success:hover {
    background: #219a52;
}

.btn-small {
    padding: 6px 12px;
    font-size: 12px;
    margin-right: 10px;
    background: #6c757d;
    color: white;
}

.btn-small:hover {
    background: #5a6268;
}

.loading {
    text-align: center;
    padding: 40px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.spinner {
    border: 4px solid #f3f3f3;
    border-top: 4px solid #3498db;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.hidden {
    display: none !important;
}

.results-section {
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    overflow: hidden;
}

.results-header {
    padding: 20px;
    background: #ecf0f1;
    border-bottom: 1px solid #bdc3c7;
}

.results-header h2 {
    margin-bottom: 10px;
    color: #2c3e50;
}

.periodo-info {
    display: flex;
    gap: 20px;
    color: #7f8c8d;
    font-size: 14px;
}

.table-container {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th,
.data-table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid #ecf0f1;
}

.data-table th {
    background: #34495e;
    color: white;
    font-weight: 500;
    position: sticky;
    top: 0;
}

.data-table tbody tr:hover {
    background: #f8f9fa;
}

.data-table input[type="number"],
.data-table input[type="text"] {
    width: 100%;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
}

.data-table input[type="number"]:focus,
.data-table input[type="text"]:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.2);
}

.cell-valid {
    background: #d5f4e6;
    font-weight: bold;
    color: #27ae60;
}

.cell-invalid {
    background: #fadbd8;
    font-weight: bold;
    color: #e74c3c;
}

.btn-guardar {
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    padding: 5px;
    border-radius: 4px;
    transition: background 0.3s ease;
}

.btn-guardar:hover:not(:disabled) {
    background: #ecf0f1;
}

.btn-guardar:disabled {
    color: #bdc3c7;
    cursor: not-allowed;
}

.btn-guardar.guardado {
    color: #27ae60;
}

.validation-summary {
    padding: 15px 20px;
    background: #f8f9fa;
    border-top: 1px solid #dee2e6;
}

.error-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.error-message {
    background: white;
    padding: 30px;
    border-radius: 8px;
    max-width: 500px;
    width: 90%;
    text-align: center;
}

.error-message h3 {
    color: #e74c3c;
    margin-bottom: 15px;
}

/* Estilos para el árbol de departamentos - CORREGIDOS */
.departamentos-tree {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    padding: 20px;
    margin-top: 10px;
}

.departamentos-tree h3 {
    margin-bottom: 15px;
    color: #2c3e50;
    font-size: 16px;
    border-bottom: 1px solid #dee2e6;
    padding-bottom: 10px;
}

.tree-controls {
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid #dee2e6;
}

.arbol-departamentos {
    max-height: 400px;
    overflow-y: auto;
    border: 1px solid #e9ecef;
    border-radius: 4px;
    padding: 15px;
    background: white;
}

.dept-item {
    margin-bottom: 5px;
    transition: all 0.2s ease;
}

.dept-label {
    display: flex;
    align-items: center;
    cursor: pointer;
    padding: 8px 12px;
    border-radius: 4px;
    transition: background-color 0.2s;
    border: 1px solid transparent;
}

.dept-label:hover {
    background: #e9ecef;
    border-color: #dee2e6;
}

.dept-label.dept-selected {
    background: #d1ecf1;
    border-color: #bee5eb;
}

.dept-checkbox {
    margin-right: 10px;
    transform: scale(1.1);
}

.dept-icon {
    margin-right: 8px;
    font-size: 14px;
}

.dept-name {
    font-size: 14px;
    color: #495057;
    font-weight: 500;
}

/* Indicadores visuales para niveles */
.dept-item[style*="padding-left: 0px"] {
    border-left: 3px solid #3498db;
}

.dept-item[style*="padding-left: 25px"] {
    border-left: 3px solid #27ae60;
}

.dept-item[style*="padding-left: 50px"] {
    border-left: 3px solid #e74c3c;
}

.dept-item[style*="padding-left: 75px"] {
    border-left: 3px solid #f39c12;
}

.loading-text {
    text-align: center;
    color: #6c757d;
    font-style: italic;
    padding: 20px;
}

/* Scroll personalizado */
.arbol-departamentos::-webkit-scrollbar {
    width: 8px;
}

.arbol-departamentos::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.arbol-departamentos::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

.arbol-departamentos::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* Estilos para impresión */
@media print {
    .filters-section,
    .form-actions,
    .btn-guardar,
    .validation-summary {
        display: none !important;
    }
    
    header {
        background: white !important;
        color: black !important;
        border-bottom: 2px solid #000;
    }
    
    .data-table input {
        border: none !important;
        background: transparent !important;
        box-shadow: none !important;
    }
    
    .container {
        max-width: none;
        padding: 0;
    }
    
    .results-section {
        box-shadow: none;
    }
}

/* Responsive */
@media (max-width: 768px) {
    .container {
        padding: 10px;
    }
    
    .form-row {
        flex-direction: column;
    }
    
    .form-group {
        min-width: 100%;
    }
    
    .data-table {
        font-size: 12px;
    }
    
    .data-table th,
    .data-table td {
        padding: 8px 4px;
    }
    
    .departamentos-tree {
        padding: 15px;
    }
    
    .arbol-departamentos {
        max-height: 300px;
    }
    
    .dept-label {
        padding: 6px 8px;
    }
    
    .dept-name {
        font-size: 13px;
    }
}