/**
 * Buscador CNAE 2025 - Estilos
 * Versión: 1.0.0
 */

/* ===================================
   VARIABLES CSS (Personalización fácil)
   =================================== */
:root {
    --cnae-primary: #2563eb;
    --cnae-primary-hover: #1d4ed8;
    --cnae-primary-light: #eff6ff;
    --cnae-secondary: #64748b;
    --cnae-success: #10b981;
    --cnae-warning: #f59e0b;
    --cnae-error: #ef4444;
    --cnae-text: #1a1a1a;
    --cnae-text-light: #666;
    --cnae-text-lighter: #6b7280;
    --cnae-border: #e0e0e0;
    --cnae-bg: #fff;
    --cnae-bg-light: #f9fafb;
    --cnae-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    --cnae-shadow-hover: 0 8px 30px rgba(0, 0, 0, 0.12);
    --cnae-radius: 12px;
    --cnae-radius-small: 8px;
    --cnae-transition: all 0.3s ease;
}

/* ===================================
   CONTENEDOR PRINCIPAL
   =================================== */
.cnae-search-container {
    max-width: 1200px;
    margin: 40px auto;
    padding: 0 20px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
}

.cnae-search-box {
    background: var(--cnae-bg);
    border-radius: var(--cnae-radius);
    padding: 40px;
    box-shadow: var(--cnae-shadow);
    transition: var(--cnae-transition);
}

.cnae-search-box:hover {
    box-shadow: var(--cnae-shadow-hover);
}

.cnae-search-box h2 {
    color: var(--cnae-text);
    font-size: 32px;
    margin: 0 0 10px 0;
    font-weight: 700;
    line-height: 1.2;
}

.cnae-search-box > p {
    color: var(--cnae-text-light);
    font-size: 16px;
    margin: 0 0 30px 0;
    line-height: 1.5;
}

/* ===================================
   FORMULARIO DE BÚSQUEDA
   =================================== */
#cnae-search-form {
    margin-bottom: 20px;
}

.search-input-group {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
    align-items: stretch;
}

#cnae-search-input {
    flex: 1;
    padding: 16px 20px;
    font-size: 16px;
    color: var(--cnae-text);
    border: 2px solid var(--cnae-border);
    border-radius: var(--cnae-radius-small);
    transition: var(--cnae-transition);
    background: var(--cnae-bg);
    font-family: inherit;
    outline: none;
}

#cnae-search-input:hover {
    border-color: var(--cnae-primary);
}

#cnae-search-input:focus {
    border-color: var(--cnae-primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

#cnae-search-input::placeholder {
    color: #999;
    font-style: italic;
}

.search-btn {
    padding: 16px 32px;
    /*background: #135BEE !important;*/
    color: var(--cnae-text) !important;
    border: 2px solid var(--cnae-border) !important;
    border-radius:  var(--cnae-radius) !important;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    /*display: flex;*/
    align-items: center;
    gap: 8px;
    transition: var(--cnae-transition) !important;
    white-space: nowrap;
    font-family: inherit;
	display:none !important;
}

.search-btn:hover, .search-btn:focus, [type=submit]:focus, button:focus {
    border-color: var(--cnae-primary) !important;
	background-color: #fff !important;
    transform: translateY(-2px) !important;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3) !important;
}

.search-btn:active {
    transform: translateY(0);
}

.search-btn .dashicons {
    font-size: 18px;
    width: 18px;
    height: 18px;
    line-height: 1;
}

/* ===================================
   FILTROS DE BÚSQUEDA
   =================================== */
.search-filters {
    display: flex;
    gap: 24px;
    flex-wrap: wrap;
    margin-bottom: 20px;
    padding-top: 10px;
}

.search-filters label {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--cnae-text-lighter);
    font-size: 14px;
    cursor: pointer;
    user-select: none;
    transition: color 0.2s ease;
}

.search-filters label:hover {
    color: var(--cnae-primary);
}

.search-filters input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--cnae-primary);
}

/* ===================================
   LOADING / SPINNER
   =================================== */
.cnae-loading {
    text-align: center;
    padding: 40px;
    color: var(--cnae-text-light);
    font-size: 16px;
}

.spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid var(--cnae-border);
    border-top-color: var(--cnae-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    vertical-align: middle;
    margin-right: 8px;
}

