/* ==================== VARIABLES CSS ==================== */
:root {
    --azul: #00BCD4;
    --rojo: #DA291C;
    --gris-borde: #e0e0e0;
    --gris-fondo: #f5f5f5;
    --texto-oscuro: #333;
    --texto-claro: #666;
    --blanco: #fff;
    --negro: #1a1a1a;
    --success: #28a745;
    --error: #dc3545;
}

/* ==================== RESET Y BASE ==================== */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    height: 100%;
    font-family: 'Roboto', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--gris-fondo);
    color: var(--texto-oscuro);
}

/* ==================== LAYOUT PRINCIPAL ==================== */
.app {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

/* ==================== TOPBAR (SIEMPRE VISIBLE) ==================== */
header.topbar {
    background: var(--negro);
    color: var(--blanco);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    z-index: 30;
    position: sticky;
    top: 0;
    height: 56px;
    flex-shrink: 0;
}

.menu-toggle {
    background: none;
    border: 0;
    color: var(--blanco);
    cursor: pointer;
    padding: 4px;
    font-size: 24px;
    line-height: 1;
}

.brand {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    font-size: 18px;
    flex: 1;
    justify-content: center;
}

.logo-mark {
    width: 24px;
    height: 24px;
    display: inline-block;
}

/* ==================== SIDEBAR ==================== */
nav.sidebar {
    position: fixed;
    left: -280px;
    top: 56px; /* Debajo del topbar */
    bottom: 0;
    width: 280px;
    background: var(--blanco);
    transition: left 0.3s ease;
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.15);
    z-index: 100;
    overflow-y: auto;
    padding: 20px;
}

nav.sidebar.active {
    left: 0;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    top: 56px; /* Debajo del topbar */
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 99;
}

.sidebar-overlay.active {
    display: block;
}

.sidebar-logo {
     width: 100%;
    height: auto;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    margin-bottom: 20px;
    border-radius: 0;
}

.sidebar-logo img {
    max-width: 150px;
    height: auto;
    object-fit: contain;
}
.sidebar-logo svg {
    width: 24px;
    height: 24px;
}

.sidebar-title {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 20px;
}

.sidebar-title .claro {
    color: var(--rojo);
}

.nav-item {
    display: flex;
    gap: 10px;
    align-items: center;
    padding: 12px;
    color: var(--texto-claro);
    border-radius: 8px;
    cursor: pointer;
    margin-bottom: 8px;
    font-size: 15px;
    transition: all 0.2s;
}

.nav-item:hover {
    background: var(--gris-fondo);
}

.nav-item.active {
    background: #e8f5f7;
    color: var(--azul);
    font-weight: 500;
}

.nav-item svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.section-title {
    margin-top: 20px;
    margin-bottom: 10px;
    color: #999;
    font-size: 13px;
    font-weight: 500;
}

.no-conversations {
    padding: 12px;
    color: #999;
    font-size: 13px;
}

/* ==================== TASKS EN SIDEBAR (DISEÑO ORIGINAL) ==================== */
.tasks-container {
    margin-top: 10px;
    display: none;
}

.tasks-container.active {
    display: block;
}

.task-card {
    background: #E0F7FA;
    border: 1.5px solid var(--azul);
    border-radius: 12px;
    padding: 14px;
    margin-bottom: 12px;
    transition: all 0.2s;
}

.task-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: #006064;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    user-select: none;
}

.task-header svg {
    width: 16px;
    height: 16px;
    transition: transform 0.2s;
}

.task-header.collapsed svg {
    transform: rotate(-90deg);
}

.task-body {
    margin-top: 10px;
    font-size: 13px;
    color: #555;
    line-height: 1.4;
    display: none;
}

.task-body.open {
    display: block;
}

/* Estilos para los items de tareas individuales */
.task-item {
    position: relative;
    background: var(--blanco);
    border-left: 3px solid var(--azul);
    padding: 8px;
    padding-right: 30px;
    margin: 5px 0;
    border-radius: 4px;
    font-size: 13px;
}

