/* ═══════════════════════════════════════════════════════════════
   Guia de Usuario IA - Sistema de Ayuda Contextual
   Prefijo: guia- (evita conflictos con ia- de reportes)
   ═══════════════════════════════════════════════════════════════ */

/* ─── FAB (Floating Action Button) ─── */

.guia-fab {
    position: fixed;
    bottom: 90px;
    right: 24px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, #6366f1, #818cf8);
    color: white;
    border: none;
    cursor: pointer;
    font-size: 1.375rem;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 14px rgba(99, 102, 241, 0.4);
    z-index: 2147483001;
    opacity: 0;
    transform: scale(0.5) translateY(20px);
    transition: all 400ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

.guia-fab-visible {
    opacity: 1;
    transform: scale(1) translateY(0);
}

.guia-fab:hover {
    transform: scale(1.1) translateY(-2px);
    box-shadow: 0 8px 24px rgba(99, 102, 241, 0.5);
}

.guia-fab:active {
    transform: scale(0.95);
}

/* Pulse ring */
.guia-fab-pulse {
    position: absolute;
    inset: -4px;
    border-radius: 50%;
    border: 2px solid rgba(99, 102, 241, 0.4);
    animation: guiaPulse 2.5s ease-in-out infinite;
    pointer-events: none;
}

@keyframes guiaPulse {
    0%, 100% { transform: scale(1); opacity: 0.4; }
    50% { transform: scale(1.2); opacity: 0; }
}

/* Tooltip del FAB */
.guia-fab-tooltip {
    position: absolute;
    right: 66px;
    white-space: nowrap;
    background: #1e293b;
    color: white;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.8125rem;
    font-weight: 500;
    pointer-events: none;
    opacity: 0;
    transform: translateX(8px);
    transition: all 250ms ease;
}

.guia-fab-tooltip::after {
    content: '';
    position: absolute;
    right: -6px;
    top: 50%;
    transform: translateY(-50%);
    border: 6px solid transparent;
    border-left-color: #1e293b;
    border-right: none;
}

.guia-fab:hover .guia-fab-tooltip {
    opacity: 1;
    transform: translateX(0);
}

/* Desplazar si Chatwoot activo */
.woot-widget-bubble ~ .guia-fab,
.woot--bubble-holder ~ .guia-fab {
    bottom: 90px;
}

/* ─── Modal Overlay ─── */

.guia-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.5);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 9995;
    display: flex;
    align-items: flex-end;
    justify-content: flex-end;
    padding: 16px;
    opacity: 0;
    visibility: hidden;
    transition: all 300ms ease;
}

.guia-modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* ─── Modal Container ─── */

.guia-modal {
    width: 420px;
    max-width: 100%;
    height: 600px;
    max-height: calc(100vh - 32px);
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.15),
                0 0 0 1px rgba(15, 23, 42, 0.06);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: translateY(30px) scale(0.95);
    transition: transform 350ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

.guia-modal-overlay.active .guia-modal {
    transform: translateY(0) scale(1);
}

/* ─── Modal Header ─── */

.guia-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    background: linear-gradient(135deg, #6366f1, #818cf8);
    color: white;
    flex-shrink: 0;
}

.guia-header-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.guia-header-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.125rem;
}

.guia-header-title {
    font-size: 1rem;
    font-weight: 700;
    margin: 0;
    color: white;
    line-height: 1.3;
}

.guia-header-subtitle {
    font-size: 0.75rem;
    opacity: 0.8;
}

.guia-modal-close {
    width: 32px;
    height: 32px;
    border: none;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 50%;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 200ms;
    font-size: 1rem;
}

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

/* ─── Quick Actions ─── */

.guia-quick-actions {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid rgba(15, 23, 42, 0.06);
    flex-shrink: 0;
}

.guia-btn-explicar {
    width: 100%;
    padding: 0.625rem 1rem;
    border: 2px solid #6366f1;
    background: #eef2ff;
    color: #6366f1;
    border-radius: 10px;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 200ms;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-family: inherit;
}

.guia-btn-explicar:hover:not(:disabled) {
    background: #6366f1;
    color: white;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
    transform: translateY(-1px);
}

.guia-btn-explicar:active:not(:disabled) {
    transform: translateY(0);
}

.guia-btn-explicar:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

/* ─── Chat Area ─── */

.guia-chat-area {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.875rem;
    scroll-behavior: smooth;
}

.guia-chat-area::-webkit-scrollbar {
    width: 6px;
}

.guia-chat-area::-webkit-scrollbar-track {
    background: transparent;
}

.guia-chat-area::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.12);
    border-radius: 3px;
}

.guia-chat-area::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.2);
}

/* ─── Welcome Message ─── */

.guia-welcome-message {
    text-align: center;
    padding: 2rem 1rem;
    color: #64748b;
}

.guia-welcome-icon {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: #eef2ff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1rem;
    font-size: 1.5rem;
    color: #6366f1;
}

