/**
 * Estilos para BahiaTinyFAQ - Widget Flotante y Panel de Administración
 *
 * @package BahiaTinyFAQ
 */

:root {
    --bahia-primary: #0369a1;
    --bahia-primary-color: #0369a1;
    --bahia-chat-bg: #ffffff;
    --bahia-chat-border: #e2e8f0;
    --bahia-header-bg: #0369a1;
    --bahia-header-text: #ffffff;
    --bahia-bot-bubble-bg: #f1f5f9;
    --bahia-bot-bubble-text: #0f172a;
    --bahia-user-bubble-bg: #0369a1;
    --bahia-user-bubble-text: #ffffff;
    --bahia-input-bg: #ffffff;
    --bahia-input-text: #0f172a;
    --bahia-input-placeholder: #64748b;
    --bahia-send-bg: #0369a1;
    --bahia-send-color: #ffffff;
    --bahia-trigger-bg: transparent;
    --bahia-trigger-color: #0369a1;
    --bahia-cta-bg: #ffffff;
    --bahia-cta-text: #0f172a;

    --bahia-bubble-size: 60px;
    --bahia-window-width: 360px;
    --bahia-window-height: 520px;
}

/* ==========================================================================
   WIDGET FLOTANTE ROOT
   ========================================================================== */

.bahia-widget-root {
    position: fixed;
    z-index: 999999;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    box-sizing: border-box;
}

.bahia-widget-root *,
.bahia-widget-root *::before,
.bahia-widget-root *::after {
    box-sizing: border-box;
}

.bahia-position-right {
    bottom: 24px;
    right: 24px;
}

.bahia-position-left {
    bottom: 24px;
    left: 24px;
}

/* ==========================================================================
   BURBUJA FLOTANTE TRIGGER
   ========================================================================== */

.bahia-floating-bubble {
    width: var(--bahia-bubble-size, 60px);
    height: var(--bahia-bubble-size, 60px);
    border-radius: 50%;
    background-color: var(--bahia-trigger-bg, transparent);
    background: var(--bahia-trigger-bg, transparent);
    color: var(--bahia-trigger-color, var(--bahia-primary, #0284c7));
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.16);
    transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.2s ease;
    padding: 0;
    overflow: hidden;
    position: relative;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.bahia-floating-bubble.has-avatar {
    background-color: var(--bahia-trigger-bg, transparent);
    background: var(--bahia-trigger-bg, transparent);
    box-shadow: none;
}

.bahia-floating-bubble:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.22);
}

.bahia-floating-bubble.has-avatar:hover {
    box-shadow: none;
    transform: scale(1.05);
}

.bahia-floating-bubble:focus-visible {
    outline: 3px solid #38bdf8;
    outline-offset: 3px;
}

.bahia-bubble-icon {
    width: 28px;
    height: 28px;
    stroke-width: 2.2;
    transition: transform 0.2s ease, opacity 0.2s ease;
}

.bahia-bubble-avatar {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
    user-select: none;
    pointer-events: none;
}

/* Indicador de cierre para burbuja sin avatar */
.bahia-floating-bubble.no-avatar .bahia-close-icon {
    display: none;
    width: 26px;
    height: 26px;
    stroke-width: 2.5;
}

.bahia-floating-bubble.no-avatar.is-open .bahia-bubble-icon {
    display: none;
}

.bahia-floating-bubble.no-avatar.is-open .bahia-close-icon {
    display: block;
}

/* Indicador de cierre para burbuja con avatar: preserva el avatar y agrega overlay sutil */
.bahia-bubble-close-overlay {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    backdrop-filter: blur(1px);
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease-in-out;
}

.bahia-bubble-close-overlay .bahia-close-icon {
    width: 24px;
    height: 24px;
    stroke: #ffffff;
    stroke-width: 2.5;
}

.bahia-floating-bubble.has-avatar.is-open .bahia-bubble-close-overlay {
    opacity: 1;
    pointer-events: auto;
}

.bahia-floating-bubble.has-avatar.is-open .bahia-bubble-avatar {
    display: block !important;
}

/* ==========================================================================
   CALL TO ACTION (CTA) TOOLTIP
   ========================================================================== */

