/* Estilos personalizados para el Asistente de Preguntas */
/* Versión rediseño visual moderno — paleta azul/índigo con light mode */

/* Variables CSS */
:root {
    color-scheme: light;

    /* Paleta principal */
    --primary-color: #4f46e5;          /* índigo 600 — acento vibrante */
    --primary-hover: #4338ca;          /* índigo 700 */
    --primary-light: #eef2ff;          /* índigo 50 — fondos suaves */
    --primary-mid: #c7d2fe;            /* índigo 200 — bordes sutiles */
    --secondary-color: #7c3aed;        /* violeta 600 */
    --secondary-light: #ede9fe;
    --success-color: #059669;
    --teal-color: #0d9488;
    --accent-color: #0ea5e9;           /* sky 500 */

    /* Neutrales refinados */
    --ink-color: #0f172a;              /* slate 900 */
    --surface: #ffffff;
    --surface-raised: #f8fafc;         /* slate 50 */
    --bg-body: #f1f5f9;                /* slate 100 */
    --gray-50: #f8fafc;
    --gray-100: #f1f5f9;
    --gray-200: #e2e8f0;
    --gray-300: #cbd5e1;
    --gray-400: #94a3b8;
    --gray-500: #64748b;
    --gray-600: #475569;
    --gray-700: #334155;

    /* Sombras refinadas */
    --shadow-xs: 0 1px 2px 0 rgb(15 23 42 / 0.06);
    --shadow-sm: 0 1px 3px 0 rgb(15 23 42 / 0.08), 0 1px 2px -1px rgb(15 23 42 / 0.04);
    --shadow-md: 0 4px 6px -1px rgb(15 23 42 / 0.08), 0 2px 4px -2px rgb(15 23 42 / 0.04);
    --shadow-lg: 0 10px 20px -3px rgb(15 23 42 / 0.1), 0 4px 8px -4px rgb(15 23 42 / 0.06);
    --shadow-xl: 0 20px 30px -5px rgb(15 23 42 / 0.12), 0 8px 14px -6px rgb(15 23 42 / 0.06);
    --shadow-glow: 0 0 0 3px rgb(79 70 229 / 0.18);

    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --radius-xl: 20px;

    --container-padding: 1rem;
}

body {
    color: var(--ink-color);
    font-family: "Source Sans 3", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: var(--bg-body);
    color-scheme: light;
}

h1,
h2,
h3,
.quick-action-card span,
.loading-status-title {
    font-family: "Sora", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

/* ─── App shell ─────────────────────────────────────────────────────────── */
.app-shell {
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-xl) !important;
    box-shadow: var(--shadow-lg);
    padding: 2.5rem !important;
}

.app-identity {
    margin-bottom: 1.25rem;
}

.app-identity img {
    background: var(--surface);
    border: 3px solid var(--primary-mid);
    border-radius: 50%;
    box-shadow: 0 0 0 6px var(--primary-light), var(--shadow-md);
    height: 96px;
    width: 96px;
    display: block;
    margin: 0 auto;
}

/* Título principal */
.app-shell > h1,
.app-title {
    font-size: 1.65rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 0.4rem;
}

.app-subtitle {
    max-width: 48rem;
    margin-left: auto;
    margin-right: auto;
    color: var(--gray-500);
    font-size: 1rem;
}

/* Contenedor principal con ancho adaptativo */
.container {
    width: 100%;
    margin: 0 auto;
    padding-left: var(--container-padding);
    padding-right: var(--container-padding);
}

/* Tablets */
@media (min-width: 768px) {
    .container {
        max-width: 98%; /* Aumentado desde 95% */
    }
    
    :root {
        --container-padding: 1.5rem; /* Menos padding en tablets */
    }
}

/* Escritorio pequeño */
@media (min-width: 1024px) {
    .container {
        max-width: 1500px; /* Aumentado desde 1400px */
    }
}

/* Escritorio mediano */
@media (min-width: 1440px) {
    .container {
        max-width: 1700px; /* Aumentado desde 1600px */
    }
}

/* Escritorio grande */
@media (min-width: 1920px) {
    .container {
        max-width: 1900px; /* Aumentado desde 1800px */
    }
}

/* Pantallas ultra anchas */
@media (min-width: 2560px) {
    .container {
        max-width: 2400px; /* Aumentado desde 2200px */
    }
}

/* Selector de tipo de consulta (tarjetas) */
.quick-actions {
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    background: var(--surface);
    box-shadow: var(--shadow-md);
    overflow: hidden;
}

.quick-actions-heading {
    border-bottom: 1px solid var(--gray-200);
    padding: 1.5rem 1.5rem 1.125rem;
    background: linear-gradient(135deg, var(--primary-light) 0%, var(--secondary-light) 100%);
}

