@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

/* ============================================================================
   RESET Y ESTILOS BASE
   ============================================================================ */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: linear-gradient(135deg, #111827 0%, #1f2937 100%);
    height: 100vh;
    display: flex;
    flex-direction: column;
    color: #ffffff;
}

/* ============================================================================
   HEADER
   ============================================================================ */
.header {
    background: rgba(31, 41, 55, 0.95);
    backdrop-filter: blur(20px);
    padding: 0.7rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
    border-bottom: 2px solid #f97316;
}

.header h1 {
    font-size: 1.8rem;
    font-weight: 800;
    letter-spacing: -0.5px;
    text-shadow: 0 0 30px rgba(249, 115, 22, 0.5);
    display: flex;
    align-items: center;
}

.header h1::before {
    content: 'CSV HYPER FILTER';
    background: linear-gradient(135deg, #f97316 0%, #ea580c 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.filename-display {
    font-size: 0.9rem;
    color: #9ca3af !important;
    font-weight: 400;
    margin-left: 1rem;
    background: none !important;
    -webkit-text-fill-color: #9ca3af !important;
}

/* ============================================================================
   BOTONES DEL HEADER
   ============================================================================ */
.upload-btn {
    color: white;
    border: none;
    padding: 0.875rem 2rem;
    border-radius: 12px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
    font-family: 'Inter', sans-serif;
}

.upload-btn.no-file {
    background: linear-gradient(135deg, #3498db, #2980b9);
    box-shadow: 0 4px 15px rgba(52, 152, 219, 0.4);
}

.upload-btn.no-file::after {
    content: "";
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: rgba(255, 255, 255, 0.2);
    transform: rotate(45deg);
    animation: shine 3s infinite;
}

.upload-btn.no-file:hover {
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 6px 20px rgba(52, 152, 219, 0.6);
}

.upload-btn.file-loaded {
    background: linear-gradient(135deg, #f97316 0%, #ea580c 100%);
    box-shadow: 0 4px 15px rgba(249, 115, 22, 0.4);
}

.upload-btn.file-loaded:hover {
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 8px 25px rgba(249, 115, 22, 0.5);
}

.upload-btn:active {
    transform: translateY(0) scale(0.98);
}

@keyframes shine {
    0% {
        left: -100%;
    }

    100% {
        left: 100%;
    }
}

/* ============================================================================
   CUSTOM MODAL DE CONFIGURACIÓN "OUT OF 10"
   ============================================================================ */
.settings-btn {
    background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
    color: white;
    border: none;
    padding: 4px 8px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 11px;
    margin-right: 4px;
    transition: all 0.2s;
}

.settings-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.4);
}

.out-of-10-modal {
    background: #1f2937;
    border: 2px solid #374151;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.8);
    z-index: 10000;
    min-width: 240px;
    font-family: 'Inter', sans-serif;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 2px solid #374151;
    font-weight: 700;
    font-size: 14px;
    color: #f97316;
    background: #111827;
    border-radius: 12px 12px 0 0;
}

.modal-header i {
    margin-right: 6px;
}

.modal-close {
    background: none;
    border: none;
    font-size: 20px;
    color: #9ca3af;
    cursor: pointer;
    padding: 0;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    transition: all 0.2s;
}

.modal-close:hover {
    background: #ef4444;
    color: white;
}

.modal-content {
    padding: 16px;
    background: #1f2937;
    border-radius: 0 0 12px 12px;
}

.format-option {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 14px;
}

.format-option:last-child {
    margin-bottom: 0;
}

.format-option label {
    font-size: 13px;
    color: #d1d5db;
    font-weight: 600;
}

.format-option label i {
    margin-right: 6px;
    color: #f97316;
}

.toggle-separator {
    background: linear-gradient(135deg, #f97316 0%, #ea580c 100%);
    color: white;
    border: none;
    padding: 8px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 18px;
    font-weight: 700;
    min-width: 50px;
    transition: all 0.2s;
    box-shadow: 0 2px 8px rgba(249, 115, 22, 0.3);
}

.toggle-separator:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(249, 115, 22, 0.5);
}

.decimal-controls {
    display: flex;
    gap: 10px;
    align-items: center;
}

.decimal-controls button {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 700;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.3);
}

.decimal-controls button:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.5);
}

.decimal-controls button:disabled {
    background: #374151;
    cursor: not-allowed;
    opacity: 0.5;
    box-shadow: none;
}

.decimal-controls span {
    font-size: 18px;
    font-weight: 700;
    color: #ffffff;
    min-width: 24px;
    text-align: center;
}

/* ============================================================================
   BOTÓN SETTINGS EN ESQUINA SUPERIOR DERECHA DE LA COLUMNA /10
   ============================================================================ */
