/* ========================================================================== */
/* 1. ESTILOS GLOBALES Y RESET */
/* ========================================================================== */

* {
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    margin: 0;
    padding: 20px;
    /* VERDE NATURAL */
    background: linear-gradient(135deg, #fff 0%, #fff 100%);
}

.container {
    max-width: 85%;
    margin: 0 auto;
    background: rgba(255, 255, 255, 0.95);
    padding: 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

h1 {
    color: #2c3e50;
    text-align: center;
    margin-bottom: 8px;
    font-weight: 700;
    font-size: 2.5rem;
    background: linear-gradient(135deg, #3498db, #2c3e50);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.subtitle {
    text-align: center;
    color: #6c757d;
    margin-bottom: 30px;
    font-size: 1.1rem;
    font-weight: 400;
}


/* ========================================================================== */
/* 2. ESTRUCTURA: ENCABEZADO Y PIE DE PÁGINA */
/* ========================================================================== */

/* Encabezado */
.site-header {
    max-width: 85%;
    background-color: #eee;
    color: #fff;
    padding: 15px 20px;
    margin: auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
    border-radius: 12px 12px 0 0;
}

.site-header .logo h1 {
    margin: 0;
    font-size: 1.3rem;
}

.site-header .header-nav a {
    color: #088;
    text-decoration: none;
    margin-left: 15px;
    font-size: 0.95rem;
    transition: color 0.2s;
}

.site-header .header-nav a:hover {
    color: #055;
}

/* Footer */
.site-footer {
    max-width: 85%;
    background-color: #088;
    color: #fff;
    padding: 15px 20px;
    margin: auto;
    box-shadow: 0 -2px 8px rgba(0,0,0,0.2);
    border-radius: 0 0 12px 12px;
}

.site-footer .footer-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
}

.site-footer p {
    margin: 0;
    font-size: 0.9rem;
}

.site-footer .footer-nav a {
    color: #fff;
    text-decoration: none;
    margin-left: 15px;
    font-size: 0.9rem;
    transition: color 0.2s;
}

.site-footer .footer-nav a:hover {
    color: #ccf;
}


/* ========================================================================== */
/* 3. MENÚ LATERAL (menu_lateral) */
/* ========================================================================== */

/* Barra lateral */
.sidebar {
    width: 250px;
    background: linear-gradient(135deg, #4794b2ff 0%, #2c6a8cff 100%); /* Gradiente */
    color: white;
    position: fixed;
    top: 0;
    right: 0;
    height: 100%;
    overflow-y: auto;
    padding: 20px;
    box-shadow: -2px 0 5px rgba(0, 0, 0, 0.5);
    transform: translateX(100%);
    transition: transform 0.3s ease;
    z-index: 1000;
}

.sidebar.open {
    transform: translateX(0);
}

.sidebar h2 {
    margin-top: 0;
    font-size: 24px;
}

/* Estilo de los enlaces en la barra lateral */
.sidebar nav {
    display: flex;
    flex-direction: column;
    margin-top: 20px;
}

.sidebar a {
    display: flex;
    align-items: center;
    color: white;
    font-weight: bold;
    text-decoration: none;
    margin: 5px 0;
    padding: 10px;
    transition: all 0.3s ease;
    border-radius: 5px;
    background: rgba(255, 255, 255, 0.1); /* Fondo sutil */
}

.sidebar a:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateX(5px);
}

.sidebar nav img {
    margin-right: 10px;
    width: 16px;
    height: 16px;
    filter: invert(1); /* Para iconos blancos */
}

/* Botón de alternancia */
.toggle-btn {
    position: fixed;
    top: 20px;
    right: 20px;
    background: linear-gradient(135deg, #4794b2 0%, #2c6a8c 100%);
    color: white;
    border: none;
    border-radius: 5px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 1001;
    font-size: 18px;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.toggle-btn:hover {
    background: linear-gradient(135deg, #5aa8c7cc 0%, #3a7ba6cc 100%); /* Gradiente más claro al hover */
    transform: scale(1.1);
}

/* CORRECCIÓN: Cuando el sidebar está abierto, mover el botón */
.sidebar.open ~ .toggle-btn {
    right: 270px;
}


/* ========================================================================== */
/* 4. COMPONENTES DE INTERFAZ: INPUTS, BOTONES, OPCIONES Y BANNERS */
/* ========================================================================== */

/* Seguridad y Privacidad */
.privacy-notice {
    background: #e8f5e9;
    border: 1px solid #4caf50;
    border-radius: 8px;
    padding: 15px;
    margin: 15px 0;
    font-size: 14px;
}

.privacy-notice h3 {
    margin: 0 0 8px 0;
    color: #2e7d32;
}

.security-banner {
    display: flex;
    align-items: center;
    background: aliceblue;
    border-radius: 8px;
    padding: 12px;
    margin: 15px 0;
}

.security-icon {
    font-size: 24px;
    margin-right: 15px;
}

.security-text {
    font-size: 14px;
    line-height: 1.4;
}

/* Área de entrada de datos */
.input-section {
    margin-bottom: 25px;
}

textarea {
    width: 100%;
    height: 220px;
    padding: 15px;
    border-radius: 8px;
    border: 2px solid #aaa;
    background-color: #f8f9fa;
    font-family: 'Courier New', monospace;
    font-size: 14px;
    resize: vertical;
    transition: all 0.3s ease;
    box-sizing: border-box;
}

textarea:focus {
    outline: none;
    border-color: #3498db;
    background-color: white;
    box-shadow: 0 0 0 0.2rem rgba(52, 152, 219, 0.25);
}

/* Controles */
.controls {
    margin: 20px 0;
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

/* Botones */
button {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s ease;
    font-size: 14px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.btn-primary {
    background: linear-gradient(135deg, #3498db, #2980b9);
    color: white;
}

.btn-primary:hover {
    background: linear-gradient(135deg, #2980b9, #2573a7);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(52, 152, 219, 0.3);
}

.btn-secondary {
    background: linear-gradient(135deg, #6c757d, #5a6268);
    color: white;
}

.btn-secondary:hover {
    background: linear-gradient(135deg, #5a6268, #495057);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(108, 117, 125, 0.3);
}

.btn-success {
    background: linear-gradient(135deg, #28a745, #218838);
    color: white;
}

.btn-success:hover {
    background: linear-gradient(135deg, #218838, #1e7e34);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(40, 167, 69, 0.3);
}

button:active {
    transform: translateY(0);
}

/* Configuración General (usado en todas las páginas de conversión) */
.options {
    background: linear-gradient(135deg, #eee, #eee);
    padding: 20px;
    border-radius: 12px;
    border-left: 4px solid #9c27b0;
    box-shadow: 0 4px 6px rgba(156, 39, 176, 0.1);
    margin: 20px 0;
}

.options h3 {
    color: #2c3e50;
    margin-bottom: 15px;
    font-weight: 600;
    font-size: 1.2rem;
}

.option-group {
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    gap: 15px;
}

label {
    font-weight: 600;
    color: #495057;
}

select {
    padding: 10px 15px;
    border: 2px solid #e9ecef;
    border-radius: 6px;
    background: white;
    font-size: 14px;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    flex: 1;
}

select:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 0.2rem rgba(52, 152, 219, 0.25);
}

select:hover {
    border-color: #adb5bd;
}

/* Resultados */
.results {
    margin-top: 25px;
}

.preview-info {
    background: linear-gradient(135deg, #fff3cd, #ffeaa7);
    padding: 12px 20px;
    border-radius: 8px;
    margin-bottom: 20px;
    border-left: 4px solid #ffc107;
    font-size: 14px;
    color: #856404;
    box-shadow: 0 2px 4px rgba(255, 193, 7, 0.1);
}

/* Estadísticas de Archivo (Usado en todas las páginas) */
.statistics {
    display: flex;
    gap: 20px;
    margin: 25px 0;
    flex-wrap: wrap;
}

.statistics-item {
    flex: 1;
    min-width: 300px;
    background: white;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    border-top: 4px solid #3498db;
}

.statistics-item h3 {
    color: #2c3e50;
    margin-bottom: 15px;
    font-weight: 600;
    border-bottom: 2px solid #f8f9fa;
    padding-bottom: 10px;
}

.statistics-item p {
    margin: 8px 0;
    color: #495057;
}

.statistics-item p span {
    font-weight: bold;
    color: #2c3e50;
}


/* ========================================================================== */
/* 5. ESTILOS DE TABLA DE VISTA PREVIA (Compartido y Extendido en CSV Editor) */
/* ========================================================================== */

.table-container {
    width: 100%;
    overflow-x: auto;
    margin: 20px 0;
    border: 1px solid #dee2e6;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
    background: white;
}

.preview-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 600px;
    font-size: 14px;
}

.preview-table th {
    background: linear-gradient(135deg, #3498db, #2980b9);
    color: white;
    padding: 15px;
    text-align: left;
    font-weight: 600;
    position: sticky;
    top: 0;
    white-space: nowrap;
    border-bottom: 2px solid #dee2e6;
}

/* Estilos de drag-and-drop (Específicos de CSV Editor) */
.preview-table th {
    cursor: move;
    user-select: none;
}

.preview-table th input[type="checkbox"] {
    margin-right: 8px;
    transform: scale(1.2);
}

.preview-table th.dragging {
    opacity: 0.5;
    background: linear-gradient(135deg, #2980b9, #2573a7);
}

.preview-table th.over {
    border: 2px dashed #ffc107;
}
/* Fin estilos de drag-and-drop */

.preview-table td {
    padding: 12px 15px;
    border-bottom: 1px solid #dee2e6;
    white-space: nowrap;
    color: #495057;
}

.preview-table tr:nth-child(even) {
    background: #f8f9fa;
}

.preview-table tr:hover {
    background: #e3f2fd;
    transition: background-color 0.2s ease;
}


/* ========================================================================== */
/* 6. ESTILOS ESPECÍFICOS DE CSV EDITOR (csveditor) */
/* ========================================================================== */

/* Controles de tabla */
.table-controls {
    display: flex;
    gap: 15px;
    margin: 20px 0;
    flex-wrap: wrap;
}

/* Búsqueda */
.search-section {
    margin: 20px 0;
}

.search-input {
    width: 100%;
    padding: 12px 20px;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    font-size: 16px;
    transition: all 0.3s ease;
    box-sizing: border-box;
}

.search-input:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 0.2rem rgba(52, 152, 219, 0.25);
}

/* Switch Modo Avanzado */
.mode-switcher {
    display: flex;
    align-items: center;
    gap: 15px;
    margin: 20px 0;
    padding: 15px;
    background: linear-gradient(135deg, #e3f2fd, #bbdefb);
    border-radius: 10px;
    border-left: 4px solid #2196f3;
}

.switch {
    position: relative;
    display: inline-block;
    width: 60px;
    height: 34px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .4s;
    border-radius: 34px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 26px;
    width: 26px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

input:checked + .slider {
    background: linear-gradient(135deg, #3498db, #2980b9);
}

input:checked + .slider:before {
    transform: translateX(26px);
}

/* Sección avanzada */
.advanced-section {
    background: linear-gradient(135deg, #fff3cd, #ffeaa7);
    padding: 20px;
    border-radius: 12px;
    margin: 20px 0;
    border-left: 4px solid #ffc107;
}

.advanced-section h3 {
    margin-top: 0;
    color: #856404;
}

.filters-section, .sort-section {
    margin: 15px 0;
}

.filters-section h4, .sort-section h4 {
    margin-bottom: 10px;
    color: #856404;
}

.quick-filter {
    display: inline-block;
    margin: 5px 10px 5px 0;
    padding: 8px 12px;
    background: white;
    border: 1px solid #ddd;
    border-radius: 20px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.3s;
}

.quick-filter:hover {
    background: #e9ecef;
}

.quick-filter.active {
    background: #3498db;
    color: white;
    border-color: #3498db;
}

/* ========================================================================== */
/* 7. ESTILOS DE CONVERSIÓN (CSV <-> JSON) */
/* ========================================================================== */

/* Detección y Configuración (Común para csvjson y jsoncsv) */
.detection-config-container {
    display: flex;
    gap: 20px;
    margin: 25px 0;
    flex-wrap: wrap;
}

.detection-info, .detection-config-container .options {
    flex: 1;
    min-width: 300px;
    margin: 0; /* Anula el margin general de .options */
}

.detection-info {
    background: linear-gradient(135deg, #eee, #fff);
    padding: 20px;
    border-radius: 12px;
    border-left: 4px solid #2196f3;
    box-shadow: 0 4px 6px rgba(33, 150, 243, 0.1);
}

.detection-info h3 {
    color: #2c3e50;
    margin-bottom: 15px;
    font-weight: 600;
    font-size: 1.2rem;
}

/* Estadísticas de columnas vacías / Advertencia (Común para csvjson y jsoncsv) */
.empty-columns-info {
    background: linear-gradient(135deg, #f8d7da, #f5c6cb);
    padding: 12px 20px;
    border-radius: 8px;
    margin: 15px 0;
    border-left: 4px solid #dc3545;
    font-size: 14px;
    color: #721c24;
    box-shadow: 0 2px 4px rgba(220, 53, 69, 0.1);
}

.empty-columns-info.warning {
    background: linear-gradient(135deg, #fff3cd, #ffeaa7);
    border-left: 4px solid #ffc107;
    color: #856404;
}

/* Salida JSON (Específico de CSV a JSON) */
.json-output {
    background: linear-gradient(135deg, #f8f9fa, #e9ecef);
    color: #495057;
    padding: 20px;
    border-radius: 12px;
    font-family: 'Courier New', monospace;
    white-space: pre-wrap;
    max-height: 400px;
    overflow-y: auto;
    margin-bottom: 20px;
    font-size: 14px;
    border: 1px solid #dee2e6;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
}

/* Scrollbar personalizado para JSON */
.json-output::-webkit-scrollbar {
    width: 8px;
}

.json-output::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.json-output::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

.json-output::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* Salida CSV (Específico de JSON a CSV) */
.csv-output {
    background: linear-gradient(135deg, #f8f9fa, #e9ecef);
    color: #495057;
    padding: 20px;
    border-radius: 12px;
    font-family: 'Courier New', monospace;
    white-space: pre-wrap;
    max-height: 400px;
    overflow-y: auto;
    margin-bottom: 20px;
    font-size: 14px;
    border: 1px solid #dee2e6;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
}


/* ========================================================================== */
/* 8. RESPONSIVE (MEDIA QUERIES) */
/* ========================================================================== */

@media (max-width: 768px) {
    /* Estilos generales */
    body {
        padding: 10px;
    }
    
    .container {
        padding: 20px;
        border-radius: 10px;
    }
    
    h1 {
        font-size: 2rem;
    }
    
    /* Controles y Opciones */
    .controls, .table-controls, .statistics, .detection-config-container {
        flex-direction: column;
        gap: 15px;
    }
    
    button {
        width: 100%;
        margin-bottom: 8px;
    }
    
    .statistics-item, .detection-info, .detection-config-container .options {
        min-width: 100%;
    }
    
    .option-group {
        flex-direction: column;
        align-items: flex-start;
    }
    
    label {
        min-width: auto;
        margin-bottom: 5px;
    }
    
    select {
        width: 100%;
    }
    
    /* Tabla */
    .table-container {
        font-size: 12px;
    }
    
    .preview-table th,
    .preview-table td {
        padding: 10px 12px;
    }
    
    /* Específico del Menú Lateral (menu_lateral) */
    .toggle-btn {
        width: 40px;
        height: 40px;
        font-size: 16px;
        top: 10px;
        right: 10px;
    }
    
    /* Ajustar posición del botón cuando está abierto */
    .sidebar.open ~ .toggle-btn {
        right: 290px;
    }
    
    .sidebar {
        width: 280px;
        padding: 15px;
    }
    
    /* Específico de Conversión (csvjson / jsoncsv) */
    .json-output, .csv-output {
        max-height: 300px;
        font-size: 12px;
        border-radius: 8px;
    }
}