.quick-actions-heading h2 {
    color: var(--primary-color);
    font-size: 1.1rem;
    font-weight: 700;
    margin: 0 0 0.25rem;
    letter-spacing: -0.01em;
}

.quick-actions-heading p {
    color: var(--gray-500);
    font-size: 0.9rem;
    margin: 0;
}

.quick-action-grid {
    display: grid;
    grid-template-columns: 1fr;
}

@media (min-width: 768px) {
    .quick-action-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    .quick-action-card {
        border-bottom: none !important;
        border-right: 1px solid var(--gray-200);
    }
    .quick-action-card:last-child {
        border-right: 0;
    }
}

.quick-action-card {
    align-items: flex-start;
    border-bottom: 1px solid var(--gray-200);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 1.25rem 1.25rem 1.25rem 1rem;
    transition: background-color 0.2s ease, box-shadow 0.2s ease;
    position: relative;
}

.quick-action-card:last-child {
    border-bottom: 0;
}

.quick-action-card:hover {
    background: #f8fafc;
}

.quick-action-card:has(input:checked) {
    background: var(--primary-light);
    box-shadow: inset 0 3px 0 0 var(--primary-color);
}

.quick-action-card input {
    margin-top: 0;
    accent-color: var(--primary-color);
}

.quick-action-card .card-icon {
    font-size: 1.75rem;
    line-height: 1;
    display: block;
    margin-bottom: 0.25rem;
}

.quick-action-card p {
    line-height: 1.45;
    margin: 0.25rem 0 0;
    color: var(--gray-500);
    font-size: 0.875rem;
}

.quick-action-card span.text-base {
    font-size: 1rem !important;
    font-weight: 700 !important;
    color: var(--gray-700) !important;
}

.quick-action-card:has(input:checked) span.text-base {
    color: var(--primary-color) !important;
}

/* Row layout for radio + text on mobile */
.quick-action-card-inner {
    display: flex;
    gap: 0.75rem;
    align-items: flex-start;
    width: 100%;
}

.quick-actions-submit {
    border-top-left-radius: 0;
    border-top-right-radius: 0;
    margin-top: 0;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%) !important;
    font-size: 1rem;
    letter-spacing: 0.01em;
    transition: opacity 0.2s, box-shadow 0.2s, transform 0.15s;
}

.quick-actions-submit:hover {
    opacity: 0.92;
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.back-to-selection {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.9rem;
    font-weight: 600;
    padding: 0.35rem 0.65rem;
    color: var(--primary-color);
    background: var(--primary-light);
    border-radius: var(--radius-sm);
    transition: background-color 0.15s;
    text-decoration: none;
}

.back-to-selection:hover {
    background: var(--primary-mid);
    color: var(--primary-hover);
}

.context-filter-card {
    border-color: var(--gray-200);
    background: var(--gray-50);
    border-radius: var(--radius-md);
}

.context-filter-card button {
    white-space: nowrap;
    background: var(--primary-color) !important;
    border-radius: var(--radius-sm);
    transition: background-color 0.15s, box-shadow 0.15s;
}

.context-filter-card button:hover {
    background: var(--primary-hover) !important;
    box-shadow: var(--shadow-sm);
}

.result-answer {
    border: 1px solid var(--primary-mid);
    background: linear-gradient(135deg, #f8f9ff 0%, var(--primary-light) 100%);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8);
    border-radius: var(--radius-md);
    overflow-wrap: anywhere;
}

.refs-table thead {
    background: var(--gray-50);
}

.refs-table th {
    color: var(--gray-600);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 700;
}

.refs-table td {
    vertical-align: top;
    font-size: 0.95rem;
    line-height: 1.45;
}

.refs-table a {
    align-items: center;
    background: var(--primary-light);
    border: 1px solid var(--primary-mid);
    border-radius: var(--radius-sm);
    color: var(--primary-color) !important;
    display: inline-flex;
    font-weight: 700;
    gap: 0.4rem;
    line-height: 1.25;
    max-width: 100%;
    overflow-wrap: anywhere;
    padding: 0.3rem 0.55rem;
    text-decoration: none !important;
    transition: background-color 0.15s, border-color 0.15s, color 0.15s, box-shadow 0.15s;
    word-break: break-word;
}

.refs-table a::after {
    content: "↗";
    flex: 0 0 auto;
    font-size: 0.82em;
    line-height: 1;
    opacity: 0.72;
}

.refs-table a:hover {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: white !important;
    box-shadow: var(--shadow-sm);
}

.refs-table a:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

.share-panel {
    border-color: #86efac;
    background: linear-gradient(135deg, #f0fdf4 0%, #ecfeff 100%);
    border-radius: var(--radius-md);
}

.error-panel {
    background: #fef2f2;
    border: 1.5px solid #fca5a5;
    border-radius: var(--radius-md);
    padding: 0.875rem 1rem;
}

#contextFiltersDialog::backdrop {
    background: rgba(15, 23, 42, 0.45);
}

#contextFiltersDialog {
    max-height: min(90vh, 760px);
}

#contextFilterSpeakers option {
    padding: 0.25rem 0.375rem;
}