.guia-welcome-message p {
    margin: 0.375rem 0;
    font-size: 0.9375rem;
    line-height: 1.5;
    color: #475569;
}

.guia-welcome-hint {
    font-size: 0.8125rem !important;
    color: #94a3b8 !important;
}

/* ─── Chat Messages ─── */

.guia-message {
    display: flex;
    gap: 0.5rem;
    align-items: flex-start;
    animation: guiaMsgIn 300ms ease both;
}

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

.guia-message-user {
    flex-direction: row-reverse;
}

/* ─── Avatars ─── */

.guia-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    flex-shrink: 0;
    margin-top: 2px;
}

.guia-avatar-user {
    background: var(--coloroscuro, #049890);
    color: white;
}

.guia-avatar-assistant {
    background: #eef2ff;
    color: #6366f1;
}

/* ─── Chat Bubbles ─── */

.guia-bubble {
    max-width: 85%;
    padding: 0.75rem 1rem;
    border-radius: 12px;
    font-size: 0.875rem;
    line-height: 1.6;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.guia-bubble-user {
    background: var(--coloroscuro, #049890);
    color: white;
    border-bottom-right-radius: 4px;
}

.guia-bubble-user p {
    margin: 0;
}

.guia-bubble-assistant {
    background: #f1f5f9;
    color: #334155;
    border-bottom-left-radius: 4px;
}

/* HTML content inside assistant bubbles */
.guia-bubble-assistant h4 {
    font-size: 0.9375rem;
    font-weight: 700;
    color: #0f172a;
    margin: 0.875rem 0 0.375rem 0;
    padding-bottom: 0.25rem;
    border-bottom: 1px solid rgba(99, 102, 241, 0.15);
}

.guia-bubble-assistant h4:first-child {
    margin-top: 0;
}

.guia-bubble-assistant p {
    margin: 0.375rem 0;
}

.guia-bubble-assistant p:first-child {
    margin-top: 0;
}

.guia-bubble-assistant p:last-child {
    margin-bottom: 0;
}

.guia-bubble-assistant ul,
.guia-bubble-assistant ol {
    margin: 0.375rem 0;
    padding-left: 1.25rem;
}

.guia-bubble-assistant li {
    margin: 0.25rem 0;
}

.guia-bubble-assistant strong {
    color: #0f172a;
    font-weight: 600;
}

.guia-bubble-assistant em {
    color: #6366f1;
    font-style: italic;
}

.guia-bubble-assistant code {
    background: rgba(99, 102, 241, 0.1);
    padding: 1px 5px;
    border-radius: 4px;
    font-size: 0.8125rem;
    color: #4f46e5;
}

/* ─── Speech Bar (boton de lectura en voz alta) ─── */

.guia-speech-bar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
    padding-bottom: 0.625rem;
    border-bottom: 1px solid rgba(99, 102, 241, 0.12);
}

.guia-btn-speech {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 1.5px solid #6366f1;
    background: #eef2ff;
    color: #6366f1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.875rem;
    transition: all 200ms;
    flex-shrink: 0;
}

.guia-btn-speech:hover {
    background: #6366f1;
    color: white;
    transform: scale(1.08);
}

.guia-btn-speech.guia-speech-active {
    background: #6366f1;
    color: white;
    animation: guiaSpeechPulse 1.5s ease-in-out infinite;
}

@keyframes guiaSpeechPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(99, 102, 241, 0.4); }
    50% { box-shadow: 0 0 0 8px rgba(99, 102, 241, 0); }
}

.guia-speech-label {
    font-size: 0.75rem;
    color: #6366f1;
    font-weight: 600;
    letter-spacing: 0.02em;
}

.guia-step-counter {
    margin-left: auto;
    font-size: 0.6875rem;
    color: #94a3b8;
    font-weight: 600;
    background: #f1f5f9;
    padding: 2px 8px;
    border-radius: 10px;
}

/* ─── Seccion activa (highlight mientras se lee) ─── */

.guia-seccion-activa {
    border-left: 3px solid #6366f1 !important;
    background: linear-gradient(135deg, #eef2ff, #f1f5f9) !important;
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.1);
}

.guia-seccion-step {
    animation: guiaSeccionIn 400ms ease both;
}

