/* ============ Burbuja flotante + ondas pulsantes ============ */
#ac-chat-bubble-wrap {
    position: fixed;
    bottom: 90px;
    right: 20px;
    width: 60px;
    height: 60px;
    z-index: 999998;
}

.ac-pulse-ring {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 2px solid var(--ac-pulse-color, #1a1a2e);
    animation: ac-pulse 2.2s ease-out infinite;
    pointer-events: none;
}

.ac-pulse-ring.ac-delay {
    animation-delay: 1.1s;
}

@keyframes ac-pulse {
    0%   { transform: scale(1);   opacity: 0.55; }
    100% { transform: scale(1.7); opacity: 0; }
}

#ac-chat-bubble {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border: none;
    background: var(--ac-bubble-color, #1a1a2e);
    color: var(--ac-bubble-icon-color, #ffffff);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(0,0,0,0.2);
}

#ac-chat-bubble svg {
    width: 30px;
    height: 30px;
}

/* ============ Ventana de chat ============ */
#ac-chat-window {
    position: fixed;
    bottom: 160px;
    right: 20px;
    width: 320px;
    max-width: 90vw;
    height: 440px;
    max-height: 70vh;
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 8px 28px rgba(0,0,0,0.28);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 999999;
    font-family: -apple-system, Arial, sans-serif;

    opacity: 0;
    transform: scale(0.85) translateY(16px);
    transform-origin: bottom right;
    pointer-events: none;
    transition: opacity 0.22s ease, transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

#ac-chat-window.ac-open {
    opacity: 1;
    transform: scale(1) translateY(0);
    pointer-events: auto;
}

/* ============ Encabezado ============ */
#ac-chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 12px 14px;
    background: var(--ac-header-bg, #1a1a2e);
    color: var(--ac-header-text, #ffffff);
    flex-shrink: 0;
}

.ac-header-info {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.ac-header-logo {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    object-fit: cover;
    background: #fff;
    flex-shrink: 0;
}

.ac-header-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.ac-header-name {
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ac-header-status {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
    opacity: 0.9;
}

.ac-status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--ac-status-dot, #3ddc84);
    flex-shrink: 0;
}

.ac-header-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.ac-header-btn {
    background: #ffffff;
    border: none;
    border-radius: 50%;
    color: var(--ac-header-bg, #1a1a2e);
    cursor: pointer;
    width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    opacity: 0.92;
    box-shadow: 0 1px 3px rgba(0,0,0,0.25);
    transition: opacity 0.15s, transform 0.15s;
}

.ac-header-btn svg {
    width: 13px;
    height: 13px;
}

.ac-header-btn:hover {
    opacity: 1;
    transform: scale(1.08);
}

/* ============ Panel de elegir curso/correo (Resumen→correo) o sección (Resumen→qué resumir) ============ */
#ac-email-panel,
#ac-summary-panel,
#ac-print-panel,
#ac-exercise-panel,
#ac-evaluation-panel {
    display: none;
    flex-direction: column;
    gap: 6px;
    padding: 8px 10px;
    background: #f3f6ef;
    border-bottom: 1px solid #e2e2e2;
    flex-shrink: 0;
}

#ac-email-panel .ac-email-row,
#ac-summary-panel .ac-email-row,
#ac-print-panel .ac-email-row,
#ac-exercise-panel .ac-email-row,
#ac-evaluation-panel .ac-email-row {
    display: flex;
    align-items: center;
    gap: 6px;
}

#ac-email-panel .ac-email-row:first-child,
#ac-summary-panel .ac-email-row:first-child,
#ac-print-panel .ac-email-row:first-child,
#ac-exercise-panel .ac-email-row:first-child,
#ac-evaluation-panel .ac-email-row:first-child {
    flex: 1;
}

#ac-email-panel select,
#ac-email-panel input[type="email"],
#ac-summary-panel select,
#ac-exercise-panel select,
#ac-exercise-panel input[type="text"],
#ac-evaluation-panel select,
#ac-evaluation-panel input[type="text"] {
    flex: 1;
    min-width: 0;
    padding: 5px 6px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 13px;
}

#ac-email-panel .ac-email-or {
    font-size: 12px;
    color: #888;
    flex-shrink: 0;
}

#ac-email-panel .ac-email-checkbox-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: #444;
    cursor: pointer;
}

#ac-email-panel .ac-email-actions,
#ac-summary-panel .ac-email-actions,
#ac-print-panel .ac-email-actions,
#ac-exercise-panel .ac-email-actions,
#ac-evaluation-panel .ac-email-actions {
    justify-content: flex-end;
}

#ac-email-panel #ac-email-send-btn,
#ac-summary-panel #ac-summary-confirm-btn,
#ac-print-panel #ac-print-confirm-btn,
#ac-exercise-panel #ac-exercise-generate-btn,
#ac-evaluation-panel #ac-eval-create-btn {
    background: var(--ac-header-bg, #1a1a2e);
    color: var(--ac-header-text, #ffffff);
    border: none;
    border-radius: 4px;
    padding: 6px 12px;
    font-size: 13px;
    cursor: pointer;
    flex-shrink: 0;
}

/* Barra de "ejercicio activo" — con el botón de mostrar solución */
#ac-exercise-active-bar {
    display: none;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 6px 10px;
    background: #fff8e6;
    border-bottom: 1px solid #f0e0b0;
    font-size: 12px;
    color: #6b5a2a;
    flex-shrink: 0;
}

