/* =============================================
   Fluxbot Chatbot Widget
   ============================================= */

/* --- Toggle button in navbar --- */
#fluxbot-nav-item {
    display: flex !important;
    align-items: center;
    align-self: center;
    padding: 0 8px;
    margin: auto 0;
}

#fluxbot-toggle-btn {
    background: none;
    border: none;
    padding: 0;
    margin: 0;
    cursor: pointer;
    color: var(--ff-ui-text) !important;
    line-height: 1;
    display: flex;
    align-items: center;
}

#fluxbot-toggle-btn:hover,
#fluxbot-toggle-btn:focus {
    background: none;
    outline: none;
    color: var(--ff-main-color, #00AEA5) !important;
    font-weight: 600 !important;
}

#fluxbot-toggle-btn i {
    font-size: 22px;
}

/* --- Overlay backdrop --- */
#fluxbot-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.3);
    z-index: 9990;
    opacity: 0;
    transition: opacity 0.3s ease;
}

#fluxbot-overlay.open {
    display: block;
    opacity: 1;
}

/* --- Main panel --- */
#fluxbot-panel {
    position: fixed;
    top: 0;
    right: -440px;
    width: 400px;
    height: 100vh;
    background: #ffffff;
    box-shadow: -6px 0 30px rgba(0, 0, 0, 0.12);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    transition: right 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

#fluxbot-panel.open {
    right: 0;
}

/* --- Panel header --- */
#fluxbot-header {
    background: linear-gradient(135deg, var(--ff-main-color, #00AEA5) 0%, #a855f7 100%);
    padding: 16px 18px;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
    position: relative;
}

.fluxbot-header-avatar {
    width: 42px;
    height: 42px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
    border: 2px solid rgba(255,255,255,0.3);
}

.fluxbot-header-info {
    flex: 1;
    min-width: 0;
}

.fluxbot-header-info h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: 0.2px;
}

.fluxbot-header-info p {
    margin: 3px 0 0;
    font-size: 12px;
    opacity: 0.82;
    line-height: 1;
}

.fluxbot-header-status {
    display: inline-block;
    width: 7px;
    height: 7px;
    background: #4ade80;
    border-radius: 50%;
    margin-right: 5px;
    vertical-align: middle;
    animation: fluxbot-pulse 2s infinite;
}

@keyframes fluxbot-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

#fluxbot-close-btn {
    background: rgba(255, 255, 255, 0.18);
    border: none;
    color: #fff;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    flex-shrink: 0;
    padding: 0;
}

#fluxbot-close-btn:hover {
    background: rgba(255, 255, 255, 0.32);
}

/* --- Scrollable body --- */
#fluxbot-body {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    position: relative;
}

/* --- Chat panel wrapper --- */
#fluxbot-panel-chat {
    display: flex;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
}

#fluxbot-panel-chat.hidden {
    display: none;
}

/* --- Home view (welcome + categories + FAQ) --- */
#fluxbot-home-view {
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    flex: 1;
}

#fluxbot-home-view.hidden {
    display: none;
}

/* Welcome block */
#fluxbot-welcome {
    padding: 0 20px 16px;
    background: #faf7ff;
    border-bottom: 1px solid #f0ebff;
    flex-shrink: 0;
}

#fluxbot-welcome h4 {
    margin: 12px 0 5px;
    font-size: 15px;
    font-weight: 700;
    color: #1e1b4b;
    line-height: 1.3;
}

#fluxbot-welcome p {
    margin: 0;
    font-size: 13px;
    color: #6b7280;
    line-height: 1.5;
}

/* Categories block */
#fluxbot-categories {
    padding: 16px 18px 14px;
    border-bottom: 1px solid #f3f4f6;
    flex-shrink: 0;
}

.fluxbot-section-title {
    margin: 0 0 10px;
    font-size: 11px;
    font-weight: 700;
    color: #9ca3af;
    text-transform: uppercase;
    letter-spacing: 0.9px;
}

.fluxbot-categories-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
}