@keyframes spin {
    to { 
        transform: rotate(360deg); 
    }
}

/* ===================================
   ÁREA DE RESULTADOS
   =================================== */
.cnae-results {
    margin-top: 30px;
}

.results-count {
    color: var(--cnae-text-light);
    font-size: 14px;
    font-weight: 600;
    margin: 0 0 20px 0;
    padding-bottom: 15px;
    border-bottom: 2px solid var(--cnae-border);
}

.cnae-results-list {
    display: grid;
    gap: 16px;
}

/* ===================================
   ITEMS DE RESULTADO
   =================================== */
.cnae-result-item {
    background: var(--cnae-bg-light);
    border: 2px solid var(--cnae-border);
    border-radius: 10px;
    padding: 20px;
    transition: var(--cnae-transition);
    cursor: pointer;
    display: none; /* Se mostrará con fadeIn desde JS */
    position: relative;
    overflow: hidden;
}

.cnae-result-item::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: var(--cnae-primary);
    transform: scaleY(0);
    transition: transform 0.3s ease;
}

.cnae-result-item:hover {
    border-color: var(--cnae-primary);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.1);
    transform: translateY(-2px);
    background: var(--cnae-bg);
}

.cnae-result-item:hover::before {
    transform: scaleY(1);
}

.result-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    gap: 12px;
    flex-wrap: wrap;
}

/* ===================================
   CÓDIGO CNAE
   =================================== */
.result-codigo {
    font-size: 24px;
    font-weight: 700;
    color: var(--cnae-primary);
    font-family: 'Courier New', monospace;
    padding: 8px 16px;
    background: var(--cnae-primary-light);
    border-radius: 6px;
    cursor: pointer;
    position: relative;
    transition: all 0.2s ease;
    display: inline-block;
    line-height: 1;
}

.result-codigo:hover {
    background: #dbeafe;
    transform: scale(1.05);
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.2);
}

.result-codigo:active {
    transform: scale(0.98);
}

.result-codigo.copied-success {
    background: var(--cnae-success);
    color: var(--cnae-bg);
}

.result-codigo.copied-error {
    background: var(--cnae-error);
    color: var(--cnae-bg);
}

/* ===================================
   TOOLTIP DE COPIADO
   =================================== */
.copy-tooltip {
    position: absolute;
    top: -35px;
    left: 50%;
    transform: translateX(-50%);
    background: #1a1a1a;
    color: #fff;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    white-space: nowrap;
    pointer-events: none;
    z-index: 1000;
    display: none;
}

.copy-tooltip::after {
    content: '';
    position: absolute;
    bottom: -4px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 5px solid #1a1a1a;
}

/* ===================================
   VERSIONES CNAE
   =================================== */
.result-version {
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    line-height: 1;
}

.version-2025 {
    background: var(--cnae-success);
    color: var(--cnae-bg);
}

.version-2009 {
    background: var(--cnae-warning);
    color: var(--cnae-bg);
}

/* ===================================
   DESCRIPCIÓN
   =================================== */
.result-descripcion {
    font-size: 16px;
    color: var(--cnae-text);
    line-height: 1.6;
    margin-bottom: 12px;
    font-weight: 400;
}

/* Resaltar término de búsqueda */
.result-descripcion mark {
    background: #fef08a;
    color: inherit;
    padding: 2px 4px;
    border-radius: 3px;
    font-weight: 600;
}

/* ===================================
   METADATA
   =================================== */
.result-meta {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--cnae-border);
}

.meta-item {
    font-size: 13px;
    color: var(--cnae-text-lighter);
    background: var(--cnae-bg);
    padding: 6px 12px;
    border-radius: 6px;
    border: 1px solid var(--cnae-border);
    font-weight: 500;
}

.meta-item strong {
    font-weight: 600;
    color: var(--cnae-text);
}

/* ===================================
   EQUIVALENCIAS/RELACIONES
   =================================== */
.result-relations {
    margin-top: 12px;
    padding: 12px 16px;
    background: #fef3c7;
    border-left: 4px solid var(--cnae-warning);
    border-radius: 6px;
    font-size: 14px;
    color: #92400e;
    line-height: 1.5;
}

.result-relations strong {
    color: #78350f;
    font-weight: 600;
    margin-right: 6px;
}

/* ===================================
   MENSAJES (Error/Info)
   =================================== */