@keyframes guiaSeccionIn {
    from {
        opacity: 0;
        transform: translateY(16px) scale(0.97);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* ─── Highlight de campos del formulario durante el tour ─── */

.guia-field-highlight {
    outline: 3px solid #6366f1 !important;
    outline-offset: 2px;
    box-shadow: 0 0 0 6px rgba(99, 102, 241, 0.15) !important;
    border-radius: 4px;
    animation: guiaFieldPulse 1.5s ease-in-out 2;
}

@keyframes guiaFieldPulse {
    0%, 100% { outline-color: #6366f1; }
    50% { outline-color: #818cf8; }
}

/* ─── Typing Indicator ─── */

.guia-typing-dots {
    display: flex;
    gap: 5px;
    padding: 4px 0;
    align-items: center;
}

.guia-typing-dots span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #94a3b8;
    animation: guiaTypingBounce 1.4s ease-in-out infinite;
}

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

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

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

/* ─── Input Area ─── */

.guia-input-area {
    padding: 0.75rem 1rem;
    border-top: 1px solid rgba(15, 23, 42, 0.06);
    background: #ffffff;
    flex-shrink: 0;
}

.guia-input-wrapper {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: #f1f5f9;
    border-radius: 24px;
    padding: 0.375rem 0.375rem 0.375rem 1rem;
    border: 1.5px solid rgba(15, 23, 42, 0.08);
    transition: all 200ms ease;
}

.guia-input-wrapper:focus-within {
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.12);
    background: #ffffff;
}

.guia-input {
    flex: 1;
    border: none;
    background: transparent;
    font-size: 0.875rem;
    color: #0f172a;
    outline: none;
    font-family: inherit;
    padding: 0.375rem 0;
    min-width: 0;
}

.guia-input::placeholder {
    color: #94a3b8;
}

.guia-input:disabled {
    opacity: 0.5;
}

.guia-btn-send {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: #6366f1;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 200ms;
    font-size: 0.8125rem;
    flex-shrink: 0;
}

.guia-btn-send:hover:not(:disabled) {
    background: #4f46e5;
    transform: scale(1.08);
}

.guia-btn-send:active:not(:disabled) {
    transform: scale(0.95);
}

.guia-btn-send:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none !important;
}

/* ─── Responsive ─── */

@media (max-width: 480px) {
    .guia-modal-overlay {
        padding: 0;
        align-items: stretch;
        justify-content: stretch;
    }

    .guia-modal {
        width: 100%;
        height: 100%;
        max-height: 100vh;
        border-radius: 0;
    }

    .guia-fab {
        bottom: 16px;
        right: 16px;
        width: 48px;
        height: 48px;
        font-size: 1.125rem;
    }

    .guia-fab-tooltip {
        display: none;
    }
}

/* ─── Tour Bar (barra flotante minimizada durante el recorrido) ─── */

.guia-tour-bar {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    z-index: 2147483002;
    opacity: 0;
    transition: all 400ms cubic-bezier(0.34, 1.56, 0.64, 1);
    width: 520px;
    max-width: calc(100% - 32px);
}

.guia-tour-bar-visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.guia-tour-bar-inner {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: linear-gradient(135deg, #312e81, #4338ca);
    border-radius: 16px 16px 0 0;
    color: white;
    box-shadow: 0 -4px 24px rgba(67, 56, 202, 0.35),
                0 0 0 1px rgba(255, 255, 255, 0.1) inset;
}

.guia-tour-icon {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    flex-shrink: 0;
    animation: guiaSpeechPulse 1.5s ease-in-out infinite;
}

.guia-tour-content {
    flex: 1;
    min-width: 0;
    overflow: hidden;
}

.guia-tour-titulo {
    font-size: 0.8125rem;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
}

.guia-tour-texto {
    font-size: 0.6875rem;
    opacity: 0.75;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
    margin-top: 1px;
}

.guia-tour-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}

.guia-tour-counter {
    font-size: 0.6875rem;
    font-weight: 700;
    background: rgba(255, 255, 255, 0.15);
    padding: 3px 8px;
    border-radius: 10px;
    white-space: nowrap;
}

.guia-tour-btn {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 1.5px solid rgba(255, 255, 255, 0.3);
    background: rgba(255, 255, 255, 0.1);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8125rem;
    transition: all 200ms;
}

.guia-tour-btn:hover {
    background: rgba(255, 255, 255, 0.25);
    border-color: rgba(255, 255, 255, 0.5);
    transform: scale(1.08);
}

.guia-tour-btn-stop {
    border-color: rgba(248, 113, 113, 0.5);
    background: rgba(248, 113, 113, 0.15);
}

.guia-tour-btn-stop:hover {
    background: rgba(248, 113, 113, 0.35);
    border-color: rgba(248, 113, 113, 0.7);
}

/* Barra de progreso del tour */
.guia-tour-progress {
    height: 4px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 0 0 16px 16px;
    overflow: hidden;
}

.guia-tour-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #818cf8, #a5b4fc);
    border-radius: 0 0 0 16px;
    transition: width 500ms ease;
}

/* ─── Print: Ocultar todo ─── */

@media print {
    .guia-fab,
    .guia-modal-overlay,
    .guia-tour-bar {
        display: none !important;
    }
}

/* ─── Responsive tour bar ─── */

@media (max-width: 480px) {
    .guia-tour-bar {
        width: calc(100% - 16px);
        bottom: 8px;
    }

    .guia-tour-bar-inner {
        padding: 0.625rem 0.75rem;
        gap: 0.5rem;
    }

    .guia-tour-icon {
        width: 32px;
        height: 32px;
        font-size: 0.875rem;
    }

    .guia-tour-btn {
        width: 30px;
        height: 30px;
        font-size: 0.75rem;
    }
}
