/* ==========================================================
   AI CHAT WIDGET — DESACTIVADO
   ========================================================== */

/* ⚠️ IA OCULTADA - Solo usará para enviar informes posteriormente */
#ai-chat-btn,
#ai-chat-panel,
.ai-chat-widget {
    display: none !important;
    visibility: hidden !important;
    pointer-events: none !important;
}

/* ── Floating button ── */
#ai-chat-btn {
    position: fixed;
    bottom: 28px;
    right: 28px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, #10b981 0%, #059669 60%, #34d399 100%);
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(16, 185, 129, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9000;
    transition: transform 0.2s, box-shadow 0.2s;
    animation: ai-btn-idle 3s ease-in-out infinite;
    overflow: hidden;
    padding: 0;
}
#ai-chat-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 28px rgba(16, 185, 129, 0.65);
    animation: none;
}
.ai-btn-img {
    width: 44px;
    height: 44px;
    object-fit: contain;
    border-radius: 50%;
}

@keyframes ai-btn-idle {
    0%, 100% { transform: translateY(0);   box-shadow: 0 4px 20px rgba(16,185,129,0.45); }
    50%       { transform: translateY(-4px); box-shadow: 0 8px 28px rgba(16,185,129,0.55); }
}

/* pulse ring on button */
#ai-chat-btn::before {
    content: '';
    position: absolute;
    inset: -4px;
    border-radius: 50%;
    border: 2px solid rgba(16, 185, 129, 0.5);
    animation: ai-ring 2.5s ease-out infinite;
}
@keyframes ai-ring {
    0%   { transform: scale(1);    opacity: 0.7; }
    70%  { transform: scale(1.35); opacity: 0; }
    100% { transform: scale(1.35); opacity: 0; }
}

/* ── Panel ── */
#ai-chat-panel {
    position: fixed;
    bottom: 96px;
    right: 28px;
    width: 360px;
    height: 520px;
    background: var(--bg-card, #1e1e2e);
    border: 1px solid rgba(16, 185, 129, 0.3);
    border-radius: 18px;
    box-shadow: 0 12px 48px rgba(0,0,0,0.35);
    display: flex;
    flex-direction: column;
    z-index: 8999;
    overflow: hidden;
    transform-origin: bottom right;
    transform: scale(0.85) translateY(12px);
    opacity: 0;
    pointer-events: none;
    transition: transform 0.22s cubic-bezier(0.34,1.56,0.64,1), opacity 0.18s ease;
}
#ai-chat-panel.ai-open {
    transform: scale(1) translateY(0);
    opacity: 1;
    pointer-events: all;
}

/* header */
.ai-panel-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px 12px;
    background: linear-gradient(135deg, #10b981, #059669);
    color: #fff;
    flex-shrink: 0;
}
.ai-panel-header .ai-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: rgba(255,255,255,0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    overflow: hidden;
    padding: 0;
}
.ai-avatar-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}
.ai-panel-title { flex: 1; }
.ai-panel-title strong { display: block; font-size: 0.95rem; font-weight: 700; }
.ai-panel-title span { font-size: 0.72rem; opacity: 0.85; }
.ai-close-btn {
    background: none; border: none; color: #fff;
    cursor: pointer; opacity: 0.75; padding: 4px;
    border-radius: 6px; transition: opacity 0.15s, background 0.15s;
    display: flex; align-items: center; justify-content: center;
}
.ai-close-btn:hover { opacity: 1; background: rgba(255,255,255,0.15); }
.ai-close-btn svg { width: 18px; height: 18px; }

/* messages */
.ai-messages {
    flex: 1;
    overflow-y: auto;
    padding: 14px 14px 8px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    scroll-behavior: smooth;
}
.ai-messages::-webkit-scrollbar { width: 4px; }
.ai-messages::-webkit-scrollbar-track { background: transparent; }
.ai-messages::-webkit-scrollbar-thumb { background: rgba(16,185,129,0.3); border-radius: 4px; }