.settings-btn-corner-out10 {
    position: absolute;
    top: 2px;
    right: 2px;
    background: #4b5563;
    color: #9ca3af;
    border: none;
    padding: 4px 5px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.2s;
    z-index: 100;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.settings-btn-corner-out10:hover {
    background: #6b7280;
    color: #d1d5db;
    transform: translateY(-2px) scale(1.05);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

th:first-child {
    position: relative;
}

/* ============================================================================
   BOTÓN CLEAR/SELECT EN SEARCH INPUT
   ============================================================================ */
.clear-select-btn {
    position: absolute;
    top: 12px;
    right: 12px;
    background: #374151;
    color: #9ca3af;
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

.clear-select-btn:hover {
    background: #4b5563;
    color: #d1d5db;
    transform: scale(1.08);
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.4);
}

.clear-select-btn:active {
    transform: scale(0.95);
}

/* Ajuste para que el textarea tenga espacio para el botón */
textarea {
    padding-right: 55px !important;
}

/* ============================================================================
   CONTAINER PRINCIPAL
   ============================================================================ */
.container {
    display: flex;
    flex: 1;
    overflow: hidden;
    gap: 1.5rem;
    padding: 1.5rem;
}

/* ============================================================================
   PANELES (Filter Panel y Search Panel)
   ============================================================================ */
.panel {
    display: flex;
    flex-direction: column;
    background: #1f2937;
    border-radius: 20px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
    overflow: hidden;
    border: 1px solid #374151;
}

/* Panel izquierdo (Filter & Results) - MÁS ANCHO */
.panel:first-child {
    flex: 1.4;
    /* 58% del espacio disponible */
}

/* Panel derecho (Search Panel) - MÁS PEQUEÑO */
.panel:last-child {
    flex: 1;
    /* 42% del espacio disponible */
}

.panel-header {
    background: linear-gradient(135deg, #f97316 0%, #ea580c 100%);
    color: white;
    padding: 0.5rem 1.5rem;
    font-weight: 700;
    font-size: 1.1rem;
    letter-spacing: 0.5px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 4px 15px rgba(249, 115, 22, 0.3);
}

/* ============================================================================
   FILTER SECTION (Panel izquierdo)
   ============================================================================ */
.filter-icon-btn {
    background: rgba(255, 255, 255, 0.2);
    border: 2px solid white;
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.2rem;
    display: none;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
}

.filter-icon-btn:hover {
    background: white;
    color: #f97316;
    transform: rotate(180deg);
}

.filter-icon-btn.visible {
    display: flex;
}

.filter-section {
    padding: 1.5rem;
    border-bottom: 2px solid #374151;
    background: #111827;
}

.filter-header {
    font-weight: 700;
    margin-bottom: 1rem;
    color: #f97316;
    font-size: 1rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.filter-options {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.filter-option {
    position: relative;
}

.filter-checkbox {
    display: none;
}

.filter-label {
    display: inline-block;
    padding: 0.6rem 1.2rem;
    background: #1f2937;
    border: 2px solid #374151;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s;
    font-weight: 500;
    user-select: none;
    font-size: 0.9rem;
    color: #d1d5db;
}

.filter-label:hover {
    border-color: #f97316;
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(249, 115, 22, 0.3);
    color: #ffffff;
}

.filter-checkbox:checked+.filter-label {
    background: linear-gradient(135deg, #374151 0%, #4b5563 100%);
    color: white;
    border-color: #9ca3af;
    box-shadow: 0 4px 12px rgba(156, 163, 175, 0.3);
}

.filter-checkbox.auto-selected+.filter-label {
    background: linear-gradient(135deg, #f97316 0%, #ea580c 100%);
    color: white;
    border-color: #f97316;
    box-shadow: 0 6px 20px rgba(249, 115, 22, 0.5);
    pointer-events: none;
}

.go-btn {
    background: linear-gradient(135deg, #f39c12, #e74c3c);
    color: white;
    border: none;
    padding: 0.75rem 2rem;
    border-radius: 10px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    transition: all 0.3s;
    box-shadow: 0 4px 15px rgba(255, 133, 0, 0.4);
    display: inline-block;
    font-family: 'Inter', sans-serif;
    position: relative;
    overflow: hidden;
}

.go-btn::after {
    content: "";
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: rgba(255, 255, 255, 0.2);
    transform: rotate(45deg);
    animation: shine 3s infinite;
}

.go-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(255, 133, 0, 0.6);
}

.go-btn:active {
    transform: scale(0.95);
}

/* ============================================================================
   DATA GRID (Panel izquierdo)
   ============================================================================ */
.drop-zone {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100%;
    border: 3px dashed #374151;
    border-radius: 16px;
    transition: all 0.3s;
    cursor: pointer;
}

.drop-zone.dragover {
    border-color: #f97316;
    background: rgba(249, 115, 22, 0.1);
    box-shadow: 0 0 30px rgba(249, 115, 22, 0.3);
}

.drop-zone-content {
    text-align: center;
    color: #9ca3af;
}

.drop-zone-icon {
    font-size: 4rem;
    opacity: 0.3;
    margin-bottom: 1rem;
}

.drop-zone-text {
    font-size: 1.2rem;
    font-weight: 600;
    color: #d1d5db;
    margin-bottom: 0.5rem;
}

.drop-zone-subtext {
    font-size: 0.9rem;
    color: #9ca3af;
}

.data-grid {
    flex: 1;
    overflow: auto;
    padding: 0;
    background: #111827;
}

.empty-state {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    height: 100%;
    color: #9ca3af;
    font-size: 1.2rem;
    gap: 1rem;
}

.empty-state-icon {
    font-size: 4rem;
    opacity: 0.3;
}

/* ============================================================================
   TABLA (Data Grid)
   ============================================================================ */
table {
    border-collapse: collapse;
    width: max-content;
    min-width: 100%;
    table-layout: auto; /* Añade esto para que las columnas se ajusten al contenido */
}

th,
td {
    border: 1px solid #374151;
    padding: 0.875rem 1rem;
    text-align: left;
    white-space: nowrap;
    color: #ffffff;
    max-width: 400px; /* Añade un ancho máximo opcional */
    overflow: hidden;
    text-overflow: ellipsis;
}

th {
    background: #1f1f1f;
    color: #ffffff;
    position: sticky;
    top: 0;
    z-index: 10;
    font-weight: 600;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border: 1px solid #444;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    transition: box-shadow 0.2s, background 0.2s;
}

th.auto-detected {
    background: #2e2e2e;
    color: #ffffff;
    position: sticky; /* Asegura que también sea sticky */
    top: 0;
    z-index: 10;
}

th.auto-detected::after {
    content: '';
    margin-left: 0.5rem;
    font-size: 0.8rem;
}

/* Asegura que todas las celdas th con estilos inline también sean sticky */
th[style*="position: relative"] {
    position: sticky !important;
    top: 0;
    z-index: 10;
}

tr:nth-child(even) {
    background: #1f2937;
}

tr:hover {
    background: #374151;
}

.highlight-row {
    background: linear-gradient(90deg, rgba(249, 115, 22, 0.4) 0%, rgba(249, 115, 22, 0.1) 100%) !important;
    box-shadow: 0 0 0 2px #f97316 !important;
    animation: pulseHighlight 0.7s ease-in-out;
}

@keyframes pulseHighlight {
    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.01);
    }
}

.copy-btn {
    background: linear-gradient(135deg, #f97316 0%, #ea580c 100%);
    color: white;
    border: none;
    padding: 0.4rem 0.8rem;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    margin-left: 0.5rem;
    transition: all 0.3s;
    font-family: 'Inter', sans-serif;
}

.copy-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 15px rgba(249, 115, 22, 0.5);
}

/* ============================================================================
   STATS (Panel izquierdo - inferior)
   ============================================================================ */
.stats {
    padding: 1rem 1.5rem;
    background: #111827;
    border-top: 2px solid #374151;
    font-size: 0.9rem;
    color: #d1d5db;
    font-weight: 500;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}

.stats strong {
    color: #f97316;
    font-weight: 700;
}

.stats-info {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

#leftStats {
    justify-content: flex-start !important;
    gap: 0.5rem !important;
}

#leftStats i {
    margin-right: 0.25rem;
}

#leftStats strong {
    margin: 0 0.25rem;
}

/* ============================================================================
   SEARCH AREA (Panel derecho)
   ============================================================================ */
.search-area {
    display: flex;
    flex-direction: column;
    padding: 1.5rem;
    background: #111827;
    position: relative;
    height: 100%;
    overflow: hidden;
}

.textarea-wrapper {
    flex: 1;
    display: flex;
    position: relative;
    min-height: 0;
    overflow: hidden;
}

.line-numbers {
    width: 50px;
    padding: 1rem 0.75rem;
    background: #1f2937;
    border: 2px solid #374151;
    border-right: none;
    border-radius: 12px 0 0 12px;
    font-family: 'Courier New', monospace;
    font-size: 0.95rem;
    color: #9ca3af;
    text-align: right;
    user-select: none;
    line-height: 1.5;
    overflow-y: auto;
    overflow-x: hidden;
    flex-shrink: 0;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.line-numbers::-webkit-scrollbar {
    display: none;
}

textarea {
    flex: 1;
    border: 2px solid #374151;
    border-radius: 0 12px 12px 0;
    padding: 1rem;
    font-family: 'Courier New', monospace;
    font-size: 0.95rem;
    resize: none;
    transition: border-color 0.3s;
    background: #1f2937;
    color: #ffffff;
    line-height: 1.5;
    overflow-y: auto;
    overflow-x: auto;
    min-height: 0;
    white-space: pre; /* Añade esta línea */
    overflow-wrap: normal; /* Añade esta línea */
    word-wrap: normal; /* Añade esta línea */
}

textarea:focus {
    outline: none;
    border-color: #f97316;
    box-shadow: 0 0 0 3px rgba(249, 115, 22, 0.2);
}

textarea:disabled {
    background: #111827;
    cursor: not-allowed;
    color: #6b7280;
}

/* ============================================================================
   TOGGLE (Panel derecho - inferior)
   ============================================================================ */
.toggle-container {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.5rem 0;
}

.toggle-label {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
    user-select: none;
}

.toggle-label input[type="checkbox"] {
    position: relative;
    width: 50px;
    height: 26px;
    appearance: none;
    background: #374151;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s;
    border: 2px solid #4b5563;
}

.toggle-label input[type="checkbox"]:checked {
    background: linear-gradient(135deg, #f97316 0%, #ea580c 100%);
    border-color: #f97316;
}

.toggle-label input[type="checkbox"]::before {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: white;
    top: 2px;
    left: 2px;
    transition: all 0.3s;
}

.toggle-label input[type="checkbox"]:checked::before {
    left: 26px;
}

.toggle-text {
    font-weight: 600;
    color: #d1d5db;
    font-size: 0.9rem;
}

/* ============================================================================
   FOOTER
   ============================================================================ */
.footer {
    background: rgba(31, 41, 55, 0.95);
    backdrop-filter: blur(20px);
    padding: 0.75rem 2rem;
    display: flex;
    justify-content: center;
    align-items: center;
    border-top: 1px solid #374151;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.3);
}

.help-link {
    color: #9ca3af;
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 500;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.help-link:hover {
    color: #f97316;
    transform: translateY(-1px);
}

.help-link i {
    font-size: 1rem;
}

/* ============================================================================
   SCROLLBARS PERSONALIZADOS
   ============================================================================ */
::-webkit-scrollbar {
    width: 10px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #1f2937;
}

::-webkit-scrollbar-thumb {
    background: #374151;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #ea580c;
}

.line-numbers::-webkit-scrollbar,
textarea::-webkit-scrollbar {
    width: 8px;
}

.line-numbers::-webkit-scrollbar-track,
textarea::-webkit-scrollbar-track {
    background: #1f2937;
}

.line-numbers::-webkit-scrollbar-thumb,
textarea::-webkit-scrollbar-thumb {
    background: #374151;
    border-radius: 4px;
}

.line-numbers::-webkit-scrollbar-thumb:hover,
textarea::-webkit-scrollbar-thumb:hover {
    background: #4b5563;
}

/* ============================================================================
   NOTIFICACIONES Y ANIMACIONES
   ============================================================================ */
.copy-notification {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0);
    background: linear-gradient(135deg, #4ade80 0%, #22c55e 100%);
    color: white;
    padding: 2rem 3rem;
    border-radius: 20px;
    box-shadow: 0 10px 40px rgba(74, 222, 128, 0.5);
    font-size: 1.5rem;
    font-weight: 700;
    z-index: 1000;
    animation: popIn 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    pointer-events: none;
}

@keyframes popIn {
    0% {
        transform: translate(-50%, -50%) scale(0);
        opacity: 0;
    }

    50% {
        transform: translate(-50%, -50%) scale(1.1);
    }

    100% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
    }
}

@keyframes popOut {
    0% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
    }

    100% {
        transform: translate(-50%, -50%) scale(0);
        opacity: 0;
    }
}

.copy-notification.hide {
    animation: popOut 0.3s ease-out forwards;
}

/* ============================================================================
   ANIMACIÓN PARA NOT FOUND
   ============================================================================ */
.not-found-highlight {
    display: inline-block;
    animation: pulseNotFound 1.5s ease-in-out infinite;
    color: #ff3b3b !important;
    font-weight: 800 !important;
    text-shadow: 0 0 10px rgba(255, 59, 59, 0.5);
}

@keyframes pulseNotFound {
    0%, 100% {
        transform: scale(1);
        color: #ff3b3b;
    }
    50% {
        transform: scale(1.15);
        color: #ff0000;
    }
}

/* ============================================================================
   RESPONSIVE
   ============================================================================ */
@media (max-width: 1024px) {
    .container {
        flex-direction: column;
    }

    .panel:first-child,
    .panel:last-child {
        flex: 1;
    }
}