.example-query-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.75rem;
}

.example-query {
    background: var(--primary-light);
    border: 1.5px solid var(--primary-mid);
    border-radius: 999px;
    color: var(--primary-color);
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 600;
    padding: 0.35rem 0.85rem;
    transition: background-color 0.15s, border-color 0.15s, transform 0.1s;
}

.example-query:hover,
.example-query:focus {
    background: var(--primary-mid);
    border-color: var(--primary-color);
    transform: translateY(-1px);
}

.loading-status-panel {
    background: var(--primary-light);
    border: 1.5px solid var(--primary-mid);
    border-radius: var(--radius-md);
    margin-top: 1.25rem;
    padding: 1rem 1.25rem;
}

.loading-status-header {
    align-items: center;
    display: flex;
    gap: 0.75rem;
}

.loading-status-dot {
    animation: loading-dot 1.3s ease-in-out infinite;
    background: var(--primary-color);
    border-radius: 999px;
    height: 0.75rem;
    width: 0.75rem;
}

.loading-status-title {
    color: var(--gray-700);
    font-size: 0.95rem;
    font-weight: 700;
}

.loading-status-detail {
    color: var(--gray-600);
    font-size: 0.875rem;
}

.loading-status-bar {
    background: #e2e8f0;
    border-radius: 999px;
    height: 0.45rem;
    margin-top: 0.85rem;
    overflow: hidden;
}

.loading-status-bar span {
    animation: loading-pulse 2.2s ease-in-out infinite;
    background: var(--primary-color);
    border-radius: inherit;
    display: block;
    height: 100%;
}

@keyframes loading-dot {
    0%, 100% { opacity: 0.45; transform: scale(0.9); }
    50% { opacity: 1; transform: scale(1.1); }
}

/* Estilos de sombra personalizados */
.card-shadow {
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 
                0 2px 4px -1px rgba(0, 0, 0, 0.06),
                0 0 0 1px rgba(0, 0, 0, 0.05);
    transition: box-shadow 0.3s ease;
}

.card-shadow:hover {
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 
                0 4px 6px -2px rgba(0, 0, 0, 0.05),
                0 0 0 1px rgba(0, 0, 0, 0.05);
}

/* Gradientes */
.gradient-bg {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
}

/* Botón principal */
.btn-primary {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    border: none;
    border-radius: var(--radius-md);
    transition: all 0.2s ease;
    transform: translateY(0);
    box-shadow: 0 2px 8px -2px rgb(79 70 229 / 0.35);
}

.btn-primary:hover:not(:disabled) {
    background: linear-gradient(135deg, var(--primary-hover) 0%, #6d28d9 100%);
    transform: translateY(-2px);
    box-shadow: 0 8px 20px -4px rgba(79, 70, 229, 0.45);
}

.btn-primary:active:not(:disabled) {
    transform: translateY(0);
}

.btn-primary:disabled {
    background: linear-gradient(135deg, var(--gray-400) 0%, var(--gray-300) 100%);
    opacity: 0.7;
    box-shadow: none;
}

/* Spinner de carga */
.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--gray-200);
    border-top: 4px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Animación de pulso para la barra de carga */
.loading-pulse {
    animation: loading-pulse 2s ease-in-out infinite;
}

@keyframes loading-pulse {
    0%, 100% {
        width: 30%;
    }
    50% {
        width: 70%;
    }
}

/* Estilos para el contenido de respuesta */
.prose {
    color: var(--gray-700);
    line-height: 1.7;
    max-width: 100%;
}

.prose h1,
.prose h2,
.prose h3,
.prose h4,
.prose h5,
.prose h6 {
    color: var(--gray-700);
    font-weight: 600;
    margin-top: 1.5em;
    margin-bottom: 0.5em;
}

.prose h1 {
    font-size: 1.5em;
}

.prose h2 {
    font-size: 1.3em;
}

.prose h3 {
    font-size: 1.1em;
}

.prose p {
    margin-bottom: 1em;
}

.prose ul,
.prose ol {
    margin-bottom: 1em;
    padding-left: 1.5em;
}

.prose li {
    margin-bottom: 0.5em;
}

.prose strong {
    font-weight: 600;
    color: var(--gray-700);
}

.prose em {
    font-style: italic;
    color: var(--gray-600);
}

