/* styles.css — GIABot Web Frontend */

/* === Design tokens === */
:root {
    --color-primary: #043249;       /* Azul corporativo oscuro */
    --color-primary-light: #064e6b; /* Azul corporativo gradiente */
    --color-primary-hover: #065a75; /* Azul hover */
    --color-secondary: #ab182b;     /* Rojo corporativo */
    --color-secondary-hover: #8f141e;
    --color-accent: #4fc3f7;        /* Cyan accent */
    --color-ai: #667eea;            /* Púrpura búsqueda IA */
    --color-warning: #e53e3e;       /* Rojo filtros activos */
    --color-muted: #718096;         /* Gris texto secundario */
    --color-bg: #ffffff;
    --color-border: #e0e0e0;
    --color-border-light: #f0f0f0;
    --color-text: #333;
    --color-text-light: #666;
    --font-main: 'Oswald', sans-serif;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: var(--font-main);
}

body {
    background: var(--color-bg);
    min-height: 100vh;
    padding: 0;
    margin: 0;
}

/* Ocultar contenido hasta que Oswald cargue (evita FOUT) */
body.fonts-loading { opacity: 0; }
body.fonts-ready { opacity: 1; transition: opacity 0.1s; }

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

/* --- NUEVO: Estilos Buscador RAG --- */
.search-section {
    margin-bottom: 20px;
    background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-light) 100%);
    padding: 28px 20px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    text-align: center;
    color: white;
}

.rag-container {
    max-width: 800px;
    margin: 0 auto;
}

.rag-header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-bottom: 15px;
    font-weight: 500;
    text-transform: uppercase;
    font-size: 0.9em;
    letter-spacing: 1px;
    opacity: 0.9;
}

.rag-header i { color: var(--color-accent); }

.rag-input-group {
    display: flex;
    gap: 0; /* Sin gap, el botón pega con el input */
    background: white;
    padding: 4px;
    border-radius: 50px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255,255,255,0.1);
    transition: transform 0.2s;
}

.rag-input-group:focus-within {
    transform: scale(1.01);
    box-shadow: 0 6px 15px rgba(0, 0, 0, 0.25);
}

#rag-search-input {
    flex-grow: 1;
    border: none;
    padding: 12px 25px;
    font-size: 1.1rem;
    border-radius: 50px 0 0 50px;
    outline: none;
    background: transparent;
    color: #333;
}

#btn-rag-search {
    background: linear-gradient(90deg, var(--color-secondary) 0%, #c41c35 100%);
    color: white;
    border: none;
    padding: 0 30px;
    border-radius: 50px;
    font-weight: 600;
    cursor: pointer;
    font-size: 1rem;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: background 0.3s;
}

#btn-rag-search:hover {
    background: linear-gradient(90deg, var(--color-secondary-hover) 0%, #a6172a 100%);
}

.rag-hint {
    margin-top: 12px;
    font-size: 0.85rem;
    color: rgba(255,255,255,0.7);
    font-style: italic;
    font-weight: 300;
}

/* --- NUEVO: Estilos Filtros Modernos --- */
.filters-section {
    background: white;
    border: 1px solid var(--color-border-light);
    border-radius: 8px;
    padding: 16px 20px;
    margin-bottom: 20px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.04);
}

.filters-header {
    margin-bottom: 12px;
    color: var(--color-primary);
    font-weight: 600;
    font-size: 0.85em;
    display: flex;
    align-items: center;
    gap: 8px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--color-border-light);
    text-transform: uppercase;
    letter-spacing: 0.8px;
}

.filters-header i {
    color: var(--color-secondary);
    font-size: 0.85em;
}

/* Rejilla de filtros (reemplaza .controls-grid anterior) */
.controls-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 14px;
    margin-bottom: 14px;
}

