/* ============ TUTOR IA - MATEOS ============ */

/* Botón flotante */
.tutor-fab {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    color: white;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(67, 97, 238, 0.4);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.6rem;
    transition: var(--transition);
}

.tutor-fab:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 28px rgba(67, 97, 238, 0.5);
}

.tutor-fab.hidden { display: none; }

/* Panel del chat — pantalla completa */
.tutor-panel {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    max-height: none;
    background: var(--card);
    border-radius: 0;
    box-shadow: none;
    z-index: 300;
    display: flex;
    flex-direction: column;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
}

.tutor-panel.open {
    opacity: 1;
    pointer-events: auto;
}

/* Header del chat */
.tutor-header {
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    color: white;
    padding: 14px 32px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-radius: 0;
    flex-shrink: 0;
}

.tutor-header-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.tutor-header-avatar {
    width: 36px;
    height: 36px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
}

.tutor-header-name {
    font-weight: 800;
    font-size: 1rem;
}

.tutor-header-status {
    font-size: 0.75rem;
    opacity: 0.8;
}

.tutor-close {
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: white;
    height: 36px;
    border-radius: 18px;
    font-size: 0.85rem;
    font-family: 'Nunito', sans-serif;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 16px;
    gap: 6px;
    transition: var(--transition);
}

.tutor-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Área de mensajes */
.tutor-messages {
    flex: 1;
    overflow-y: auto;
    padding: 24px 32px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    scroll-behavior: smooth;
    max-width: 860px;
    width: 100%;
    margin: 0 auto;
}

/* Burbuja de mensaje */
.tutor-msg {
    max-width: 85%;
    padding: 14px 18px;
    border-radius: 16px;
    font-size: 1rem;
    line-height: 1.65;
    animation: fadeIn 0.25s ease;
}

.tutor-msg.user {
    align-self: flex-end;
    background: var(--primary);
    color: white;
    border-bottom-right-radius: 4px;
}

.tutor-msg.assistant {
    align-self: flex-start;
    background: var(--bg);
    color: var(--dark);
    border-bottom-left-radius: 4px;
}

.tutor-msg.assistant strong {
    color: var(--primary);
}

/* Hint colapsable */
.tutor-hint {
    background: #FFF8E1;
    border: 1px solid var(--warning);
    border-radius: var(--radius-sm);
    margin-top: 8px;
    overflow: hidden;
}

.tutor-hint-toggle {
    padding: 8px 12px;
    cursor: pointer;
    font-weight: 700;
    font-size: 0.85rem;
    color: #F59E0B;
    display: flex;
    align-items: center;
    gap: 6px;
}

.tutor-hint-toggle::before {
    content: '💡';
}

.tutor-hint-content {
    padding: 0 12px 10px;
    font-size: 0.88rem;
    display: none;
}

.tutor-hint.open .tutor-hint-content {
    display: block;
}

/* Pregunta siguiente */
.tutor-next-question {
    background: #EDE9FE;
    border: 1px solid #C4B5FD;
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    margin-top: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    color: #6D28D9;
}

.tutor-next-question::before {
    content: '🤔 ';
}

/* Botones de acción post-respuesta */
.tutor-actions {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--gray-lighter);
}

.tutor-action-btn {
    background: white;
    border: 1.5px solid var(--gray-lighter);
    border-radius: 20px;
    padding: 6px 14px;
    font-size: 0.8rem;
    font-family: 'Nunito', sans-serif;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition);
    color: var(--dark);
}

.tutor-action-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: #F0F4FF;
}

.tutor-action-answer {
    border-color: var(--primary-light);
    color: var(--primary);
}

.tutor-action-done {
    border-color: var(--success);
    color: #047857;
}

.tutor-action-done:hover {
    background: var(--success-light);
    border-color: var(--success);
    color: #047857;
}

/* Encouragement */
.tutor-encouragement {
    font-size: 0.85rem;
    color: var(--success);
    font-weight: 700;
    margin-top: 4px;
}

/* Fórmulas KaTeX */
.tutor-math {
    background: #F8FAFC;
    border: 1px solid var(--gray-lighter);
    border-radius: var(--radius-sm);
    padding: 14px 20px;
    margin: 10px 0;
    text-align: center;
    overflow-x: auto;
    font-size: 1.15rem;
}

/* Step by step */
.tutor-steps {
    margin-top: 10px;
}

.tutor-step {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 6px 0;
    font-size: 0.88rem;
}

.tutor-step-icon {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    flex-shrink: 0;
    margin-top: 1px;
}

.tutor-step.completed .tutor-step-icon {
    background: var(--success);
    color: white;
}

.tutor-step.pending .tutor-step-icon {
    background: var(--gray-lighter);
    color: var(--gray);
}

.tutor-step.current .tutor-step-icon {
    background: var(--primary);
    color: white;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(67, 97, 238, 0.4); }
    50% { box-shadow: 0 0 0 6px rgba(67, 97, 238, 0); }
}

/* Recta numérica en el chat */
.tutor-numberline {
    margin: 10px 0;
    padding: 14px;
    background: #F8FAFC;
    border-radius: var(--radius-sm);
    border: 1px solid var(--gray-lighter);
}

/* Block Groups (divisores, repartos, fracciones) */
.tutor-block-groups {
    margin: 12px 0;
    padding: 16px;
    background: #F8FAFC;
    border-radius: var(--radius-sm);
    border: 1px solid var(--gray-lighter);
}

.tutor-bg-title {
    font-weight: 700;
    font-size: 0.9rem;
    margin-bottom: 12px;
    color: var(--dark);
}

.tutor-bg-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 0;
    border-bottom: 1px solid var(--gray-lighter);
}

.tutor-bg-row:last-child {
    border-bottom: none;
}