.prose blockquote {
    border-left: 4px solid var(--primary-color);
    margin: 1.5em 0;
    padding-left: 1em;
    color: var(--gray-600);
    font-style: italic;
}

.prose code {
    background-color: var(--gray-100);
    padding: 0.2em 0.4em;
    border-radius: 3px;
    font-size: 0.9em;
    color: var(--gray-700);
}

.prose pre {
    background-color: var(--gray-100);
    padding: 1em;
    border-radius: 8px;
    overflow-x: auto;
    margin: 1em 0;
}

.prose pre code {
    background-color: transparent;
    padding: 0;
}

.prose span {
    color: #0284c7;
    background: #e0f2fe;
    font-weight: 500;
    border-radius: 0.2em;
    padding: 0 0.2em;
}

/* Estilos para hiperenlaces en las respuestas */
.prose a {
    color: var(--primary-color);
    text-decoration: underline;
    text-underline-offset: 2px;
    text-decoration-thickness: 2px;
    font-weight: 600;
    transition: all 0.2s ease;
}

.prose a:hover {
    color: #1d4ed8;
    text-decoration-color: #1d4ed8;
    background-color: rgba(37, 99, 235, 0.1);
    padding: 0.1em 0.2em;
    border-radius: 3px;
}

.prose a:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
    background-color: rgba(37, 99, 235, 0.1);
    padding: 0.1em 0.2em;
    border-radius: 3px;
}

.prose a:visited {
    color: var(--secondary-color);
    text-decoration-color: var(--secondary-color);
}

.prose a[href*="transcripts/"] {
    background: #eef2ff;
    border-radius: 4px;
    box-decoration-break: clone;
    -webkit-box-decoration-break: clone;
    color: var(--primary-color);
    padding: 0.05em 0.28em;
    text-decoration-thickness: 1.5px;
}

.prose a[href*="transcripts/"]:hover,
.prose a[href*="transcripts/"]:focus {
    background: #e0e7ff;
    color: var(--primary-hover);
}

/* Grid adaptativo para contenido en columnas */
.content-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
    width: 100%;
}

/* Grid de 2 columnas para pantallas grandes */
.two-column-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 2rem;
}

@media (min-width: 1024px) {
    .two-column-grid {
        grid-template-columns: 1fr 1fr;
    }
}

/* Grid de 3 columnas para pantallas muy grandes */
.three-column-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
}