.control-group label {
    display: block;
    margin-bottom: 5px;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--color-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.select-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.select-wrapper .icon-select {
    position: absolute;
    left: 14px;
    color: var(--color-primary);
    pointer-events: none;
    font-size: 0.9em;
    opacity: 0.7;
}

.select-wrapper select {
    width: 100%;
    padding: 8px 15px 8px 36px;
    border: 1px solid var(--color-border);
    border-radius: 4px;
    background-color: #fafbfc;
    color: var(--color-text);
    appearance: none;
    cursor: pointer;
    font-size: 0.88rem;
    transition: all 0.15s;
}

.select-wrapper select:focus {
    border-color: var(--color-primary);
    background-color: white;
    outline: none;
    box-shadow: 0 0 0 3px rgba(4, 50, 73, 0.1);
}

/* Flecha custom para selects */
.select-wrapper::after {
    content: '\f078'; /* FontAwesome chevron down */
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    position: absolute;
    right: 15px;
    font-size: 0.7rem;
    color: var(--color-muted);
    pointer-events: none;
}

.filters-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid #f0f0f0;
    padding-top: 15px;
    margin-top: 5px;
}

.btn-clear {
    background-color: transparent;
    border: 1px solid #cbd5e0;
    color: var(--color-muted);
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 6px;
}

.btn-clear:hover {
    background-color: #fee2e2;
    color: var(--color-warning);
    border-color: var(--color-warning);
}

.results-count {
    font-size: 0.9rem;
    color: var(--color-muted);
    font-weight: 500;
}
.results-count.count-ai      { color: var(--color-ai); }
.results-count.count-filtered { color: var(--color-warning); }
.results-count.count-all      { color: var(--color-muted); }

/* --- FIN NUEVOS ESTILOS --- */


/* --- HEADER Y NAVEGACIÓN --- */
.top-bar {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 20px;
    background: #dbdbda;
    padding: 15px 40px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 1);
    margin-bottom: 0;
    width: 100%;
    position: sticky;
    top: 0;
    z-index: 500;
    transition: padding 0.3s ease;
}

/* Header compacto al hacer scroll */
.top-bar.compact { padding: 8px 40px; }
.top-bar.compact .logo { height: 36px; }
.top-bar.compact .header h1 { font-size: 1.4em; }
.top-bar.compact .header-subtitle { display: none; }
.top-bar.compact .nav-btn { font-size: 0.95em; }
.top-bar.compact .telegram-link a { width: 38px; height: 38px; font-size: 18px; }

.telegram-link { margin-left: auto; }

.telegram-link a {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 50px;
    height: 50px;
    background: #0088cc;
    border-radius: 50%;
    color: white;
    font-size: 24px;
    transition: all 0.3s ease;
    text-decoration: none;
}

.telegram-link a:hover {
    background: #006699;
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(0, 136, 204, 0.4);
}

.logo { height: 60px; flex-shrink: 0; transition: height 0.3s ease; }
.logo img { height: 100%; object-fit: contain; }

.header { flex: 1; color: white; padding: 10px 20px; }
.header h1 {
    font-size: 2em;
    margin-bottom: 5px;
    transition: font-size 0.3s ease;
    color: #2c3e50;
    text-shadow: none;
    font-weight: 400;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.header p {
    font-size: 1em;
    color: #666666;
    font-weight: 400;
    line-height: 1.4;
}

.nav-links { display: flex; gap: 15px; margin-right: 20px; }
.nav-btn {
    text-decoration: none;
    color: var(--color-primary);
    font-weight: 500;
    font-size: 1.15em;
    padding: 8px 12px;
    border-radius: 4px;
    transition: all 0.2s ease;
    white-space: nowrap;
}
.nav-btn:hover {
    background-color: rgba(4, 50, 73, 0.1);
    color: var(--color-secondary);
}

@media (max-width: 900px) {
    .nav-links { gap: 8px; margin-right: 10px; }
    .nav-btn { font-size: 0.85em; padding: 6px 8px; }
}
@media (max-width: 768px) {
    .header-subtitle { display: none !important; }
    .header h1 { font-size: 1.4em !important; }
    .header { padding: 5px 8px; }
    .top-bar { padding: 8px 10px !important; gap: 8px; }
    .logo { height: 36px; }
    .telegram-link a { width: 34px; height: 34px; font-size: 16px; }
    .nav-links { gap: 2px; margin-right: 2px; }
    .nav-btn { font-size: 0.7em; padding: 4px 5px; letter-spacing: -0.3px; }
    /* Compact mobile: todo más pequeño, no más grande */
    .top-bar.compact { padding: 5px 10px; }
    .top-bar.compact .logo { height: 28px; }
    .top-bar.compact .header h1 { font-size: 1.1em; }
    .top-bar.compact .nav-btn { font-size: 0.65em; padding: 3px 4px; }
    .top-bar.compact .telegram-link a { width: 28px; height: 28px; font-size: 14px; }
}


/* --- TABLA Y CONTENIDO (Original) --- */
.loading {
    text-align: center;
    color: var(--color-primary); /* Cambiado a oscuro para verse en fondo blanco */
    font-size: 1.1em;
    display: none;
    padding: 20px;
}

.error {
    background: #d32f2f;
    color: white;
    padding: 15px 20px;
    border-radius: 8px;
    margin-bottom: 20px;
    display: none;
    border-left: 5px solid #b71c1c;
}

.table-wrapper {
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.06);
    overflow-x: auto;
    border: 1px solid var(--color-border-light);
}