.task-content {
    margin-bottom: 4px;
    color: var(--texto-oscuro);
}

.task-time {
    font-size: 11px;
    color: var(--texto-claro);
}

.task-delete {
    position: absolute;
    top: 5px;
    right: 5px;
    background: none;
    border: none;
    color: var(--error);
    cursor: pointer;
    font-size: 16px;
    padding: 2px 5px;
    border-radius: 3px;
    line-height: 1;
}

.task-delete:hover {
    background: var(--error);
    color: var(--blanco);
}

.action-buttons {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 20px;
}

.btn-secondary {
    background: var(--texto-claro);
    color: var(--blanco);
    border: none;
    padding: 10px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 14px;
}

.btn-secondary:hover {
    background: var(--texto-oscuro);
    transform: translateY(-2px);
}

/* ==================== MAIN CONTENT ==================== */
main.content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    background: var(--gris-fondo);
}

/* ==================== WELCOME AREA ==================== */
.welcome-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding: 40px 20px 140px;
    overflow-y: auto;
    background: var(--blanco);
}

.hero {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    margin-bottom: 30px;
}

.hero-icon {
    width: 60px;
    height: 60px;
   
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.hero-icon svg {
    width: 32px;
    height: 32px;
}

.hero-title {
    font-size: 17px;
    font-weight: 500;
    color: #555;
    text-align: center;
    max-width: 300px;
    line-height: 1.4;
}

/* ==================== SUGGESTION CARDS ==================== */
.suggestions {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
    width: 100%;
    max-width: 500px;
    margin-bottom: 20px;
}

.suggestion-card {
    background: var(--blanco);
    border: 1px solid var(--gris-borde);
    border-radius: 16px;
    padding: 20px;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.suggestion-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
}

.card-icon {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 12px;
    font-size: 20px;
    font-weight: 700;
    color: var(--blanco);
}

.card-icon.red {
   
}

.card-icon.cyan {
    
}

.card-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--texto-oscuro);
    margin-bottom: 6px;
}

.card-desc {
    font-size: 13px;
    color: #777;
    line-height: 1.4;
}

/* ==================== CHAT PAGE ==================== */
.chat-page {
    display: none;
    height: 100%;
    flex-direction: column;
    padding-bottom: 140px;
    background: var(--gris-fondo);
}

.chat-history {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 20px;
    padding-bottom: 80px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: var(--gris-fondo);
    min-height: 0;
    max-height: 100%;
}

/* ==================== MENSAJES ==================== */
.msg {
    padding: 12px 16px;
    border-radius: 16px;
    max-width: 85%;
    line-height: 1.5;
    font-size: 15px;
    animation: fadeIn 0.3s ease;
}

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

.msg.user {
    align-self: flex-end;
    background: #E0F7FA;
    color: #006064;
    border-radius: 16px 16px 4px 16px;
}

.msg.bot {
    align-self: flex-start;
    background: var(--blanco);
    color: var(--texto-oscuro);
    border-radius: 16px 16px 16px 4px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
}

/* Contenedor del visor de medios integrado */
.message-media-viewer {
    margin-top: 12px;
    width: 100%;
     max-width: 100%;
}

.media-content {
    position: relative;
    width: 100%;
    border-radius: 12px;
    overflow: hidden;
    background: #000;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.media-content video {
    width: 100%;
    height: auto;
    display: block;
    max-height: 400px;
    object-fit: contain;
}

.media-content iframe {
    width: 100%;
    height: 500px;
    border: none;
    display: block;
}

.media-content img {
    width: 100%;
    height: auto;
    display: block;
    user-select: none;
    -webkit-user-drag: none;
    pointer-events: none;
}

.media-protection-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 999;
    background: transparent;
    cursor: default;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
}