@media (min-width: 768px) {
    .three-column-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 1280px) {
    .three-column-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* Estilos para referencias */
.reference-item {
    display: block;
    padding: 12px 16px;
    background-color: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: 8px;
    text-decoration: none;
    color: var(--gray-700);
    transition: all 0.2s ease;
}

.reference-item:hover {
    background-color: white;
    border-color: var(--primary-color);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.reference-item .reference-title {
    font-weight: 600;
    color: var(--primary-color);
    margin-bottom: 4px;
    display: block;
}

.reference-item .reference-url {
    font-size: 0.875rem;
    color: var(--gray-600);
    word-break: break-all;
}

/* Lista de referencias en grid */
.references-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
}

@media (min-width: 768px) {
    .references-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 1280px) {
    .references-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

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

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.fade-in-up {
    animation: fadeInUp 0.6s ease-out;
}

.fade-in {
    animation: fadeIn 0.4s ease-out;
}

/* Estilos responsive mejorados */
@media (max-width: 768px) {
    :root {
        --container-padding: 1rem;
    }

    .app-shell {
        border-left: 0;
        border-radius: 0 !important;
        border-right: 0;
        margin-top: 0;
        padding: 1.25rem !important;
    }

    .a11y-toolbar > div {
        align-items: flex-start;
        flex-direction: column;
        gap: 0.75rem;
    }
    
    .card-shadow {
        margin-bottom: 1rem;
    }
    
    .result-answer.prose {
        font-size: 1.075rem;
        line-height: 1.75;
        padding: 1.125rem !important;
    }

    .result-answer.prose h1 {
        font-size: 1.35em;
    }

    .result-answer.prose h2 {
        font-size: 1.2em;
    }

    .result-answer.prose h3 {
        font-size: 1.08em;
    }

    .result-answer.prose p,
    .result-answer.prose li {
        margin-bottom: 0.85em;
    }
    
    .reference-item {
        padding: 10px 12px;
    }
    
    .reference-item .reference-title {
        font-size: 0.9rem;
    }
    
    .reference-item .reference-url {
        font-size: 0.8rem;
    }

    .quick-action-card {
        padding: 0.9rem 1rem;
    }

    .quick-actions-heading {
        padding: 1rem 1rem 0.875rem;
    }

    .share-panel .flex {
        align-items: stretch;
        flex-direction: column;
    }
}

@media (max-width: 640px) {
    .refs-table {
        border: 0 !important;
        min-width: 0 !important;
    }

    .refs-table thead {
        display: none;
    }

    .refs-table,
    .refs-table tbody,
    .refs-table tr,
    .refs-table td {
        display: block;
        width: 100%;
    }

    .refs-table tr {
        background: var(--surface);
        border: 1px solid var(--gray-200);
        border-radius: var(--radius-md);
        box-shadow: var(--shadow-xs);
        margin-bottom: 0.75rem;
        overflow: hidden;
    }

    .refs-table td {
        border-bottom: 1px solid var(--gray-100) !important;
        display: grid;
        font-size: 1rem;
        gap: 0.25rem;
        grid-template-columns: 1fr;
        line-height: 1.5;
        padding: 0.75rem 0.875rem !important;
    }

    .refs-table td:last-child {
        border-bottom: 0 !important;
    }

    .refs-table a {
        display: flex;
        justify-content: space-between;
        min-height: 2.75rem;
        padding: 0.65rem 0.75rem;
        width: 100%;
    }

    .refs-table td::before {
        color: var(--gray-500);
        display: block;
        font-size: 0.78rem;
        font-weight: 700;
        letter-spacing: 0.04em;
        text-transform: uppercase;
    }

    .refs-table td[colspan]::before {
        content: "" !important;
        display: none;
    }

    #refsTable td:nth-child(1)::before {
        content: "Contertulio";
    }

    #refsTable td:nth-child(2)::before {
        content: "Descripción";
    }

    #refsTable td:nth-child(3)::before {
        content: "Audio";
    }

    #refsTable td:nth-child(4)::before {
        content: "Tiempo";
    }

    #topicRefsTable td:nth-child(1)::before {
        content: "Tema";
    }

    #topicRefsTable td:nth-child(2)::before {
        content: "Episodio";
    }

    #topicRefsTable td:nth-child(3)::before {
        content: "Tiempo";
    }

    #topicRefsTable td:nth-child(4)::before {
        content: "Similitud";
    }

    html[lang="en"] #refsTable td:nth-child(1)::before {
        content: "Speaker";
    }

    html[lang="en"] #refsTable td:nth-child(2)::before {
        content: "Description";
    }

    html[lang="en"] #refsTable td:nth-child(3)::before {
        content: "Audio";
    }

    html[lang="en"] #refsTable td:nth-child(4)::before {
        content: "Time";
    }

    html[lang="en"] #topicRefsTable td:nth-child(1)::before {
        content: "Topic";
    }

    html[lang="en"] #topicRefsTable td:nth-child(2)::before {
        content: "Episode";
    }

    html[lang="en"] #topicRefsTable td:nth-child(3)::before {
        content: "Time";
    }

    html[lang="en"] #topicRefsTable td:nth-child(4)::before {
        content: "Similarity";
    }
}

/* Estilos para focus mejorado */
textarea:focus,
select:focus,
button:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.focus-visible {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

/* Estilos para scrollbar personalizada */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--gray-100);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: var(--gray-300);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--gray-400);
}

/* Estilos para estados de error */
.error-shake {
    animation: shake 0.5s ease-in-out;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

/* Clase para elementos de pantalla completa */
.full-width {
    width: 100vw;
    margin-left: calc(-50vw + 50%);
}

/* Transiciones suaves para elementos interactivos */
.smooth-transition {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Estilos para tooltip */
.tooltip {
    position: relative;
    display: inline-block;
}

.tooltip .tooltiptext {
    visibility: hidden;
    width: 200px;
    background-color: var(--gray-700);
    color: white;
    text-align: center;
    border-radius: 6px;
    padding: 8px;
    position: absolute;
    z-index: 1;
    bottom: 125%;
    left: 50%;
    margin-left: -100px;
    opacity: 0;
    transition: opacity 0.3s;
    font-size: 0.875rem;
}

.tooltip:hover .tooltiptext {
    visibility: visible;
    opacity: 1;
}

/* Banner de cookies */
.cookie-banner {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 1rem;
    z-index: 1000;
    transform: translateY(100%);
    transition: transform 0.3s ease;
}

.cookie-banner.show {
    transform: translateY(0);
}

/* Indicador de carga accesible */
.loading-spinner {
    border: 3px solid #f3f3f3;
    border-top: 3px solid #3498db;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    animation: spin 1s linear infinite;
    display: inline-block;
    margin-right: 8px;
}

/* Accesibilidad */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Mejoras de accesibilidad para movimiento reducido */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .spinner,
    .loading-spinner {
        animation: none;
        border-top-color: var(--primary-color);
    }
}

/* Modo alto contraste */
@media (prefers-contrast: high) {
    body {
        background-color: #000;
        color: #fff;
    }
    
    .card-shadow {
        border: 2px solid var(--gray-300);
    }
    
    .btn-primary {
        border: 2px solid var(--primary-color);
    }
    
    .reference-item {
        border: 2px solid var(--gray-300);
    }
    
    .bg-white {
        background-color: #000 !important;
        color: #fff !important;
        border: 2px solid #fff;
    }
}

.high-contrast {
    background-color: #000;
    color: #fff;
}

/* Utilidades adicionales para layouts flexibles */
.flex-container {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
}

.flex-item {
    flex: 1 1 300px;
}

/* Layout de panel dividido */
.split-panel {
    display: grid;
    grid-template-columns: 1fr;
    gap: 2rem;
}

@media (min-width: 1024px) {
    .split-panel {
        grid-template-columns: 2fr 1fr;
    }
}

@media (min-width: 1440px) {
    .split-panel {
        grid-template-columns: 3fr 2fr;
    }
}

/* Estilos específicos para formularios de análisis */
#speakersAnalysisForm .grid {
    display: grid;
    gap: 0.75rem; /* Reducido aún más para maximizar ancho */
    grid-template-columns: 1fr;
}

