/* ============================================
   CHATBOT DE AYUDA UNSM - ESTILOS
   Asistente virtual flotante responsive
   ============================================ */

/* ============================================
   VARIABLES
   ============================================ */
:root {
    --chatbot-primary: var(--color-primary, #359444);
    --chatbot-primary-dark: var(--color-primary-dark, #2a7a35);
    --chatbot-primary-light: var(--color-primary-light, #4caf50);
    --chatbot-white: var(--color-white, #ffffff);
    --chatbot-bg-light: var(--color-bg-light, #f5f5f5);
    --chatbot-text: var(--color-text, #333333);
    --chatbot-shadow: 0 4px 12px rgba(53, 148, 68, 0.3);
    --chatbot-z-index: 9999;
}

/* ============================================
   BOTÓN FLOTANTE
   ============================================ */
.chatbot__button {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--chatbot-primary) 0%, var(--chatbot-primary-dark) 100%);
    border: none;
    box-shadow: var(--chatbot-shadow);
    cursor: pointer;
    z-index: var(--chatbot-z-index);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.chatbot__button:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(53, 148, 68, 0.4);
}

.chatbot__button:active {
    transform: scale(0.95);
}

.chatbot__button:focus {
    outline: 3px solid var(--chatbot-primary-light);
    outline-offset: 3px;
}

/* Ícono del botón */
.chatbot__icon {
    width: 28px;
    height: 28px;
    color: var(--chatbot-white);
    transition: all 0.3s ease;
}

.chatbot__icon--close {
    display: none;
}

.chatbot__button--active .chatbot__icon {
    display: none;
}

.chatbot__button--active .chatbot__icon--close {
    display: block;
}

/* Animación de pulso inicial */
@keyframes pulse {
    0%, 100% {
        box-shadow: 0 4px 12px rgba(53, 148, 68, 0.3);
    }
    50% {
        box-shadow: 0 4px 20px rgba(53, 148, 68, 0.6);
        transform: scale(1.02);
    }
}

.chatbot__button--pulse {
    animation: pulse 2s ease-in-out 3;
}

/* ============================================
   VENTANA DE CHAT
   ============================================ */
.chatbot__window {
    position: fixed;
    bottom: 90px;
    right: 20px;
    width: 380px;
    height: 600px;
    background: var(--chatbot-white);
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    z-index: calc(var(--chatbot-z-index) - 1);
    display: flex;
    flex-direction: column;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.chatbot__window--open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* ============================================
   HEADER
   ============================================ */
.chatbot__header {
    background: linear-gradient(135deg, var(--chatbot-primary) 0%, var(--chatbot-primary-dark) 100%);
    color: var(--chatbot-white);
    padding: 20px;
    border-radius: 16px 16px 0 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.chatbot__header-content {
    display: flex;
    align-items: center;
    gap: 12px;
}

.chatbot__logo {
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.chatbot__logo svg {
    width: 24px;
    height: 24px;
}

.chatbot__header-text {
    flex: 1;
}

.chatbot__title {
    font-size: 16px;
    font-weight: 700;
    margin: 0 0 2px 0;
    line-height: 1.2;
}

.chatbot__subtitle {
    font-size: 12px;
    margin: 0;
    opacity: 0.9;
    line-height: 1.2;
}

.chatbot__close-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    padding: 0;
    flex-shrink: 0;
}

.chatbot__close-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: rotate(90deg);
}

.chatbot__close-btn:focus {
    outline: 2px solid var(--chatbot-white);
    outline-offset: 2px;
}

.chatbot__close-btn svg {
    color: var(--chatbot-white);
}

/* ============================================
   ÁREA DE MENSAJES
   ============================================ */
.chatbot__messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    background: var(--chatbot-white);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Scrollbar personalizado */
.chatbot__messages::-webkit-scrollbar {
    width: 6px;
}

.chatbot__messages::-webkit-scrollbar-track {
    background: var(--chatbot-bg-light);
}

.chatbot__messages::-webkit-scrollbar-thumb {
    background: var(--chatbot-primary);
    border-radius: 3px;
}

.chatbot__messages::-webkit-scrollbar-thumb:hover {
    background: var(--chatbot-primary-dark);
}

/* Mensaje individual */
.chatbot__message {
    display: flex;
    flex-direction: column;
    gap: 4px;
    max-width: 80%;
    animation: fadeInMessage 0.3s ease;
}

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

.chatbot__message--bot {
    align-self: flex-start;
}

.chatbot__message--user {
    align-self: flex-end;
}

/* Burbuja de mensaje */
.chatbot__bubble {
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
}

.chatbot__message--bot .chatbot__bubble {
    background: #E8F5E9;
    color: var(--chatbot-text);
    border-bottom-left-radius: 4px;
}

.chatbot__message--user .chatbot__bubble {
    background: var(--chatbot-primary);
    color: var(--chatbot-white);
    border-bottom-right-radius: 4px;
}

/* Timestamp */
.chatbot__timestamp {
    font-size: 11px;
    color: #999;
    padding: 0 8px;
}

.chatbot__message--bot .chatbot__timestamp {
    align-self: flex-start;
}

.chatbot__message--user .chatbot__timestamp {
    align-self: flex-end;
}

/* ============================================
   INDICADOR DE ESCRITURA (TYPING)
   ============================================ */
.chatbot__typing {
    padding: 0 20px 12px 20px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.chatbot__typing-dots {
    background: #E8F5E9;
    padding: 12px 16px;
    border-radius: 18px;
    display: flex;
    gap: 4px;
}

.chatbot__typing-dots span {
    width: 6px;
    height: 6px;
    background: var(--chatbot-primary);
    border-radius: 50%;
    animation: typing 1.4s infinite;
}

.chatbot__typing-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.chatbot__typing-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

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

.chatbot__typing-text {
    font-size: 11px;
    color: #999;
    margin: 0;
}

/* ============================================
   ACCIONES RÁPIDAS
   ============================================ */
.chatbot__quick-actions {
    padding: 12px 20px;
    border-top: 1px solid #f0f0f0;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    flex-shrink: 0;
}

.chatbot__quick-action {
    background: var(--chatbot-white);
    border: 2px solid var(--chatbot-primary);
    color: var(--chatbot-primary);
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.chatbot__quick-action:hover {
    background: var(--chatbot-primary);
    color: var(--chatbot-white);
    transform: translateY(-2px);
    box-shadow: 0 2px 8px rgba(53, 148, 68, 0.3);
}

.chatbot__quick-action:focus {
    outline: 2px solid var(--chatbot-primary);
    outline-offset: 2px;
}

.chatbot__quick-action:active {
    transform: translateY(0);
}

/* ============================================
   ÁREA DE INPUT
   ============================================ */
.chatbot__input-area {
    padding: 16px 20px;
    border-top: 1px solid #f0f0f0;
    display: flex;
    gap: 12px;
    align-items: center;
    background: var(--chatbot-white);
    border-radius: 0 0 16px 16px;
    flex-shrink: 0;
}

.chatbot__input {
    flex: 1;
    background: var(--chatbot-bg-light);
    border: 2px solid transparent;
    border-radius: 24px;
    padding: 12px 16px;
    font-size: 14px;
    color: var(--chatbot-text);
    transition: all 0.2s ease;
    font-family: inherit;
}

.chatbot__input::placeholder {
    color: #999;
}

.chatbot__input:focus {
    outline: none;
    border-color: var(--chatbot-primary);
    background: var(--chatbot-white);
}

.chatbot__send-btn {
    background: var(--chatbot-primary);
    border: none;
    border-radius: 50%;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    padding: 0;
    flex-shrink: 0;
}

.chatbot__send-btn:hover {
    background: var(--chatbot-primary-dark);
    transform: scale(1.05);
}

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

.chatbot__send-btn:focus {
    outline: 2px solid var(--chatbot-primary);
    outline-offset: 2px;
}

.chatbot__send-btn svg {
    color: var(--chatbot-white);
}

.chatbot__send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ============================================
   FOOTER
   ============================================ */
.chatbot__footer {
    padding: 8px 20px;
    border-top: 1px solid #f0f0f0;
    background: var(--chatbot-bg-light);
    border-radius: 0 0 16px 16px;
    flex-shrink: 0;
}

.chatbot__footer-text {
    font-size: 11px;
    color: #999;
    margin: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

.chatbot__footer-text svg {
    color: #999;
}

/* ============================================
   PREGUNTAS RELACIONADAS
   ============================================ */
.chatbot__related {
    margin-top: 12px;
    padding: 12px;
    background: #f9f9f9;
    border-radius: 12px;
}

.chatbot__related-title {
    font-size: 12px;
    font-weight: 600;
    color: var(--chatbot-text);
    margin: 0 0 8px 0;
}

.chatbot__related-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.chatbot__related-item {
    font-size: 13px;
    color: var(--chatbot-primary);
    cursor: pointer;
    transition: all 0.2s ease;
    padding: 6px 8px;
    border-radius: 6px;
}

.chatbot__related-item:hover {
    background: var(--chatbot-primary);
    color: var(--chatbot-white);
    padding-left: 12px;
}

.chatbot__related-item::before {
    content: "→ ";
    font-weight: 700;
}

/* ============================================
   RESPONSIVE - TABLET
   ============================================ */
@media (max-width: 768px) and (min-width: 481px) {
    .chatbot__window {
        width: 360px;
        height: 550px;
    }
}

/* ============================================
   RESPONSIVE - MÓVIL
   ============================================ */
@media (max-width: 480px) {
    .chatbot__button {
        width: 56px;
        height: 56px;
        bottom: 16px;
        right: 16px;
    }

    .chatbot__icon {
        width: 24px;
        height: 24px;
    }

    .chatbot__window {
        bottom: 0;
        right: 0;
        left: 0;
        top: 0;
        width: 100%;
        height: 100%;
        max-height: 100vh;
        border-radius: 0;
    }

    .chatbot__window--open {
        transform: translateY(0);
    }

    .chatbot__header {
        border-radius: 0;
        padding: 16px;
    }

    .chatbot__messages {
        padding: 16px;
    }

    .chatbot__quick-actions {
        padding: 12px 16px;
    }

    .chatbot__input-area {
        padding: 16px;
        border-radius: 0;
    }

    .chatbot__footer {
        border-radius: 0;
    }
}

/* ============================================
   ANIMACIONES ADICIONALES
   ============================================ */
@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

/* ============================================
   ACCESIBILIDAD
   ============================================ */
@media (prefers-reduced-motion: reduce) {
    .chatbot__button,
    .chatbot__window,
    .chatbot__message,
    .chatbot__quick-action {
        animation: none;
        transition: none;
    }
}

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

/* ============================================
   ESTADO DE CARGA
   ============================================ */
.chatbot__loading {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.chatbot__loading-spinner {
    width: 24px;
    height: 24px;
    border: 3px solid var(--chatbot-bg-light);
    border-top-color: var(--chatbot-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ============================================
   SELECCIÓN DE ROL
   ============================================ */
.chatbot__role-selection {
    margin: 0;
    padding: 0;
    background: transparent;
    align-items: stretch;
}

.chatbot__roles-container {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    padding: 8px 0;
    width: 100%;
}

.chatbot__role-button {
    background: var(--chatbot-white);
    border: 2px solid var(--chatbot-bg-light);
    border-radius: 12px;
    padding: 16px 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    min-height: 100px;
    position: relative;
    overflow: hidden;
}

.chatbot__role-button:hover {
    border-color: var(--chatbot-primary);
    background: linear-gradient(135deg, var(--chatbot-primary) 0%, var(--chatbot-primary-dark) 100%);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(53, 148, 68, 0.2);
}

.chatbot__role-button:hover .chatbot__role-icon {
    transform: scale(1.2);
}

.chatbot__role-button:hover .chatbot__role-name,
.chatbot__role-button:hover .chatbot__role-desc {
    color: var(--chatbot-white);
}

.chatbot__role-button:active {
    transform: translateY(0);
}

.chatbot__role-icon {
    font-size: 32px;
    transition: transform 0.3s ease;
    line-height: 1;
}

.chatbot__role-info {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    text-align: center;
}

.chatbot__role-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--chatbot-text);
    transition: color 0.3s ease;
}

.chatbot__role-desc {
    font-size: 11px;
    color: #666;
    transition: color 0.3s ease;
    line-height: 1.3;
}

/* Responsive para móvil */
@media (max-width: 768px) {
    .chatbot__roles-container {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .chatbot__role-button {
        flex-direction: row;
        justify-content: flex-start;
        padding: 14px;
        min-height: auto;
    }

    .chatbot__role-icon {
        font-size: 28px;
        min-width: 40px;
    }

    .chatbot__role-info {
        align-items: flex-start;
        text-align: left;
        flex: 1;
    }

    .chatbot__role-name {
        font-size: 15px;
    }

    .chatbot__role-desc {
        font-size: 12px;
    }
}