table { width: 100%; border-collapse: collapse; }
thead { background: var(--color-primary); color: white; }

th {
    padding: 14px 12px;
    text-align: left;
    font-weight: 600;
    font-size: 0.82em;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
    line-height: 1.1;
}

th:hover { background: rgba(255,255,255,0.08); }
.sort-indicator { margin-left: 6px; font-size: 0.75em; }
th i { font-size: 0.85em; }

td {
    padding: 12px 12px;
    border-bottom: 1px solid var(--color-border-light);
    font-size: 0.9em;
    color: var(--color-text);
}

tbody tr { transition: all 0.15s ease; cursor: pointer; }
tbody tr:hover { background-color: #f8fafb; }
tbody tr:last-child td { border-bottom: none; }
tbody tr.fila-destacada { background-color: #e8f4fd; box-shadow: inset 3px 0 0 var(--color-primary); }

.tag {
    display: inline-block;
    background: var(--color-primary);
    color: white;
    padding: 3px 10px;
    border-radius: 3px;
    margin-right: 4px;
    margin-bottom: 4px;
    font-size: 0.78em;
    cursor: pointer;
    transition: all 0.15s ease;
    letter-spacing: 0.3px;
}

.tag:hover { background: var(--color-primary-hover); }

.type-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: var(--color-muted);
    color: white;
    padding: 3px 8px;
    border-radius: 3px;
    font-size: 0.8em;
    font-weight: 500;
    white-space: nowrap;
    line-height: 1.1;
}
.type-badge i { font-size: 0.7em; flex-shrink: 0; }

/* --- PAGINACIÓN --- */
.pagination {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    margin-top: 10px;
    background: white;
    border: 1px solid var(--color-border-light);
    border-radius: 6px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.04);
}

.pag-left {
    display: flex;
    align-items: center;
    gap: 14px;
}

.pag-info {
    font-size: 0.9rem;
    color: var(--color-muted);
    font-weight: 500;
}

.pag-select {
    padding: 6px 10px;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    font-size: 0.85rem;
    color: var(--color-primary);
    background: #f8fafc;
    cursor: pointer;
    font-family: var(--font-main);
}

.pag-select:focus {
    border-color: var(--color-primary);
    outline: none;
}

.pag-buttons {
    display: flex;
    gap: 6px;
    align-items: center;
}

.pag-btn {
    background: white;
    border: 1px solid var(--color-border);
    color: var(--color-primary);
    padding: 8px 14px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s;
    min-width: 40px;
    text-align: center;
}

.pag-btn:hover:not(:disabled) {
    background: var(--color-primary);
    color: white;
    border-color: var(--color-primary);
}

.pag-btn.pag-active {
    background: var(--color-primary);
    color: white;
    border-color: var(--color-primary);
}

.pag-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