.tutor-bg-label {
    font-weight: 700;
    font-size: 0.85rem;
    min-width: 120px;
    color: var(--secondary);
}

.tutor-bg-visual {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.tutor-bg-bag {
    display: flex;
    gap: 3px;
    padding: 6px 10px;
    background: white;
    border: 2px solid var(--primary-light);
    border-radius: 10px;
}

.tutor-bg-item {
    font-size: 0.9rem;
}

/* Selectable Options (quiz visual) */
.tutor-selectable {
    margin: 12px 0;
}

.tutor-sel-question {
    font-weight: 700;
    font-size: 0.92rem;
    margin-bottom: 10px;
    color: var(--dark);
}

.tutor-sel-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 10px;
}

.tutor-sel-option {
    background: white;
    border: 2px solid var(--gray-lighter);
    border-radius: var(--radius-sm);
    padding: 12px;
    cursor: pointer;
    text-align: center;
    font-family: 'Nunito', sans-serif;
    font-size: 0.9rem;
    transition: var(--transition);
}

.tutor-sel-option:hover {
    border-color: var(--primary);
    background: #F0F4FF;
    transform: translateY(-2px);
}

.tutor-sel-option.selected-correct {
    border-color: var(--success);
    background: var(--success-light);
}

.tutor-sel-option.selected-wrong {
    border-color: var(--error);
    background: var(--error-light);
    animation: shake 0.4s ease;
}

.tutor-sel-visual {
    font-size: 1.3rem;
    margin-bottom: 6px;
    line-height: 1.4;
}

.tutor-sel-text {
    font-weight: 700;
    font-size: 0.85rem;
}

.tutor-nl-track {
    position: relative;
    height: 50px;
    margin: 10px 0;
}

.tutor-nl-line {
    position: absolute;
    top: 24px;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--dark);
}

.tutor-nl-tick {
    position: absolute;
    top: 16px;
    transform: translateX(-50%);
    text-align: center;
}

.tutor-nl-tick::before {
    content: '';
    display: block;
    width: 2px;
    height: 16px;
    background: var(--dark);
    margin: 0 auto 4px;
}

.tutor-nl-tick span {
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--dark);
}

.tutor-nl-point {
    position: absolute;
    top: 6px;
    transform: translateX(-50%);
    text-align: center;
}

.tutor-nl-dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    margin: 0 auto 2px;
}

.tutor-nl-point .tutor-nl-label {
    font-size: 0.68rem;
    font-weight: 700;
    white-space: nowrap;
}

.tutor-nl-arrow {
    position: absolute;
    top: 2px;
    height: 20px;
    border: 2px dashed;
    border-bottom: none;
    border-radius: 20px 20px 0 0;
}

.tutor-nl-arrow-label {
    position: absolute;
    top: -14px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.7rem;
    font-weight: 800;
    white-space: nowrap;
}

/* Typing indicator */
.tutor-typing {
    align-self: flex-start;
    padding: 10px 18px;
    background: var(--bg);
    border-radius: 14px;
    display: flex;
    gap: 4px;
}

.tutor-typing-dot {
    width: 8px;
    height: 8px;
    background: var(--gray-light);
    border-radius: 50%;
    animation: typingBounce 1.2s infinite;
}

.tutor-typing-dot:nth-child(2) { animation-delay: 0.15s; }
.tutor-typing-dot:nth-child(3) { animation-delay: 0.3s; }

@keyframes typingBounce {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-6px); }
}

/* Input area */
.tutor-input-area {
    padding: 16px 32px;
    border-top: 1px solid var(--gray-lighter);
    display: flex;
    gap: 10px;
    flex-shrink: 0;
    background: var(--card);
    max-width: 860px;
    width: 100%;
    margin: 0 auto;
}

.tutor-input {
    flex: 1;
    border: 2px solid var(--gray-lighter);
    border-radius: 24px;
    padding: 12px 20px;
    font-family: 'Nunito', sans-serif;
    font-size: 1rem;
    outline: none;
    transition: var(--transition);
}

.tutor-input:focus {
    border-color: var(--primary);
}

.tutor-send {
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 50%;
    width: 42px;
    height: 42px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    transition: var(--transition);
    flex-shrink: 0;
}

.tutor-send:hover {
    background: var(--primary-dark);
}

.tutor-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Overlay oscuro (móvil) */
.tutor-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 250;
}

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

/* Mensaje de bienvenida */
.tutor-welcome {
    text-align: center;
    padding: 20px;
    color: var(--gray);
}

.tutor-welcome-icon {
    font-size: 2.5rem;
    margin-bottom: 8px;
}

.tutor-welcome h3 {
    color: var(--dark);
    margin-bottom: 4px;
}

.tutor-welcome p {
    font-size: 0.85rem;
}

/* Sugerencias rápidas */
.tutor-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    justify-content: center;
    margin-top: 12px;
}

.tutor-suggestion {
    background: white;
    border: 1.5px solid var(--primary-light);
    border-radius: 20px;
    padding: 6px 14px;
    font-size: 0.8rem;
    color: var(--primary);
    cursor: pointer;
    transition: var(--transition);
    font-family: 'Nunito', sans-serif;
    font-weight: 600;
}

.tutor-suggestion:hover {
    background: var(--primary);
    color: white;
}

/* Responsive móvil */
@media (max-width: 600px) {
    .tutor-messages {
        padding: 16px;
    }

    .tutor-input-area {
        padding: 12px 16px;
    }

    .tutor-header {
        padding: 12px 16px;
    }

    .tutor-msg {
        max-width: 95%;
        font-size: 0.95rem;
    }

    .tutor-fab {
        bottom: 16px;
        right: 16px;
        width: 52px;
        height: 52px;
        font-size: 1.4rem;
    }
}