@media (min-width: 768px) {
    #speakersAnalysisForm .grid {
        grid-template-columns: 1fr 1fr;
        gap: 0.75rem; /* Menos espacio entre columnas */
    }
}

/* En pantallas grandes, un poco más de espacio pero no mucho */
@media (min-width: 1200px) {
    #speakersAnalysisForm .grid {
        gap: 1rem;
    }
}

/* Asegurar que los campos de fecha tengan ancho completo pero sin restricciones excesivas */
#speakersAnalysisForm input[type="date"] {
    width: 100%;
    box-sizing: border-box;
}

/* Espaciado mínimo en móvil, más flexible en escritorio */
#speakersAnalysisForm .grid > div {
    position: relative;
}

/* Solo en móvil, asegurar separación clara */
@media (max-width: 767px) {
    #speakersAnalysisForm .grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    #speakersAnalysisForm .grid > div {
        margin-bottom: 0.5rem;
    }
}

/* Asegurar que los inputs tengan el tamaño correcto */
#speakersAnalysisForm input,
#speakersAnalysisForm select {
    display: block;
    width: 100%;
    box-sizing: border-box;
}

/* Estilos específicos para el select multiple de intervinientes */
#speakers {
    height: 120px !important; /* Altura fija para mostrar múltiples opciones */
    overflow-y: auto;
    padding: 0.5rem !important;
    line-height: 1.4;
}

/* Mejorar la visualización de las opciones en el select multiple */
#speakers option {
    padding: 0.25rem 0.5rem;
    border-radius: 3px;
    margin-bottom: 1px;
}

#speakers option:checked {
    background: linear-gradient(135deg, #2563eb 0%, #7c3aed 100%);
    color: white;
    font-weight: 600;
}

/* Forzar que el select multiple muestre las opciones seleccionadas visiblemente */
#speakers:focus {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

/* Asegurar que el placeholder se vea bien */
#speakers option:disabled {
    color: #6b7280;
    font-style: italic;
}

/* Estilos específicos para las estadísticas del período */
#generalStats .grid {
    display: grid !important;
    grid-template-columns: 1fr;
    gap: 1rem;
}

@media (min-width: 768px) {
    #generalStats .grid {
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 1rem;
    }
}

/* Asegurar que las estadísticas no se vean afectadas por otros estilos */
#generalStats .grid > div {
    min-height: auto;
    margin-bottom: 0;
}

/* Mejorar la apariencia de las estadísticas */
#generalStats {
    margin-bottom: 1rem;
}

@media (min-width: 1024px) {
    #generalStats .grid {
        gap: 2rem;
    }
}

/* Estilos específicos para la grilla de estadísticas */
.stats-grid {
    display: grid !important;
    grid-template-columns: 1fr;
    gap: 1rem;
}

@media (min-width: 768px) {
    .stats-grid {
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 1.5rem;
    }
}

@media (min-width: 1024px) {
    .stats-grid {
        gap: 2rem;
        grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    }
}

/* Elementos individuales de estadísticas */
.stats-item {
    flex: none;
    min-width: 0;
}

/* Maximizar ancho para gráficas y resultados */
#speakersResults {
    width: 100%;
    max-width: none !important;
    margin: 0;
    padding: 0;
}

/* Contenedores de gráficas con ancho completo */
#speakersResults .bg-white {
    margin-left: calc(-1 * var(--container-padding));
    margin-right: calc(-1 * var(--container-padding));
    padding-left: var(--container-padding);
    padding-right: var(--container-padding);
    width: auto;
}

/* Asegurar que las gráficas usen todo el ancho disponible */
#speakersResults canvas,
#speakersResults .chart-container,
#speakersResults svg {
    width: 100% !important;
    max-width: 100% !important;
}