/* Activar overlay solo cuando se intenta interactuar */
.media-content:active .media-protection-overlay {
    pointer-events: auto;
}

@media (max-width: 768px) {
    .message-media-viewer {
        max-width: 100%;
    }
    
    .media-content video {
        max-height: 300px;
    }
    
    .media-content iframe {
        height: 350px;
    }
}



/* ==================== INPUT SECTION ==================== */
.input-section {
    background: var(--blanco);
    border-top: 1px solid var(--gris-borde);
    padding: 16px;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 20;
}

.input-wrapper {
    background: var(--blanco);
    border: 1px solid var(--gris-borde);
    border-radius: 24px;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}

.input-wrapper input {
    border: 0;
    outline: none;
    font-size: 15px;
    width: 100%;
    color: var(--texto-oscuro);
}

.input-wrapper input::placeholder {
    color: #999;
}

.send-btn-icon {
    background: var(--azul);
    color: var(--blanco);
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: all 0.2s;
}

.send-btn-icon:hover {
    background: #0097A7;
    transform: scale(1.05);
}

.send-btn-icon i {
    font-size: 14px;
}

.add-btn {
    color: var(--azul);
    font-size: 22px;
    cursor: pointer;
    font-weight: 600;
    flex-shrink: 0;
    user-select: none;
    line-height: 1;
}

.footer-note {
    font-size: 12px;
    color: #999;
    text-align: center;
    line-height: 1.4;
}

/* ==================== ACTION MENU ==================== */
.action-menu {
    position: fixed;
    bottom: 80px;
    left: 16px;
    right: 16px;
    background: var(--blanco);
    border: 1px solid var(--gris-borde);
    border-radius: 16px;
    box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.15);
    padding: 12px;
    display: none;
    z-index: 50;
    max-width: 400px;
}

.action-menu.active {
    display: block;
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.action-item {
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    border-radius: 12px;
    font-size: 15px;
    color: var(--texto-claro);
    transition: all 0.2s;
    border: 1px solid transparent;
}

.action-item:hover {
    background: var(--gris-fondo);
}

.action-item.selected {
    background: #E0F7FA;
    color: #006064;
    font-weight: 500;
    border-color: var(--azul);
}

.action-item svg,
.action-item .icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.action-item .icon {
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 16px;
}

.action-item .icon.red {
    color: var(--rojo);
}

/* ==================== LOADING ==================== */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    color: var(--blanco);
}

.loading-overlay.active {
    display: flex;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top: 4px solid var(--blanco);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 15px;
}

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

.loading-overlay p {
    font-size: 16px;
    margin-top: 10px;
}

/* ==================== SCROLLBAR CUSTOM ==================== */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
}

::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* ==================== RESPONSIVE DESKTOP ==================== */
@media (min-width: 900px) {
    .app {
        display: grid;
        grid-template-columns: 280px 1fr;
        grid-template-rows: 56px 1fr;
    }

    header.topbar {
        grid-column: 1 / -1;
        background: var(--negro);
        padding: 0 24px;
    }

    .menu-toggle {
        display: none;
    }

    nav.sidebar {
        position: static;
        top: auto;
        left: 0;
        box-shadow: none;
        border-right: 1px solid var(--gris-borde);
    }

    .sidebar-overlay {
        display: none !important;
    }

    main.content {
        grid-column: 2;
    }

    .suggestions {
        grid-template-columns: repeat(2, 1fr);
        max-width: 700px;
    }

    .welcome-area {
        padding: 60px 40px 140px;
    }

    .action-menu {
        left: 300px;
        max-width: 350px;
    }

    .input-section {
        left: 280px;
    }
}

/* ==================== ANIMATIONS UTILITIES ==================== */
.fade-in {
    animation: fadeIn 0.3s ease;
}