/* bubbles */
.ai-msg {
    max-width: 88%;
    padding: 9px 13px;
    border-radius: 14px;
    font-size: 0.84rem;
    line-height: 1.5;
    word-break: break-word;
    animation: ai-msg-in 0.2s ease;
}
@keyframes ai-msg-in {
    from { transform: translateY(6px); opacity: 0; }
    to   { transform: translateY(0);   opacity: 1; }
}
.ai-msg.user {
    align-self: flex-end;
    background: linear-gradient(135deg, #1619b5, #6069d7);
    color: #fff;
    border-bottom-right-radius: 4px;
}
.ai-msg.model {
    align-self: flex-start;
    background: var(--bg-hover, rgba(255,255,255,0.07));
    color: #212121;
    border-bottom-left-radius: 4px;
    border: 1px solid rgba(16,185,129,0.2);
}

/* typing indicator */
.ai-typing {
    align-self: flex-start;
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 10px 14px;
    background: var(--bg-hover, rgba(255,255,255,0.07));
    border-radius: 14px;
    border-bottom-left-radius: 4px;
    border: 1px solid rgba(16,185,129,0.2);
}
.ai-typing span {
    width: 7px; height: 7px;
    border-radius: 50%;
    background: #10b981;
    animation: ai-dot 1.2s ease-in-out infinite;
}
.ai-typing span:nth-child(2) { animation-delay: 0.2s; }
.ai-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes ai-dot {
    0%, 60%, 100% { transform: translateY(0);   opacity: 0.4; }
    30%            { transform: translateY(-5px); opacity: 1; }
}

/* input row */
.ai-input-row {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 10px 12px 14px;
    border-top: 1px solid rgba(16,185,129,0.15);
    flex-shrink: 0;
    background: var(--bg-card, #1e1e2e);
}
#ai-input {
    flex: 1;
    resize: none;
    border: 1px solid rgba(16,185,129,0.3);
    border-radius: 12px;
    padding: 9px 12px;
    font-size: 0.84rem;
    font-family: inherit;
    background: var(--bg-hover, rgba(255,255,255,0.05));
    color: #212121;
    outline: none;
    max-height: 100px;
    line-height: 1.4;
    transition: border-color 0.15s;
}
#ai-input:focus { border-color: #10b981; }
#ai-input::placeholder { color: rgba(255,255,255,0.3); }
#ai-send-btn {
    width: 38px; height: 38px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, #10b981, #059669);
    color: #fff;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    transition: transform 0.15s, opacity 0.15s;
}
#ai-send-btn:hover   { transform: scale(1.08); }
#ai-send-btn:active  { transform: scale(0.95); }
#ai-send-btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }
#ai-send-btn svg { width: 18px; height: 18px; }

/* mobile */
@media (max-width: 640px) {
    #ai-chat-panel {
        width: calc(100vw - 24px);
        right: 12px;
        bottom: 88px;
        height: 60vh;
    }
    #ai-chat-btn { bottom: 20px; right: 16px; }
    #tour-help-btn { bottom: 84px; right: 16px; }
    #tour-help-panel {
        width: calc(100vw - 24px);
        right: 12px;
        bottom: 148px;
    }
}

/* ==========================================================
   TOUR HELP BUTTON + PANEL
   ========================================================== */

/* "?" floating button — sits 68px above the AI chat button */
#tour-help-btn {
    position: fixed;
    bottom: 96px;
    right: 28px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--bg-card, #1e1e2e);
    border: 2px solid rgba(16, 185, 129, 0.6);
    color: #6ee7b7;
    cursor: pointer;
    box-shadow: 0 3px 14px rgba(0,0,0,0.28);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9000;
    transition: transform 0.18s, background 0.18s, border-color 0.18s, color 0.18s, opacity 0.15s;
    font-weight: 700;
    font-size: 1.1rem;
}
#tour-help-btn svg { width: 22px; height: 22px; pointer-events: none; stroke-width: 2.5; }
#tour-help-btn:hover,
#tour-help-btn.active {
    background: linear-gradient(135deg, #10b981, #059669);
    border-color: #34d399;
    color: #fff;
    transform: scale(1.12);
    box-shadow: 0 6px 24px rgba(16, 185, 129, 0.5);
}

/* Hide "?" when AI chat is open */
#tour-help-btn.tour-btn-hidden {
    opacity: 0;
    pointer-events: none;
    transform: scale(0.75) translateY(6px);
}

/* Help panel */
#tour-help-panel {
    position: fixed;
    bottom: 152px;
    right: 28px;
    width: 380px;
    background: var(--bg-card, #1e1e2e);
    border: 1px solid rgba(16, 185, 129, 0.3);
    border-radius: 18px;
    box-shadow: 0 12px 48px rgba(0,0,0,0.35);
    z-index: 8999;
    overflow: hidden;
    transform-origin: bottom right;
    transform: scale(0.85) translateY(12px);
    opacity: 0;
    pointer-events: none;
    transition: transform 0.22s cubic-bezier(0.34,1.56,0.64,1), opacity 0.18s ease;
}
#tour-help-panel.tour-panel-open {
    transform: scale(1) translateY(0);
    opacity: 1;
    pointer-events: all;
}