@media (max-width: 768px) {
    .pagination { flex-direction: column; gap: 10px; padding: 12px; }
    .pag-left { flex-direction: column; gap: 6px; text-align: center; }
    .pag-buttons { gap: 4px; }
    .pag-btn { padding: 6px 10px; font-size: 0.8rem; }

    /* Tabla mobile: ocultar columnas no esenciales */
    .table-wrapper { border-radius: 8px; }
    th, td { padding: 10px 8px; font-size: 0.85em; }
    /* Ocultar: usuario, tipo, subcategoría, tags, fecha */
    th:nth-child(3), td:nth-child(3),
    th:nth-child(4), td:nth-child(4),
    th:nth-child(6), td:nth-child(6),
    th:nth-child(7), td:nth-child(7),
    th:nth-child(8), td:nth-child(8) { display: none; }

    /* Búsqueda RAG mobile */
    .search-section { padding: 16px 10px; }
    .rag-header { font-size: 0.8em; }
    .rag-input-group { border-radius: 8px; }
    #rag-search-input { padding: 10px 12px; font-size: 0.9rem; border-radius: 8px 0 0 8px; }
    #btn-rag-search { padding: 0 12px; font-size: 0.8rem; border-radius: 0 8px 8px 0; min-width: auto; }
    .rag-hint { font-size: 0.75rem; }

    /* Filtros mobile */
    .filters-section { padding: 14px; }
    .controls-grid { gap: 12px; }

    /* Container */
    .container { padding: 12px; }
}

.url-cell {
    color: var(--color-primary);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
    line-height: 1.2;
}
.url-cell i { font-size: 0.9em; flex-shrink: 0; }
.url-cell:hover { text-decoration: underline; color: var(--color-primary); }

.nowrap { white-space: nowrap; }
.timestamp { color: #999; font-size: 0.85em; white-space: nowrap; }
.empty { text-align: center; padding: 40px; color: #999; font-size: 1.1em; }
.acciones-cell { text-align: center; width: 80px; }

.btn-ver-detalle {
    background: transparent;
    color: var(--color-primary);
    border: 1px solid var(--color-border);
    padding: 6px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85em;
    font-weight: 500;
    transition: all 0.15s ease;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.btn-ver-detalle:hover {
    background: var(--color-primary);
    color: white;
    border-color: var(--color-primary);
}

/* --- MODAL (Original) --- */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.6);
    animation: fadeIn 0.3s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal-content {
    background-color: white;
    margin: 5% auto;
    padding: 30px;
    border-radius: 8px;
    width: 90%;
    max-width: 800px;
    max-height: 80vh;
    overflow-y: auto;
    animation: slideDown 0.3s ease;
    box-shadow: 0 8px 40px rgba(0,0,0,0.2);
}
@keyframes slideDown { from { transform: translateY(-50px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    border-bottom: 3px solid var(--color-primary);
    padding-bottom: 15px;
    position: relative;
}

.modal-header::after {
    content: '';
    position: absolute;
    bottom: -3px;
    left: 0;
    width: 80px;
    height: 3px;
    background: var(--color-secondary);
}

.modal-header h2 {
    color: var(--color-primary);
    font-size: 1.5em;
    margin: 0;
    word-break: break-word;
    font-weight: 600;
    letter-spacing: 0.3px;
}

.close-btn {
    background: none;
    border: none;
    font-size: 2em;
    cursor: pointer;
    color: var(--color-primary);
    transition: transform 0.2s;
    flex-shrink: 0;
    margin-left: 20px;
}
.close-btn:hover { transform: rotate(90deg); }

.modal-section { margin-bottom: 20px; }
.modal-section-title {
    color: var(--color-primary);
    font-weight: 600;
    font-size: 1.1em;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.modal-section-content {
    color: var(--color-text);
    line-height: 1.7;
    padding: 14px 16px;
    background: #fafbfc;
    border-radius: 4px;
    border-left: 3px solid var(--color-primary);
    word-break: break-word;
    font-weight: 300;
    font-size: 0.93em;
}

.modal-tags { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.modal-tag {
    background: var(--color-primary);
    color: white;
    padding: 4px 12px;
    border-radius: 3px;
    font-size: 0.85em;
    cursor: pointer;
    transition: all 0.15s ease;
    letter-spacing: 0.3px;
}
.modal-tag:hover { background: var(--color-primary-hover); }

.modal-link {
    color: var(--color-primary);
    word-break: break-all;
    text-decoration: none;
    font-weight: 500;
}
.modal-link:hover { text-decoration: underline; }

#modal-resumen { white-space: pre-line; }
.icon { font-size: 1.2em; flex-shrink: 0; }