.slide-in {
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        transform: translateX(-100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}


/* ==================== ESTILOS PARA MENSAJES MARKDOWN ==================== */

/* Headers dentro de mensajes */
.msg-header {
    font-weight: 700;
    margin: 12px 0 8px 0;
    line-height: 1.3;
    color: inherit;
}

.msg h1.msg-header {
    font-size: 1.3em;
    border-bottom: 2px solid rgba(0, 0, 0, 0.1);
    padding-bottom: 6px;
}

.msg h2.msg-header {
    font-size: 1.15em;
}

.msg h3.msg-header {
    font-size: 1.05em;
}

/* Párrafos */
.msg-paragraph {
    margin: 8px 0;
    line-height: 1.6;
}

/* Espaciador entre secciones */
.msg-spacer {
    height: 12px;
}

/* Listas */
.msg-list-item {
    margin: 6px 0 6px 20px;
    line-height: 1.5;
    position: relative;
}

.msg-list-item::before {
    content: "•";
    position: absolute;
    left: -20px;
    color: var(--azul);
    font-weight: bold;
    font-size: 1.2em;
}

.msg-list-item.numbered::before {
    content: none;
}

/* Código inline */
.msg-code {
    background: rgba(0, 0, 0, 0.06);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 0.9em;
    color: #c7254e;
}

.msg.bot .msg-code {
    background: rgba(0, 0, 0, 0.05);
}

/* Links */
.msg-link {
    color: var(--azul);
    text-decoration: none;
    border-bottom: 1px solid var(--azul);
    transition: all 0.2s;
}

.msg-link:hover {
    color: #0097A7;
    border-bottom-color: #0097A7;
}

/* Negritas y cursivas */
.msg strong {
    font-weight: 600;
    color: inherit;
}

.msg em {
    font-style: italic;
    color: inherit;
}

/* Mejorar el espaciado general de los mensajes */
.msg.bot {
    padding: 16px 18px;
}

/* Eliminar margen del primer y último elemento */
.msg > *:first-child {
    margin-top: 0;
}

.msg > *:last-child {
    margin-bottom: 0;
}


/* Separador horizontal */
.msg-divider {
    border: none;
    border-top: 2px solid rgba(0, 0, 0, 0.1);
    margin: 16px 0;
}

/* Citas / Blockquotes */
.msg-quote {
    background: rgba(0, 188, 212, 0.08);
    border-left: 4px solid var(--azul);
    padding: 12px 16px;
    margin: 8px 0;
    border-radius: 4px;
    font-style: italic;
}

/* ==================== ESTILOS PARA TABLAS MARKDOWN ==================== */
.table-container {
    overflow-x: auto;
    margin: 1rem 0;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.markdown-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    font-size: 0.9em;
    min-width: 400px;
}

.markdown-table th {
    background: linear-gradient(135deg, #DA291C, #FF6B6B);
    color: white;
    font-weight: 600;
    padding: 12px 15px;
    text-align: left;
    border-bottom: 2px solid #dee2e6;
}

.markdown-table td {
    padding: 10px 15px;
    border-bottom: 1px solid #e9ecef;
    color: #495057;
}

.markdown-table tr:last-child td {
    border-bottom: none;
}

.markdown-table tr:hover {
    background-color: #f8f9fa;
}

.markdown-table th:first-child,
.markdown-table td:first-child {
    border-top-left-radius: 8px;
    border-bottom-left-radius: 8px;
}

.markdown-table th:last-child,
.markdown-table td:last-child {
    border-top-right-radius: 8px;
    border-bottom-right-radius: 8px;
}

/* Responsive */
@media (max-width: 768px) {
    .markdown-table {
        font-size: 0.8em;
    }
    
    .markdown-table th,
    .markdown-table td {
        padding: 8px 10px;
    }
}


/* ==================== MEJORAS PARA TAREAS EN SIDEBAR ==================== */
.empty-task-message {
    color: #999;
    font-style: italic;
    text-align: center;
    padding: 10px;
    font-size: 13px;
}

/* Mejorar visibilidad de las tareas */
.tasks-container.active {
    display: block;
    animation: slideDown 0.3s ease;
}

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










/* ESTILOS AGREADOS ++++++++++++++++++++++++++++++++++++++++++++++ */




/* Badge para contador de tareas */
.nav-item .task-badge {
    background: var(--rojo);
    color: white;
    border-radius: 10px;
    padding: 2px 6px;
    font-size: 11px;
    margin-left: auto;
}

/* Mejorar hover en items de tareas */
.task-item:hover {
    background: rgba(0, 188, 212, 0.05);
    transform: translateX(2px);
    transition: all 0.2s ease;
}

.nav-item {
  text-decoration: none; /* quita el subrayado */
  color: inherit;        /* mantiene el color del texto */
  display: flex;         /* opcional, para alinear icono + texto */
  align-items: center;   /* centra verticalmente el svg con el texto */
  gap: 6px;              /* espacio entre el icono y el texto */
}


/* ==================== CONTADOR DE TOKENS ==================== */
.token-counter {
    font-size: 11px;
    color: #999;
    text-align: right;
    margin-top: 4px;
    margin-bottom: 8px;
    padding-right: 8px;
    transition: color 0.3s ease;
    user-select: none;
}

.token-counter #currentTokens {
    font-weight: 600;
}

.token-counter #maxTokens {
    opacity: 0.7;
}