#ac-exercise-reveal-btn {
    background: none;
    border: 1px solid #c9b46a;
    border-radius: 4px;
    padding: 3px 8px;
    font-size: 12px;
    color: #6b5a2a;
    cursor: pointer;
    flex-shrink: 0;
}

.ac-eval-tipos-row {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 12px;
}

.ac-eval-tipos-row label {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    color: #444;
    cursor: pointer;
    white-space: nowrap;
}

#ac-email-panel #ac-email-cancel-btn,
#ac-summary-panel #ac-summary-cancel-btn,
#ac-print-panel #ac-print-cancel-btn {
    background: none;
    border: none;
    color: #666;
    cursor: pointer;
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    padding: 0;
}

#ac-email-panel #ac-email-cancel-btn svg,
#ac-summary-panel #ac-summary-cancel-btn svg,
#ac-print-panel #ac-print-cancel-btn svg {
    width: 12px;
    height: 12px;
}

/* ============ Ventana minimizada (solo encabezado visible) ============ */
#ac-chat-window.ac-minimized {
    height: auto !important;
}

#ac-chat-window.ac-minimized #ac-chat-messages,
#ac-chat-window.ac-minimized #ac-mode-row,
#ac-chat-window.ac-minimized #ac-exercise-panel,
#ac-chat-window.ac-minimized #ac-evaluation-panel,
#ac-chat-window.ac-minimized #ac-exercise-active-bar,
#ac-chat-window.ac-minimized #ac-chat-input-row {
    display: none;
}

/* ============ Ventana ampliada ============ */
#ac-chat-window.ac-expanded {
    width: 420px;
    height: 640px;
    max-height: 85vh;
}

/* ============ Mensajes ============ */
#ac-chat-messages {
    flex: 1;
    padding: 12px;
    overflow-y: auto;
    font-size: 14px;
    line-height: 1.4;
}

.ac-msg {
    margin-bottom: 10px;
    padding: 8px 12px;
    border-radius: 10px;
    max-width: 85%;
    white-space: pre-wrap;
}

.ac-msg-user {
    background: var(--ac-header-bg, #1a1a2e);
    color: var(--ac-header-text, #ffffff);
    margin-left: auto;
}

.ac-msg-bot {
    background: #f0f0f2;
    color: #1a1a1a;
}

/* ============ Indicador de "escribiendo..." ============ */
.ac-typing {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 12px 14px;
    width: fit-content;
}

.ac-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #7A4928;
    animation: ac-bounce 1.2s infinite ease-in-out;
}

.ac-dot:nth-child(2) {
    animation-delay: 0.15s;
}

.ac-dot:nth-child(3) {
    animation-delay: 0.3s;
}

@keyframes ac-bounce {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.5;
    }
    30% {
        transform: translateY(-4px);
        opacity: 1;
    }
}

/* ============ Modo (Chat / Tutor) ============ */
#ac-mode-row {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-top: 1px solid #eee;
    flex-shrink: 0;
    font-size: 12px;
    color: #666;
}

#ac-mode-row label {
    font-weight: 600;
}

#ac-mode-select {
    font-size: 12px;
    padding: 2px 6px;
    border: 1px solid #ddd;
    border-radius: 6px;
    background: #fff;
    color: #333;
    cursor: pointer;
}

/* ============ Input ============ */
#ac-chat-input-row {
    display: flex;
    align-items: center;
    border-top: 1px solid #eee;
    flex-shrink: 0;
}

#ac-chat-mic {
    background: none;
    border: none;
    color: var(--ac-header-bg, #1a1a2e);
    cursor: pointer;
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    box-shadow: none;
    opacity: 0.75;
}

#ac-chat-mic:hover {
    opacity: 1;
    transform: none;
}

#ac-chat-mic svg {
    width: 18px;
    height: 18px;
}

#ac-chat-mic.ac-recording {
    color: #d63638;
    opacity: 1;
    animation: ac-mic-pulse 1.2s ease-in-out infinite;
}

@keyframes ac-mic-pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.15); }
}

#ac-chat-input {
    flex: 1;
    border: none;
    padding: 10px 12px;
    font-size: 14px;
    outline: none;
}

#ac-chat-send {
    box-sizing: border-box !important;

    display: flex !important;
    align-items: center !important;
    justify-content: center !important;

    flex: 0 0 72px !important;

    width: 72px !important;
    min-width: 72px !important;
    max-width: 72px !important;

    height: 40px !important;
    min-height: 40px !important;
    max-height: 40px !important;

    margin: 0 !important;
    padding: 0 !important;

    border: 0 !important;

    border-radius: 0 0 14px 0 !important;

    background: var(--ac-bubble-color, #1a1a2e) !important;
    color: var(--ac-bubble-icon-color, #ffffff) !important;

    cursor: pointer;

    font-family: inherit;
    font-size: 14px !important;
    font-weight: 400;

    line-height: 40px !important;

    text-align: center;
    vertical-align: middle;

    box-shadow: none !important;
    transform: none !important;

    appearance: none;
    -webkit-appearance: none;
}