html, body{
  font-family: var(--font-family);
}

/* ===== SKIP TO CONTENT - ACCESIBILIDAD ===== */
.skip-to-content {
    position: absolute;
    top: -40px;
    left: 0;
    background: #3b82f6;
    color: white;
    padding: 8px 16px;
    text-decoration: none;
    z-index: 10000;
    border-radius: 0 0 8px 0;
    font-weight: 500;
}

.skip-to-content:focus-visible {
    top: 0;
}

/* ===== HISTORIAL DE CONVERSACIONES ===== */
.history-item {
    padding: 12px 16px;
    margin-bottom: 8px;
    border-radius: 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-default);
    cursor: pointer;
    transition: all 0.2s ease;
}

.history-item:hover {
    background: var(--bg-hover);
    border-color: var(--border-medium);
    transform: translateX(2px);
}

.history-item:active {
    transform: translateX(0);
}

/* Scroll personalizado para historial */
#historyListContainer::-webkit-scrollbar {
    width: 6px;
}

#historyListContainer::-webkit-scrollbar-track {
    background: var(--border-default);
    border-radius: 10px;
}

#historyListContainer::-webkit-scrollbar-thumb {
    background: var(--border-medium);
    border-radius: 10px;
}

#historyListContainer::-webkit-scrollbar-thumb:hover {
    background: var(--border-strong);
}

.typing-indicator-container {
    opacity: 1;
    transition: all 0.3s ease;
}

.typing-bubble {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background-color: none;
}

.typing-animation {
    display: flex;
    gap: 0.3rem;
    padding: 0.25rem 0;
}

.typing-dot {
    width: 8px;
    height: 8px;
    background-color: #ccc;
    border-radius: 50%;
    animation: typingWave 200ms infinite ease-in-out;
}

.typing-dot:nth-child(2) {
    animation-delay: 0.1s;
}

.typing-dot:nth-child(3) {
    animation-delay: 0.2s;
}

@keyframes typingWave {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.6;
    }
    30% {
        transform: translateY(-8px);
        opacity: 1;
    }
}

.typing-text {
    color: var(--text-secondary);
    font-size: 0.9rem;
    min-width: 140px;
    display: none;
    animation: textPulse 2s infinite;
}

@keyframes textPulse {
    0%, 100% {
        opacity: 0.7;
    }
    50% {
        opacity: 1;
    }
}


/* ✅ ESTILOS PARA BLOQUES DE CÓDIGO */
.code-block-wrapper {
    margin: 1rem 0;
    width: 100%;
    overflow: hidden;
    background-color: #1E1E1E;
    border-radius: 15px;
}

.code-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 1rem;
    gap: 18px;
    background-color: #1E1E1E;
    position: sticky;
    border-bottom: 1px solid #555;
}

.code-language {
    font-size: 0.9rem;
    font-weight: 600;
    letter-spacing: 0.5px;
    color: #9ca3af;
}

.code-copy-btn {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    background-color: transparent;
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.code-copy-btn svg{
  width: 16px;
  height: 16px;
}

.code-copy-btn:hover {
    background-color: rgba(59, 130, 246, 0.15);
    border-color: #3b82f6;
    color: #3b82f6;
    transform: scale(1.05);
}

.code-copy-btn:active {
    transform: scale(0.95);
}


.code-block-wrapper pre {
    margin: 0;
    padding: 1rem;
    overflow-x: auto;
}

.code-block-wrapper code {
    font-family: 'Fira Code', 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 0.9rem;
    line-height: 1.5;
    color: #e5e7eb;
}

.code-block-wrapper .hljs {
    background-color: transparent;
    padding: 0;
}

/* Código inline (dentro de párrafos) */
.bot-bubble code:not(pre code) {
    color: var(--text-muted);
    padding: 0.4rem 0.6rem;
    border-radius: var(--radius-sm);
    font-family: var(--font-mono);
    font-size: 0.85em;
}

/* Bloques de código preformateados */
.bot-bubble pre {
    background-color: #1E1E1E;
    padding: 15px 20px;
    overflow-x: auto;
}

/* Responsividad */
@media screen and (max-width: 768px) {
    .code-block-wrapper {
        margin: 0.75rem 0;
    }

    .code-header {
        padding: 0.35rem 0.75rem;
    }

    .code-block-wrapper pre {
        padding: 0.75rem;
    }

    .code-block-wrapper code {
        font-size: 0.8rem;
    }

    .code-copy-btn {
        width: 28px;
        height: 28px;
    }
}

/* ===== RATE LIMIT NOTICE ===== */
.rate-limit-notice {
    margin: auto;
    max-width: 95%;
}

.rate-limit-bubble {
    padding: 10px 10px !important;
    background: transparent;
    border-radius: 20px;
    border: 1px solid #333;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.rate-limit-bubble h4{
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  padding: 0;
  font-size: 20px;
}

.rate-limit-bubble svg{
  color: rgb(255,103,103);
}

.rate-limit-bubble p {
    margin: 0;
    line-height: 1.6;
    font-size: 19px;
    color: var(--text-tertiary);
}

.rate-limit-acknowledge-btn {
    background: #ffffff;
    border: none;
    border-radius: 999px;
    padding: 12px 15px;
    cursor: pointer;
    font-size: 18px;
    font-weight: 600;
    width: 100%;
    max-width: 100%;
    color: #000000;
    transition: all 0.2s ease;
}

.rate-limit-acknowledge-btn:hover {
    background: #f2f2f2;
    transform: scale(1.02);
}

.rate-limit-acknowledge-btn:active {
    transform: scale(0.98);
}

/* Responsive móvil */
@media (max-width: 768px) {
    .rate-limit-notice {
        max-width: 95%;
    }
    
    .rate-limit-bubble {
        padding: 10px 16px !important;
    }
    
    .rate-limit-bubble h4{
      font-size: 18px;
    }
    
    .rate-limit-bubble p {
        font-size: 16px;
    }
    
    .rate-limit-acknowledge-btn {
        padding: 12px 15px;
        font-size: 18px;
    }
}

/* ===== MANEJO DE FÓRMULAS MATEMÁTICAS (KaTeX) ===== */

/* Contenedor general de fórmulas */
.katex-display {
    overflow-x: auto;
    overflow-y: hidden;
    padding: 0.5rem 0;
    margin: 0.75rem 0;
}

/* Scroll horizontal para fórmulas largas */
.katex-display > .katex {
    white-space: normal;
    word-break: break-word;
}

/* Permitir scroll horizontal en fórmulas que desbordan */
.katex-display {
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* Estilo del scrollbar (opcional) */
.katex-display::-webkit-scrollbar {
    height: 4px;
}

.katex-display::-webkit-scrollbar-track {
    background: var(--border-default);
    border-radius: 4px;
}

.katex-display::-webkit-scrollbar-thumb {
    background: var(--border-medium);
    border-radius: 4px;
}

.katex-display::-webkit-scrollbar-thumb:hover {
    background: var(--border-strong);
}

/* Fórmulas inline (dentro de párrafos) */
.katex {
    font-size: 1.05em;
    word-break: break-word;
    overflow-wrap: break-word;
}

/* Para móviles: reducir tamaño de fórmulas */
@media screen and (max-width: 768px) {
    .katex-display {
        font-size: 0.9rem;
    }
    
    .katex {
        font-size: 0.95rem;
    }
}

/* En móviles muy pequeños, reducir más */
@media screen and (max-width: 480px) {
    .katex-display {
        font-size: 0.8rem;
    }
    
    .katex {
        font-size: 0.85rem;
    }
}