/* Ajustes al botón deshabilitado */
.send-btn-icon:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

/* Responsive */
@media (max-width: 768px) {
    .token-counter {
        font-size: 10px;
    }
}


/* Estilos para elementos deshabilitados */
.nav-item.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

.nav-item.disabled:hover {
    background-color: transparent;
    color: var(--text-color);
}


/* Estilos para Material Icons */
.material-symbols-outlined {
    font-variation-settings:
    'FILL' 0,
    'wght' 400,
    'GRAD' 0,
    'opsz' 24;
    vertical-align: middle;
    font-size: 20px;
    margin-right: 6px;
}

.task-header .material-symbols-outlined {
    font-size: 18px;
    margin-right: 8px;
}

.send-btn-icon .material-symbols-outlined {
    font-size: 18px;
}

.send-btn-icon {
    background: var(--azul);
    color: var(--blanco);
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: all 0.2s;
}

.send-btn-icon .material-symbols-outlined {
    font-size: 22px;
    line-height: 1;
    margin: 0; /* Eliminar el margin-right que se aplicó globalmente */
}

/* ==================== AVATARES EN MENSAJES ==================== */
.message-container {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    margin-bottom: 12px;
    animation: fadeIn 0.3s ease;
}

.message-container.user {
    flex-direction: row-reverse; /* Usuario a la derecha */
}

.message-container.bot {
    flex-direction: row; /* Bot a la izquierda */
}

.message-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}

/* Avatar del BOT (Logo Claro) */
.message-avatar.bot {
    background: white; /* Fondo blanco para el logo */
    padding: 6px;
    border: 2px solid #f0f0f0;
}

.message-avatar.bot img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block; /* Elimina espacios extra */
}