.fluxbot-category-btn {
    background: #f5f3ff;
    border: 1.5px solid #e9d5ff;
    color: var(--ff-sidebar-open-color, #00AEA5);
    border-radius: 20px;
    padding: 6px 13px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-family: inherit;
    line-height: 1;
}

.fluxbot-category-btn:hover {
    background: var(--ff-main-color, #00AEA5);
    border-color: var(--ff-main-color, #00AEA5);
    color: #fff;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(124, 58, 237, 0.3);
}

.fluxbot-category-btn i {
    font-size: 13px;
}

/* FAQ block */
#fluxbot-faq {
    padding: 16px 18px;
    flex-shrink: 0;
}

.fluxbot-faq-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 12px;
    background: #f9fafb;
    border-radius: 9px;
    margin-bottom: 6px;
    cursor: pointer;
    transition: all 0.15s ease;
    font-size: 13px;
    color: #374151;
    border: 1px solid transparent;
    text-decoration: none;
}

.fluxbot-faq-item:last-child {
    margin-bottom: 0;
}

.fluxbot-faq-item:hover {
    background: #f5f3ff;
    border-color: #e9d5ff;
    color: var(--ff-sidebar-open-color, #00AEA5);
}

.fluxbot-faq-item .faq-icon {
    color: var(--ff-main-color, #00AEA5);
    margin-top: 2px;
    flex-shrink: 0;
    width: 14px;
    text-align: center;
}

.fluxbot-faq-item span {
    flex: 1;
    line-height: 1.45;
}

.fluxbot-faq-item .faq-arrow {
    color: #d1d5db;
    font-size: 10px;
    margin-top: 3px;
    flex-shrink: 0;
    transition: color 0.15s;
}

.fluxbot-faq-item:hover .faq-arrow {
    color: var(--ff-sidebar-open-color, #00AEA5);
}

/* --- Chat view --- */
#fluxbot-chat-view {
    display: none;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
}

#fluxbot-chat-view.active {
    display: flex;
}

/* --- Tab bar (Chat | Historial) --- */
#fluxbot-tabs {
    display: flex;
    align-items: center;
    background: #f9fafb;
    border-bottom: 1px solid #e5e7eb;
    padding: 6px 8px;
    gap: 4px;
    flex-shrink: 0;
}

.fluxbot-tab {
    flex: 1;
    border: none;
    background: transparent;
    color: #6b7280;
    font-size: 13px;
    font-weight: 500;
    padding: 7px 0;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.18s ease;
    font-family: inherit;
    letter-spacing: 0.1px;
    border: 1px solid #F9FAFB;
}

.fluxbot-tab:hover {
    background: #fff;
    border: 1px solid #dbdde4;
    color: var(--ff-main-color, #00C4BA);
}

.fluxbot-tab.active {
    background: #fff;
    color: var(--ff-main-color, #00AEA5);
    font-weight: 700;
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
    border: 1px solid #c1c7d4;
}

/* --- Historial panel --- */
#fluxbot-panel-historial {
    display: flex;
    flex-direction: column;
    flex: 1;
    overflow-y: auto;
}

#fluxbot-history-list {
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.fluxbot-hist-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 13px;
    background: #f9fafb;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.15s ease;
    border: 1px solid transparent;
}

.fluxbot-hist-item:hover {
    background: #f5f3ff;
    border-color: #e9d5ff;
}

.hist-icon {
    width: 34px;
    height: 34px;
    background: #ede9fe;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--ff-main-color, #00AEA5);
    font-size: 13px;
    flex-shrink: 0;
}

.hist-info {
    flex: 1;
    min-width: 0;
}

.hist-preview {
    margin: 0 0 2px;
    font-size: 13px;
    color: #374151;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.35;
}

.hist-time {
    font-size: 11px;
    color: #9ca3af;
}

.hist-arrow {
    color: #d1d5db;
    font-size: 11px;
    flex-shrink: 0;
    transition: color 0.15s;
}

.fluxbot-hist-item:hover .hist-arrow {
    color: var(--ff-main-color, #00AEA5);
}

.fluxbot-hist-empty {
    text-align: center;
    padding: 48px 20px;
    color: #9ca3af;
}

.fluxbot-hist-empty i {
    font-size: 36px;
    display: block;
    margin-bottom: 12px;
    opacity: 0.5;
}

.fluxbot-hist-empty p {
    margin: 0;
    font-size: 13px;
    line-height: 1.5;
}

/* --- Back bar inside chat view (← Inicio) --- */
#fluxbot-back-bar {
    padding: 8px 16px;
    border-bottom: 1px solid #f3f4f6;
    flex-shrink: 0;
    background: #faf9ff;
}

#fluxbot-back-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--ff-main-color, #00AEA5);
    font-size: 12px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-weight: 500;
    font-family: inherit;
    transition: opacity 0.15s;
    opacity: 0.9;
}