/* Para gráficas que puedan tener contenedores específicos */
.chart-wrapper {
    width: 100%;
    overflow: hidden;
    margin: 0;
    padding: 0;
}

/* Reducir márgenes en móvil para gráficas */
@media (max-width: 768px) {
    #speakersResults .bg-white {
        margin-left: calc(-1 * var(--container-padding));
        margin-right: calc(-1 * var(--container-padding));
        border-radius: 0;
    }
}

/* En pantallas grandes, usar el máximo ancho posible */
@media (min-width: 1024px) {
    #speakersResults {
        width: 100vw;
        margin-left: calc(-50vw + 50%);
        padding-left: 2rem;
        padding-right: 2rem;
    }
}

/* ===== ESTILOS FAQ (Consultas Destacadas) ===== */

/* Sección FAQ */
#faqSection {
    max-width: 900px;
    margin: 0 auto;
}

#faqSection h2 {
    color: var(--gray-700);
}

/* Búsqueda FAQ */
#faqSearch {
    transition: border-color 0.2s, box-shadow 0.2s;
}

#faqSearch:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

/* Categorías FAQ - Acordeón */
.faq-category {
    background: white;
    border: 1px solid var(--gray-200);
    border-radius: 0.75rem;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    transition: box-shadow 0.2s;
}

.faq-category:hover {
    box-shadow: var(--shadow-md);
}

.faq-subcategory {
    margin: 0.5rem 0;
    border-radius: 0.5rem;
    border: 1px solid var(--gray-100);
    box-shadow: none;
}

.faq-subcategory:hover {
    box-shadow: var(--shadow-sm);
}

/* Header de categoría */
.faq-category-header {
    display: flex;
    flex-direction: column;
    padding: 1rem 1.25rem;
    cursor: pointer;
    user-select: none;
    background: var(--gray-50);
    border-bottom: 1px solid transparent;
    transition: background-color 0.15s;
}

.faq-category-header:hover {
    background: var(--gray-100);
}

.faq-category-primary {
    background: linear-gradient(135deg, var(--primary-light) 0%, var(--secondary-light) 100%);
}

.faq-category-primary:hover {
    background: linear-gradient(135deg, var(--primary-mid) 0%, #ddd6fe 100%);
}

.faq-category-header-left {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.faq-category-chevron {
    font-size: 0.75rem;
    color: var(--gray-400);
    transition: transform 0.25s ease;
    flex-shrink: 0;
}

.faq-category-chevron-open {
    transform: rotate(90deg);
}

.faq-category-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--gray-700);
    margin: 0;
    flex-grow: 1;
}

.faq-category-count {
    background: var(--primary-color);
    color: white;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.125rem 0.5rem;
    border-radius: 9999px;
    flex-shrink: 0;
}

.faq-category-description {
    font-size: 0.8125rem;
    color: var(--gray-400);
    margin: 0.25rem 0 0 1.25rem;
    line-height: 1.4;
}

/* Contenido de categoría (colapsable) */
.faq-category-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.35s ease;
}

.faq-category-content-open {
    max-height: 5000px;
    border-top: 1px solid var(--gray-200);
}

.faq-category-queries {
    padding: 0.5rem 1rem;
}

.faq-category-children {
    padding: 0 1rem 0.5rem;
}

/* Item de consulta FAQ */
.faq-query-item {
    border-bottom: 1px solid var(--gray-100);
    transition: background-color 0.15s;
}

.faq-query-item:last-child {
    border-bottom: none;
}

.faq-query-item:hover {
    background: #fafbff;
}

.faq-query-link {
    display: block;
    padding: 0.875rem 0.5rem;
    text-decoration: none;
    color: inherit;
}

.faq-query-link:hover {
    text-decoration: none;
}

.faq-query-question {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    font-weight: 500;
    color: var(--gray-700);
    line-height: 1.5;
}

.faq-query-icon {
    flex-shrink: 0;
    font-size: 0.875rem;
    margin-top: 0.125rem;
}

.faq-query-preview {
    margin: 0.5rem 0 0 1.625rem;
    font-size: 0.8125rem;
    color: var(--gray-400);
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.faq-query-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 0.5rem 0 0 1.625rem;
}

.faq-query-likes {
    font-size: 0.75rem;
    color: var(--gray-400);
}

.faq-query-dislikes {
    font-size: 0.75rem;
    color: var(--gray-400);
}

/* Botones de votación */
.vote-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.5rem 1.1rem;
    border-radius: var(--radius-md);
    border: 1.5px solid var(--gray-200);
    background: var(--surface);
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 600;
    box-shadow: var(--shadow-xs);
}