.cnae-error,
.cnae-info {
    padding: 16px 20px;
    border-radius: var(--cnae-radius-small);
    margin-top: 20px;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 12px;
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.cnae-error {
    background: #fee;
    border-left: 4px solid var(--cnae-error);
    color: #991b1b;
}

.cnae-info {
    background: var(--cnae-primary-light);
    border-left: 4px solid var(--cnae-primary);
    color: #1e40af;
}

.message-icon {
    font-size: 20px;
    line-height: 1;
}

.message-text {
    flex: 1;
    font-weight: 500;
}

.no-results {
    text-align: center;
    padding: 60px 20px;
    color: var(--cnae-text-lighter);
    font-size: 16px;
}

/* ===================================
   ESTADO EXPANDIDO (Opcional)
   =================================== */
.cnae-result-item.expanded {
    background: var(--cnae-bg);
    border-color: var(--cnae-primary);
    box-shadow: 0 6px 20px rgba(37, 99, 235, 0.15);
}

.cnae-result-item.expanded::before {
    transform: scaleY(1);
}

/* ===================================
   RESPONSIVE - TABLETS
   =================================== */
@media (max-width: 768px) {
    .cnae-search-container {
        margin: 20px auto;
        padding: 0 15px;
    }
    
    .cnae-search-box {
        padding: 24px;
    }
    
    .cnae-search-box h2 {
        font-size: 24px;
        margin-bottom: 8px;
    }
    
    .cnae-search-box > p {
        font-size: 14px;
        margin-bottom: 20px;
    }
    
    .search-input-group {
        flex-direction: column;
    }
    
    .search-btn {
        justify-content: center;
        width: 100%;
    }
    
    .result-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    
    .result-codigo {
        font-size: 20px;
        padding: 6px 12px;
    }
    
    .result-descripcion {
        font-size: 15px;
    }
    
    .result-meta {
        flex-direction: column;
        gap: 8px;
    }
    
    .meta-item {
        width: fit-content;
    }
}

/* ===================================
   RESPONSIVE - MÓVILES
   =================================== */
@media (max-width: 480px) {
    .cnae-search-box {
        padding: 20px;
        border-radius: 8px;
    }
    
    .cnae-search-box h2 {
        font-size: 22px;
    }
    
    #cnae-search-input {
        padding: 14px 16px;
        font-size: 15px;
    }
    
    .search-btn {
        padding: 14px 24px;
        font-size: 15px;
    }
    
    .search-filters {
        gap: 16px;
        font-size: 13px;
    }
    
    .cnae-result-item {
        padding: 16px;
    }
    
    .result-codigo {
        font-size: 18px;
    }
    
    .result-version {
        font-size: 11px;
        padding: 5px 10px;
    }
}

/* ===================================
   ANIMACIONES
   =================================== */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.cnae-result-item {
    animation: fadeInUp 0.4s ease forwards;
}

/* ===================================
   ACCESIBILIDAD
   =================================== */
.cnae-result-item:focus-within {
    outline: 2px solid var(--cnae-primary);
    outline-offset: 2px;
}

#cnae-search-input:focus-visible {
    outline: 2px solid var(--cnae-primary);
    outline-offset: 2px;
}

/* ===================================
   PRINT STYLES
   =================================== */
@media print {
    .cnae-search-box {
        box-shadow: none;
        border: 1px solid #ddd;
    }
    
    .search-input-group,
    .search-filters,
    .cnae-loading {
        display: none;
    }
    
    .cnae-result-item {
        break-inside: avoid;
        page-break-inside: avoid;
    }
}

/* ===================================
   DARK MODE (Opcional)
   =================================== */
@media (prefers-color-scheme: dark) {
    :root {
        --cnae-text: #f1f5f9;
        --cnae-text-light: #cbd5e1;
        --cnae-text-lighter: #94a3b8;
        --cnae-border: #334155;
        --cnae-bg: #1e293b;
        --cnae-bg-light: #0f172a;
    }
    
    .cnae-search-box {
        background: #1e293b;
    }
    
    #cnae-search-input {
        background: #0f172a;
        color: #f1f5f9;
    }
    
    .cnae-result-item {
        background: #0f172a;
        border-color: #334155;
    }
    
    .cnae-result-item:hover {
        background: #1e293b;
    }
}