.tour-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px 10px;
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    border-bottom: 1px solid rgba(16,185,129,0.15);
}
.tour-panel-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.95rem;
    color: #ffffff;
}
.tour-panel-title strong { font-weight: 700; }
.tour-panel-subtitle {
    font-size: 0.75rem;
    color: rgb(36 36 36);
    padding: 6px 16px 8px;
    margin: 0;
}

.tour-list {
    display: flex;
    flex-direction: column;
    padding: 4px 8px 12px;
    gap: 2px;
    max-height: 380px;
    overflow-y: auto;
}
.tour-list::-webkit-scrollbar { width: 4px; }
.tour-list::-webkit-scrollbar-thumb { background: rgba(16,185,129,0.3); border-radius: 4px; }

.tour-item-btn {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 9px 10px;
    border: none;
    background: none;
    border-radius: 10px;
    cursor: pointer;
    text-align: left;
    transition: background 0.15s, transform 0.15s;
    width: 100%;
}
.tour-item-btn:hover {
    background: linear-gradient(135deg, rgba(16,185,129,0.15), rgba(5,150,105,0.15));
    transform: translateX(3px);
}
.tour-item-icon {
    font-size: 1.25rem;
    width: 30px;
    text-align: center;
    flex-shrink: 0;
}
.tour-item-info {
    flex: 1;
    display: flex;
    flex-direction: column;
}
.tour-item-info strong {
    font-size: 0.85rem;
    font-weight: 600;
    color: #e2e8f0;
    line-height: 1.3;
}
.tour-item-info span {
    font-size: 0.72rem;
    color: #94a3b8;
    line-height: 1.3;
}
.tour-item-arrow {
    width: 14px;
    height: 14px;
    color: rgba(16,185,129,0.7);
    flex-shrink: 0;
    transition: color 0.15s, transform 0.15s;
}
.tour-item-btn:hover .tour-item-arrow {
    color: #6ee7b7;
    transform: translateX(2px);
}

/* ==========================================================
   TOUR CHIP (en el chat, sugerencia de tutorial)
   ========================================================== */
.ai-tour-chip {
    align-self: flex-start;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    border: 1.5px solid rgba(16,185,129,0.6);
    border-radius: 20px;
    background: linear-gradient(135deg, rgba(16,185,129,0.15), rgba(5,150,105,0.15));
    color: #6ee7b7;
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    animation: ai-msg-in 0.2s ease;
    margin-left: 2px;
}
.ai-tour-chip:hover {
    background: linear-gradient(135deg, rgba(16,185,129,0.3), rgba(5,150,105,0.3));
    border-color: #34d399;
    color: #fff;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(16,185,129,0.3);
}
.ai-tour-chip strong { font-weight: 700; }

/* ==========================================================
   DRIVER.JS OVERRIDES — estilo MiClub
   ========================================================== */
.driver-popover.miclub-tour-popover {
    background: #1e1e2e !important;
    border: 1px solid rgba(16,185,129,0.3) !important;
    border-radius: 14px !important;
    color: #e2e8f0 !important;
    box-shadow: 0 8px 32px rgba(0,0,0,0.5) !important;
}
.driver-popover.miclub-tour-popover .driver-popover-title {
    font-size: 0.95rem !important;
    font-weight: 700 !important;
    color: #6ee7b7 !important;
    margin-bottom: 4px !important;
}
.driver-popover.miclub-tour-popover .driver-popover-description {
    font-size: 0.82rem !important;
    color: #cbd5e1 !important;
    line-height: 1.5 !important;
}
.driver-popover.miclub-tour-popover .driver-popover-progress-text {
    font-size: 0.72rem !important;
    color: rgba(255,255,255,0.5) !important;
}
.driver-popover.miclub-tour-popover .driver-popover-footer button {
    text-shadow: none;
    background: linear-gradient(135deg, #10b981, #059669) !important;
    border: none !important;
    border-radius: 8px !important;
    font-size: 0.8rem !important;
    padding: 6px 14px !important;
    cursor: pointer !important;
}
.driver-popover.miclub-tour-popover .driver-popover-close-btn {
    color: rgba(255,255,255,0.45) !important;
}
.driver-popover.miclub-tour-popover .driver-popover-close-btn:hover {
    color: #fff !important;
}