.vote-btn:hover:not(:disabled) {
    transform: scale(1.05);
    box-shadow: var(--shadow-sm);
}

.vote-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.vote-like:hover:not(:disabled) {
    border-color: #22c55e;
    background: #f0fdf4;
}

.vote-dislike:hover:not(:disabled) {
    border-color: #ef4444;
    background: #fef2f2;
}

.vote-btn.voted-like {
    border-color: #22c55e;
    background: #dcfce7;
}

.vote-btn.voted-dislike {
    border-color: #ef4444;
    background: #fee2e2;
}

/* Indicadores de votos en consultas similares */
.similar-query-votes {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.75rem;
    color: #6b7280;
    margin-left: 0.5rem;
}

.similar-query-votes .vote-count {
    display: inline-flex;
    align-items: center;
    gap: 0.125rem;
}

.faq-query-arrow {
    font-size: 0.8125rem;
    color: var(--primary-color);
    font-weight: 500;
    opacity: 0;
    transition: opacity 0.15s;
}

.faq-query-item:hover .faq-query-arrow {
    opacity: 1;
}

/* Estado vacío FAQ */
#faqEmpty {
    background: var(--gray-50);
    border-radius: 0.75rem;
    border: 2px dashed var(--gray-200);
}

#faqEmpty p:first-child {
    font-weight: 500;
    color: var(--gray-600);
}

/* Loading FAQ */
#faqLoading {
    font-size: 0.9375rem;
}

/* Responsive FAQ */
@media (max-width: 640px) {
    .faq-category-header {
        padding: 0.75rem 1rem;
    }

    .faq-category-title {
        font-size: 0.9375rem;
    }

    .faq-query-link {
        padding: 0.75rem 0.25rem;
    }

    .faq-query-preview {
        -webkit-line-clamp: 1;
    }

    .faq-query-arrow {
        opacity: 1;
    }
}

/* ── Footer ────────────────────────────────────────────────────────────────── */
.footer-panel {
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg) !important;
    box-shadow: var(--shadow-sm);
}

/* ── Accessibility toolbar ──────────────────────────────────────────────────── */
.a11y-toolbar button {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 4px;
    color: #fff;
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    padding: 2px 8px;
}

.a11y-toolbar button:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.55);
}

.accessibility-info-link {
    color: rgba(255, 255, 255, 0.75) !important;
    text-decoration: none;
}

.accessibility-info-link:hover {
    color: #fff !important;
    text-decoration: underline;
}

/* ── Language switcher buttons ─────────────────────────────────────────────── */
.lang-btn {
    background: transparent;
    border: 2px solid transparent;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1.3rem;
    line-height: 1;
    opacity: 0.55;
    padding: 2px 4px;
    transition: opacity 0.2s, border-color 0.2s;
    vertical-align: middle;
}

.lang-btn:hover {
    opacity: 0.9;
}

.lang-btn.lang-btn-active {
    opacity: 1;
    border-color: rgba(255, 255, 255, 0.75);
}

.lang-btn:focus {
    outline: 2px solid white;
    outline-offset: 2px;
}

.lang-flag-symbol {
    align-items: center;
    background: #ffffff;
    border: 1px solid rgba(17, 24, 39, 0.18);
    border-radius: 3px;
    display: inline-flex;
    height: 1rem;
    justify-content: center;
    margin-right: 0.25rem;
    min-width: 1.5rem;
    overflow: hidden;
    vertical-align: middle;
}

.lang-flag-symbol::before {
    background-position: center;
    background-repeat: no-repeat;
    background-size: cover;
    content: "";
    display: block;
    height: 100%;
    width: 100%;
}

.lang-btn[data-lang="es"] .lang-flag-symbol::before {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 60 40'%3E%3Crect width='60' height='40' fill='%23c8102e'/%3E%3Crect y='10' width='60' height='20' fill='%23ffc400'/%3E%3C/svg%3E");
}

.lang-btn[data-lang="en"] .lang-flag-symbol::before {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 60 30'%3E%3Crect width='60' height='30' fill='%23012169'/%3E%3Cpath d='M0 0 L25 12.5 M35 17.5 L60 30 M60 0 L35 12.5 M25 17.5 L0 30' stroke='%23fff' stroke-width='6'/%3E%3Cpath d='M0 0 L25 12.5 M35 17.5 L60 30 M60 0 L35 12.5 M25 17.5 L0 30' stroke='%23c8102e' stroke-width='3.5'/%3E%3Crect x='25' width='10' height='30' fill='%23fff'/%3E%3Crect y='10' width='60' height='10' fill='%23fff'/%3E%3Crect x='27' width='6' height='30' fill='%23c8102e'/%3E%3Crect y='12' width='60' height='6' fill='%23c8102e'/%3E%3C/svg%3E");
}