#fluxbot-back-btn:hover {
    opacity: 1;
}

/* Messages area */
#fluxbot-messages {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
    scroll-behavior: smooth;
}

#fluxbot-messages::-webkit-scrollbar {
    width: 4px;
}

#fluxbot-messages::-webkit-scrollbar-track {
    background: transparent;
}

#fluxbot-messages::-webkit-scrollbar-thumb {
    background: #e5e7eb;
    border-radius: 4px;
}

/* Message bubbles */
.fluxbot-msg {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    max-width: 88%;
    animation: fluxbot-fadein 0.2s ease;
}

@keyframes fluxbot-fadein {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

.fluxbot-msg.user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.fluxbot-msg.bot {
    align-self: flex-start;
}

.msg-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    flex-shrink: 0;
}

.fluxbot-msg.bot .msg-avatar {
    background: #ede9fe;
    color: var(--ff-main-color, #00AEA5);
}

.fluxbot-msg.user .msg-avatar {
    background: var(--ff-main-color, #00AEA5);
    color: #fff;
}

.msg-bubble {
    padding: 10px 13px;
    font-size: 13px;
    line-height: 1.55;
    color: #374151;
    word-break: break-word;
    position: relative;
}

.fluxbot-msg.bot .msg-bubble {
    background: #f3f4f6;
    border-radius: 14px 14px 14px 3px;
    color: #374151;
}

.fluxbot-msg.bot .msg-bubble a.fluxbot-email-link {
    color: var(--ff-main-color);
    text-decoration: underline;
    word-break: break-all;
}
.fluxbot-msg.bot .msg-bubble a.fluxbot-email-link:hover {
    color: #7B81DE;
}

.fluxbot-msg.user .msg-bubble {
    background: var(--ff-main-color, #00AEA5);
    color: #fff;
    border-radius: 14px 14px 3px 14px;
}

/* Typing indicator */
.fluxbot-msg.fluxbot-typing .msg-bubble {
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 5px;
}

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

.fluxbot-typing-dot:nth-child(2) { animation-delay: 0.2s; }
.fluxbot-typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes fluxbot-bounce {
    0%, 60%, 100% { transform: translateY(0); }
    30%            { transform: translateY(-7px); }
}

/* --- Footer / input area --- */
#fluxbot-footer {
    border-top: 1px solid #e5e7eb;
    padding: 12px 14px 10px;
    background: #fff;
    flex-shrink: 0;
}

#fluxbot-input-row {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    background: #f9fafb;
    border: 1.5px solid #e5e7eb;
    border-radius: 12px;
    padding: 8px 10px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

#fluxbot-input-row:focus-within {
    border-color: var(--ff-main-color, #00AEA5);
    background: #fff;
    box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.1);
}

#fluxbot-input-row textarea {
    background: transparent !important;
    box-shadow: unset !important;
}

#fluxbot-input {
    flex: 1;
    border: none;
    background: transparent;
    resize: none;
    font-size: 13px;
    line-height: 1.5;
    color: #374151;
    min-height: calc(3 * 1.5 * 13px); /* 3 rows */
    max-height: 100px;
    outline: none;
    font-family: inherit;
    overflow-y: auto;
}

#fluxbot-input::placeholder {
    color: #9ca3af;
}

#fluxbot-send-btn {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: var(--ff-main-color, #00AEA5);
    border: none;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    transition: background 0.2s ease, transform 0.15s ease;
    flex-shrink: 0;
    padding: 0;
}

#fluxbot-send-btn:hover:not(:disabled) {
    background: var(--ff-secondary-color, #6d28d9);
    transform: scale(1.05);
}

#fluxbot-send-btn:disabled {
    background: #d1d5db;
    cursor: not-allowed;
    transform: none;
}

#fluxbot-disclaimer {
    margin: 7px 0 0;
    text-align: center;
    font-size: 11px;
    color: #c0c6cf;
    line-height: 1.3;
}

/* --- Generic hidden utility (used by JS) --- */
#fluxbot-panel-historial.hidden,
#fluxbot-footer.hidden {
    display: none !important;
}

.fluxbot-msg.user::before {
  content: "" !important;
}

/* --- Responsive (smaller screens) --- */
@media (max-width: 480px) {
    #fluxbot-panel {
        width: 100vw;
        right: -100vw;
    }
}