.bahia-cta-bubble {
    position: absolute;
    bottom: calc(var(--bahia-bubble-size, 60px) + 12px);
    background: var(--bahia-cta-bg, #ffffff);
    border: 1px solid var(--bahia-chat-border, #e2e8f0);
    border-radius: 10px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08), 0 1px 3px rgba(0, 0, 0, 0.04);
    padding: 10px 14px;
    max-width: 280px;
    min-width: 180px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    cursor: pointer;
    animation: bahia-fade-slide-up 0.25s ease-out;
}

.bahia-position-right .bahia-cta-bubble {
    right: 0;
}

.bahia-position-left .bahia-cta-bubble {
    left: 0;
}

.bahia-cta-bubble::after {
    content: "";
    position: absolute;
    bottom: -6px;
    width: 10px;
    height: 10px;
    background: var(--bahia-cta-bg, #ffffff);
    border-right: 1px solid var(--bahia-chat-border, #e2e8f0);
    border-bottom: 1px solid var(--bahia-chat-border, #e2e8f0);
    transform: rotate(45deg);
}

.bahia-position-right .bahia-cta-bubble::after {
    right: calc(var(--bahia-bubble-size, 60px) / 2 - 5px);
}

.bahia-position-left .bahia-cta-bubble::after {
    left: calc(var(--bahia-bubble-size, 60px) / 2 - 5px);
}

.bahia-cta-text {
    font-size: 13.5px;
    line-height: 1.4;
    color: var(--bahia-cta-text, #1e293b);
    font-weight: 500;
}

.bahia-cta-close {
    background: transparent;
    border: none;
    color: var(--bahia-cta-text, #94a3b8);
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    padding: 2px 4px;
    border-radius: 4px;
    transition: opacity 0.15s;
    opacity: 0.7;
}

.bahia-cta-close:hover {
    opacity: 1;
}

/* ==========================================================================
   VENTANA DE CHAT
   ========================================================================== */

.bahia-chat-window {
    position: absolute;
    bottom: calc(var(--bahia-bubble-size, 60px) + 14px);
    width: var(--bahia-window-width, 360px);
    height: var(--bahia-window-height, 520px);
    max-height: calc(100vh - 120px);
    background: var(--bahia-chat-bg, #ffffff);
    border: 1px solid var(--bahia-chat-border, #e2e8f0);
    border-radius: 14px;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.05);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: bahia-fade-slide-up 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.bahia-position-right .bahia-chat-window {
    right: 0;
}

.bahia-position-left .bahia-chat-window {
    left: 0;
}

/* CABECERA */
.bahia-chat-header {
    background-color: var(--bahia-header-bg, var(--bahia-primary, #0284c7));
    color: var(--bahia-header-text, #ffffff);
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-top-left-radius: 13px;
    border-top-right-radius: 13px;
}

.bahia-header-info {
    display: flex;
    align-items: center;
    gap: 10px;
    overflow: hidden;
}

.bahia-header-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(255, 255, 255, 0.85);
    flex-shrink: 0;
}

.bahia-header-text {
    overflow: hidden;
}

.bahia-header-bot-name {
    display: block;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    opacity: 0.85;
    margin-bottom: 2px;
}

.bahia-header-title {
    margin: 0;
    font-size: 14.5px;
    font-weight: 600;
    color: var(--bahia-header-text, #ffffff);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.2;
}

.bahia-chat-close-btn {
    background: transparent;
    border: none;
    color: var(--bahia-header-text, #ffffff);
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    opacity: 0.85;
    transition: all 0.15s ease;
}

.bahia-chat-close-btn:hover {
    opacity: 1;
    background: rgba(255, 255, 255, 0.16);
}

.bahia-chat-close-btn:focus-visible {
    outline: 2px solid var(--bahia-header-text, #ffffff);
    outline-offset: 2px;
}

/* MENSAJES */
.bahia-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 14px;
    background: var(--bahia-chat-bg, #ffffff);
    display: flex;
    flex-direction: column;
    gap: 10px;
    scrollbar-width: thin;
}

.bahia-chat-messages:focus-visible {
    outline: 2px solid var(--bahia-primary, #38bdf8);
}

.bahia-msg {
    max-width: 84%;
    padding: 10px 14px;
    font-size: 13.5px;
    line-height: 1.5;
    word-break: break-word;
}

.bahia-msg-user {
    background-color: var(--bahia-user-bubble-bg, var(--bahia-primary, #0284c7));
    color: var(--bahia-user-bubble-text, #ffffff);
    align-self: flex-end;
    border-radius: 14px 14px 2px 14px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

.bahia-msg-bot {
    background-color: var(--bahia-bot-bubble-bg, #f1f5f9);
    color: var(--bahia-bot-bubble-text, #0f172a);
    border: 1px solid var(--bahia-chat-border, #e2e8f0);
    align-self: flex-start;
    border-radius: 14px 14px 14px 2px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03);
}

.bahia-msg-loading {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: var(--bahia-bot-bubble-text, #64748b);
    opacity: 0.75;
    font-style: italic;
    font-size: 13px;
}

/* FORMULARIO */
.bahia-chat-form {
    display: flex;
    gap: 8px;
    padding: 10px 12px;
    background: var(--bahia-chat-bg, #ffffff);
    border-top: 1px solid var(--bahia-chat-border, #e2e8f0);
}

.bahia-chat-input {
    flex: 1;
    padding: 9px 12px;
    border: 1px solid var(--bahia-chat-border, #cbd5e1);
    border-radius: 8px;
    font-size: 13.5px;
    outline: none;
    transition: all 0.15s ease;
    background: var(--bahia-input-bg, #ffffff);
    color: var(--bahia-input-text, #0f172a);
}

.bahia-chat-input::placeholder {
    color: var(--bahia-input-placeholder, #94a3b8);
    opacity: 1;
}

.bahia-chat-input:focus {
    border-color: var(--bahia-primary, #0284c7);
    box-shadow: 0 0 0 2px rgba(2, 132, 199, 0.15);
}

.bahia-chat-btn {
    padding: 9px 14px;
    background-color: var(--bahia-send-bg, var(--bahia-primary, #0284c7));
    color: var(--bahia-send-color, #ffffff);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
}

.bahia-chat-btn:hover:not(:disabled) {
    filter: brightness(0.92);
    transform: translateY(-1px);
}

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

/* ==========================================================================
   ANIMACIONES
   ========================================================================== */

@keyframes bahia-fade-slide-up {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ==========================================================================
   RESPONSIVE (MÓVIL / PANTALLAS PEQUEÑAS)
   ========================================================================== */

@media (max-width: 480px) {
    .bahia-position-right,
    .bahia-position-left {
        bottom: 16px;
        right: 16px;
        left: auto;
    }

    .bahia-chat-window {
        position: fixed;
        bottom: 84px;
        right: 12px;
        left: 12px;
        width: auto;
        height: 75vh;
        max-height: 540px;
    }

    .bahia-cta-bubble {
        max-width: calc(100vw - 32px);
        right: 0;
    }
}

/* ==========================================================================
   ADMIN PANEL REDESIGN (CICLO 9A)
   ========================================================================== */

.bahia-admin-wrap {
    max-width: 980px;
    margin: 20px 20px 40px 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
}

.bahia-admin-header {
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid #cbd5e1;
}

.bahia-admin-header-title {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 0 0 6px 0;
    font-size: 22px;
    font-weight: 700;
    color: #0f172a;
}

.bahia-admin-header-title .dashicons {
    font-size: 26px;
    width: 26px;
    height: 26px;
    color: #0284c7;
}

.bahia-version-badge {
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    background: #e2e8f0;
    color: #475569;
    border-radius: 12px;
    letter-spacing: 0.5px;
}

.bahia-admin-header-desc {
    margin: 0;
    color: #64748b;
    font-size: 13.5px;
}

/* NAVEGACIÓN SUPERIOR (UPBAR) */
.bahia-nav-bar-container {
    margin-bottom: 24px;
    background: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: 10px;
    padding: 6px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03);
}

.bahia-nav-bar {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
}

.bahia-nav-bar::-webkit-scrollbar {
    height: 4px;
}

.bahia-nav-bar::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

.bahia-nav-tab {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 9px 16px;
    font-size: 13.5px;
    font-weight: 500;
    color: #475569;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 7px;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.15s ease-in-out;
    user-select: none;
}

.bahia-nav-tab .dashicons {
    font-size: 18px;
    width: 18px;
    height: 18px;
    color: #64748b;
    transition: color 0.15s ease-in-out;
}

.bahia-nav-tab:hover {
    background: #f1f5f9;
    color: #0f172a;
}

.bahia-nav-tab:hover .dashicons {
    color: #0284c7;
}

.bahia-nav-tab.bahia-nav-tab-active {
    background: #0284c7;
    color: #ffffff;
    font-weight: 600;
    box-shadow: 0 2px 6px rgba(2, 132, 199, 0.25);
}

.bahia-nav-tab.bahia-nav-tab-active .dashicons {
    color: #ffffff;
}

.bahia-nav-tab:focus-visible {
    outline: 2px solid #0284c7;
    outline-offset: 2px;
}

/* SECCIONES Y CONTENIDO */
.bahia-section {
    display: none;
}

.bahia-section.bahia-section-active {
    display: block;
}

.bahia-card {
    background: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: 10px;
    padding: 24px;
    margin-bottom: 24px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.02);
}

.bahia-card-header {
    margin-bottom: 20px;
    padding-bottom: 14px;
    border-bottom: 1px solid #f1f5f9;
}

.bahia-card-title {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0 0 6px 0;
    font-size: 17px;
    font-weight: 600;
    color: #0f172a;
}

.bahia-card-title .dashicons {
    color: #0284c7;
    font-size: 20px;
    width: 20px;
    height: 20px;
}

.bahia-card-subtitle {
    margin: 0;
    font-size: 13px;
    color: #64748b;
}

/* DASHBOARD GRID EN SECCIÓN ESTADO */
.bahia-status-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 16px;
    margin-bottom: 10px;
}

.bahia-stat-box {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.bahia-stat-box-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #64748b;
}

.bahia-stat-box-value {
    font-size: 15px;
    font-weight: 600;
    color: #0f172a;
    word-break: break-word;
}

.bahia-stat-box-desc {
    font-size: 12.5px;
    color: #64748b;
    margin: 0;
    line-height: 1.4;
}

/* BOTONES Y ACCIONES */
.bahia-form-actions {
    margin-top: 24px;
    padding: 16px 0;
    display: flex;
    align-items: center;
    gap: 12px;
}

/* BADGES DE ESTADO */
.bahia-status-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 20px;
    font-weight: 600;
    font-size: 12.5px;
}

.bahia-status-connected {
    background-color: #dcfce7;
    color: #15803d;
    border: 1px solid #bbf7d0;
}

.bahia-status-disconnected {
    background-color: #fee2e2;
    color: #b91c1c;
    border: 1px solid #fecaca;
}