/* Avatar del USUARIO */
.message-avatar.user {
    background: linear-gradient(135deg, #00BCD4, #0097A7);
    color: white;
}

.message-avatar.user .material-symbols-outlined {
    font-size: 24px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.message-content {
    display: flex;
    flex-direction: column;
    max-width: 75%;
      min-width: 0; 
}

/* NUEVO: Expandir el contenedor cuando tiene video */
.message-content:has(.message-media-viewer) {
    max-width: 90%;
}

@media (max-width: 768px) {
    .message-content:has(.message-media-viewer) {
        max-width: 95%;
    }
}

/* Ajustar el estilo de los mensajes */
.msg {
    padding: 12px 16px;
    border-radius: 16px;
    line-height: 1.5;
    font-size: 15px;
    width: 100%;
     word-wrap: break-word; /* NUEVO: Romper palabras largas */
    overflow-wrap: break-word; /* NUEVO: Mejor compatibilidad */
    white-space: pre-wrap; /* NUEVO: Respetar saltos de línea */
}

.msg.user {
    background: #E0F7FA;
    color: #006064;
    border-radius: 16px 16px 4px 16px;
    max-width: none; 
}

.msg.bot {
    background: var(--blanco);
    color: var(--texto-oscuro);
    border-radius: 16px 16px 16px 4px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
    max-width: none;
}

/* Responsive */
@media (max-width: 768px) {
    .message-avatar {
        width: 36px;
        height: 36px;
    }
    
    .message-avatar.user .material-symbols-outlined {
        font-size: 22px;
    }
    
    .message-content {
        max-width: 70%;
    }
}


/* Avatar del USUARIO - CORREGIDO */
.message-avatar.user {
    background: linear-gradient(135deg, #00BCD4, #0097A7);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
}

.message-avatar.user .material-symbols-outlined {
    font-size: 26px;
    line-height: 1;
    font-weight: 400;
    display: block;
    margin: 0;
    padding: 0;
    text-align: center;
}


/* ==================== MODAL PREMIUM ==================== */
.premium-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    animation: fadeIn 0.3s ease;
}

.premium-overlay.active {
    display: flex;
}

.premium-modal {
    background: white;
    border-radius: 20px;
    max-width: 500px;
    width: 90%;
    box-shadow: 0 20px 60px rgba(0, 188, 212, 0.3);
    overflow: hidden;
    animation: slideUp 0.4s ease;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(50px) scale(0.9);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Header del Modal */
.premium-header {
    background: linear-gradient(135deg, #00BCD4, #0097A7);
    padding: 30px 20px;
    text-align: center;
    color: white;
    position: relative;
}

.premium-icon {
    width: 80px;
    height: 80px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 15px;
    border: 3px solid rgba(255, 255, 255, 0.3);
}

.premium-icon .material-symbols-outlined {
    font-size: 48px;
    color: white;
    font-variation-settings: 'FILL' 1;
}

.premium-header h2 {
    font-size: 24px;
    font-weight: 700;
    margin: 0;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

/* Body del Modal */
.premium-body {
    padding: 30px 25px;
    text-align: center;
}

.premium-message {
    font-size: 16px;
    color: var(--texto-oscuro);
    margin-bottom: 10px;
    line-height: 1.6;
}

.premium-subtitle {
    font-size: 14px;
    color: var(--texto-claro);
    margin-bottom: 25px;
    line-height: 1.5;
}

/* Features */
.premium-features {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-top: 20px;
}

.feature-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px;
    background: #E0F7FA;
    border-radius: 10px;
    font-size: 13px;
    color: #006064;
    font-weight: 500;
}

.feature-item .material-symbols-outlined {
    font-size: 20px;
    color: #00BCD4;
    font-variation-settings: 'FILL' 1;
}

/* Footer del Modal */
.premium-footer {
    padding: 20px 25px 25px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.btn-premium {
    background: linear-gradient(135deg, #00BCD4, #0097A7);
    color: white;
    border: none;
    padding: 15px 30px;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0, 188, 212, 0.3);
}

.btn-premium:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 188, 212, 0.4);
}

.btn-premium .material-symbols-outlined {
    font-size: 22px;
    font-variation-settings: 'FILL' 1;
}

.btn-close-premium {
    background: transparent;
    color: var(--texto-claro);
    border: 2px solid var(--gris-borde);
    padding: 12px 30px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-close-premium:hover {
    background: var(--gris-fondo);
    border-color: var(--texto-claro);
}

/* Responsive */
@media (max-width: 768px) {
    .premium-modal {
        max-width: 95%;
    }
    
    .premium-features {
        grid-template-columns: 1fr;
    }
    
    .premium-header h2 {
        font-size: 20px;
    }
    
    .premium-icon {
        width: 70px;
        height: 70px;
    }
    
    .premium-icon .material-symbols-outlined {
        font-size: 40px;
    }
}


/* ==================== INPUT DESHABILITADO ==================== */
.input-wrapper input:disabled {
    background-color: #f5f5f5;
    color: #999;
    cursor: not-allowed;
}

.input-wrapper input:disabled::placeholder {
    color: #da291c;
    font-weight: 500;
}

.send-btn-icon:disabled {
    background: #ccc !important;
    cursor: not-allowed !important;
    opacity: 0.5 !important;
}

.send-btn-icon:disabled:hover {
    transform: none !important;
}


/* ==================== INPUT EN ESTADO DE LÍMITE ==================== */
.input-wrapper input.limit-reached {
    cursor: pointer !important;
    font-weight: 500;
    color: #DA291C !important;
    background-color: #fff5f5 !important;
}

.input-wrapper input.limit-reached::placeholder {
    color: #DA291C;
    font-weight: 600;
    cursor: pointer;
}

.input-wrapper input.limit-reached:hover {
    background-color: #ffe5e5 !important;
}

.input-wrapper:has(input.limit-reached) {
    border-color: #DA291C;
}

.task-download {
    position: absolute;
    bottom: 5px;
    right: 8px;        /* ANTES: 25px → AHORA: 35px */
    background: #00BCD4;
    border: none;
    color: white;
    cursor: pointer;
    font-size: 14px;
    padding: 4px 8px;
    border-radius: 4px;
    transition: all 0.2s;
}

.task-download:hover {
    background: #0097A7;
    transform: scale(1.1);

}


/* ============================================
   CHIP DE MODO ACTIVO
   ============================================ */

.mode-chip-container {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 12px;
    animation: slideDown 0.3s ease-out;
    position: relative;
    z-index: 10;
}

.mode-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: #E0F7FA;
    color: #00ACC1;
    padding: 8px 14px;
    border-radius: 24px;
    font-size: 13px;
    font-weight: 500;
    box-shadow: 0 2px 6px rgba(0, 172, 193, 0.15);
    border: 1px solid #B2EBF2;
    transition: all 0.3s ease;
}

.mode-chip:hover {
    background: #B2EBF2;
    box-shadow: 0 3px 8px rgba(0, 172, 193, 0.25);
}

.mode-chip-icon {
    width: 18px;
    height: 18px;
    color: #00ACC1;
    stroke: currentColor;
    flex-shrink: 0;
}

#modeChipText {
    color: #00ACC1;
    font-weight: 500;
    user-select: none;
}

.mode-chip-close {
    background: transparent;
    border: none;
    color: #00ACC1;
    cursor: pointer;
    font-size: 18px;
    font-weight: 600;
    padding: 0;
    margin-left: 4px;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s ease;
}

.mode-chip-close:hover {
    background: rgba(0, 172, 193, 0.15);
    color: #00838F;
    transform: scale(1.1);
}

.mode-chip-close:active {
    transform: scale(0.95);
}

/* Animación de entrada */
@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Responsive para móviles */
@media (max-width: 600px) {
    .mode-chip {
        font-size: 13px;
        padding: 8px 14px;
        gap: 6px;
    }
    
    .mode-chip-icon {
        width: 16px;
        height: 16px;
    }
    
    .mode-chip-close {
        font-size: 16px;
        width: 18px;
        height: 18px;
    }
}


/* Ícono de letra "A" para Aprende.org */
.mode-chip-icon-letter {
    width: 24px;
    height: 24px;
    background: #DA291C;
    color: white;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
    flex-shrink: 0;
    font-family: 'Roboto', sans-serif;
}

/* Mantener el SVG original para otros modos */
.mode-chip-icon {
    width: 18px;
    height: 18px;
    color: #00ACC1;
    stroke: currentColor;
    flex-shrink: 0;
}


/* Contenedor flexible para íconos dinámicos */
.mode-chip-icon-container {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}