/* Variables CSS personalizables */
:root {
    --hexbot-primary-color: #0073aa;
    --hexbot-secondary-color: #005177;
    --hexbot-background-color: #ffffff;
    --hexbot-text-color: #333333;
    --hexbot-user-message-color: var(--hexbot-primary-color);
    --hexbot-bot-message-color: #f1f1f1;
    --hexbot-font-size: 14px;
    --hexbot-font-family: inherit;
}

/* Estilos base del chatbot */
/* Burbuja siempre visible salvo cuando el chat está abierto */
.hexbot-toggle {
    position: fixed;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--hexbot-primary-color, #0073aa);
    color: white;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 9998;
    display: flex !important;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s ease;
}

.hexbot-toggle.hexbot-toggle-hidden {
    display: none !important;
}

.hexbot-toggle:hover {
    transform: scale(1.1);
}

.hexbot-toggle img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}

.hexbot-toggle svg {
    width: 28px;
    height: 28px;
}

/* Posiciones del toggle */
.hexbot-position-bottom-right {
    bottom: 20px;
    right: 20px;
}

.hexbot-position-bottom-left {
    bottom: 20px;
    left: 20px;
}

.hexbot-position-top-right {
    top: 20px;
    right: 20px;
}

.hexbot-position-top-left {
    top: 20px;
    left: 20px;
}

/* Wrapper: cerrado por defecto. Solo visible al hacer clic en la burbuja (.hexbot-open) */
.hexbot-chat-wrapper {
    position: fixed;
    flex-direction: row;
    align-items: stretch;
    gap: 0;
    z-index: 9999;
    max-height: 80vh;
}

.hexbot-chat-wrapper:not(.hexbot-open) {
    display: none !important;
}

.hexbot-chat-wrapper.hexbot-open {
    display: flex !important;
}

.hexbot-chat-wrapper.hexbot-debug-open {
    width: 760px;
    max-width: calc(100vw - 40px);
}

.hexbot-position-bottom-right .hexbot-chat-wrapper {
    bottom: 90px;
    right: 20px;
}

.hexbot-position-bottom-left .hexbot-chat-wrapper {
    bottom: 90px;
    left: 20px;
}

.hexbot-position-top-right .hexbot-chat-wrapper {
    top: 90px;
    right: 20px;
}

.hexbot-position-top-left .hexbot-chat-wrapper {
    top: 90px;
    left: 20px;
}

/* Contenedor del chatbot */
.hexbot-chatbot {
    width: 380px;
    min-width: 380px;
    height: 600px;
    max-height: 80vh;
    background: var(--hexbot-background-color, #ffffff);
    border-radius: 12px 0 0 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    font-size: var(--hexbot-font-size, 14px);
    font-family: var(--hexbot-font-family, inherit);
    color: var(--hexbot-text-color, #333333);
}

.hexbot-chat-wrapper:not(.hexbot-debug-open) .hexbot-chatbot {
    border-radius: 12px;
}

.hexbot-chat-wrapper.hexbot-debug-open .hexbot-chatbot {
    border-radius: 12px 0 0 12px;
}

/* Header del chat */
.hexbot-chat-header {
    background: var(--hexbot-primary-color, #0073aa);
    color: white;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.hexbot-chat-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.hexbot-avatar,
.hexbot-avatar-default {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
}

.hexbot-avatar-default {
    background: rgba(255, 255, 255, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 18px;
}

.hexbot-chat-header-text {
    display: flex;
    flex-direction: column;
}

.hexbot-chat-header-text strong {
    font-size: 16px;
}

.hexbot-status {
    font-size: 12px;
    opacity: 0.9;
}

.hexbot-close {
    background: none;
    border: none;
    color: white;
    font-size: 28px;
    cursor: pointer;
    line-height: 1;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.2s;
}

.hexbot-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Panel debug: solo visible cuando el wrapper tiene .hexbot-debug-open (Modo debug en configuración) */
.hexbot-chat-wrapper:not(.hexbot-debug-open) .hexbot-debug-panel {
    display: none !important;
}

.hexbot-chat-wrapper.hexbot-debug-open .hexbot-debug-panel {
    display: flex !important;
}

.hexbot-debug-panel {
    width: 380px;
    min-width: 320px;
    height: 600px;
    max-height: 80vh;
    background: #1e1e1e;
    border-radius: 0 12px 12px 0;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    flex-direction: column;
    overflow: hidden;
    font-size: 12px;
    font-family: monospace;
    color: #d4d4d4;
}

.hexbot-debug-header {
    background: #333;
    color: #fff;
    padding: 12px 14px;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.hexbot-debug-header-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.hexbot-debug-header strong {
    font-size: 14px;
}

.hexbot-debug-subtitle {
    font-size: 11px;
    opacity: 0.85;
}

.hexbot-debug-download-btn {
    background: #555;
    border: 1px solid #666;
    color: #fff;
    font-size: 11px;
    padding: 6px 10px;
    border-radius: 6px;
    cursor: pointer;
    white-space: nowrap;
}

.hexbot-debug-download-btn:hover {
    background: #666;
}

.hexbot-debug-content {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    white-space: pre-wrap;
    word-break: break-word;
}

.hexbot-debug-empty {
    color: #888;
    font-style: italic;
    margin: 0;
}

.hexbot-debug-step {
    margin-bottom: 10px;
    padding: 8px 10px;
    background: #2d2d2d;
    border-radius: 6px;
    border-left: 3px solid var(--hexbot-primary-color, #0073aa);
}

.hexbot-debug-block {
    margin-top: 12px;
    padding: 10px;
    background: #252526;
    border-radius: 6px;
    font-size: 11px;
    max-height: 200px;
    overflow-y: auto;
}

.hexbot-debug-block-title {
    font-weight: bold;
    margin-bottom: 6px;
    color: #9cdcfe;
}

.hexbot-debug-block.system {
    max-height: 300px;
}

/* Mensajes */
.hexbot-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.hexbot-message {
    display: flex;
    flex-direction: column;
    max-width: 85%;
    animation: fadeIn 0.3s ease;
}

.hexbot-message-user {
    flex-direction: column;
    align-items: flex-end;
}

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

.hexbot-message-bot {
    align-self: flex-start;
}

.hexbot-message-content {
    padding: 12px 16px;
    border-radius: 18px;
    word-wrap: break-word;
    line-height: 1.4;
}

.hexbot-message-user .hexbot-message-content {
    background: var(--hexbot-user-message-color, var(--hexbot-primary-color, #0073aa));
    color: white;
    border-bottom-right-radius: 4px;
}

.hexbot-message-bot .hexbot-message-content {
    background: var(--hexbot-bot-message-color, #f1f1f1);
    color: var(--hexbot-text-color, #333);
    border-bottom-left-radius: 4px;
}

/* Indicador de escritura */
.hexbot-typing-indicator {
    padding: 10px 20px;
    display: flex;
    gap: 5px;
}

.hexbot-typing-indicator span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #999;
    animation: typing 1.4s infinite;
}

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

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

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

/* Input */
.hexbot-chat-input-container {
    border-top: 1px solid #e0e0e0;
    padding: 15px;
    display: flex;
    align-items: flex-end;
    gap: 10px;
    background: #f9f9f9;
}

.hexbot-input {
    flex: 1;
    border: 1px solid #ddd;
    border-radius: 20px;
    padding: 10px 15px;
    resize: none;
    font-family: inherit;
    font-size: 14px;
    max-height: 100px;
    overflow-y: auto;
}

.hexbot-input:focus {
    outline: none;
    border-color: var(--hexbot-primary-color, #0073aa);
}

.hexbot-send-button {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--hexbot-primary-color, #0073aa);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    flex-shrink: 0;
}

.hexbot-send-button:hover {
    background: var(--hexbot-secondary-color, #005177);
}

.hexbot-send-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Estilos según el tema seleccionado */
.hexbot-style-minimal .hexbot-chatbot {
    border-radius: 0;
}

.hexbot-style-minimal .hexbot-message-content {
    border-radius: 4px;
}

.hexbot-style-rounded .hexbot-chatbot {
    border-radius: 24px;
}

.hexbot-style-rounded .hexbot-message-content {
    border-radius: 20px;
}

.hexbot-style-classic .hexbot-chatbot {
    border-radius: 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.hexbot-style-classic .hexbot-chat-header {
    border-bottom: 2px solid rgba(255, 255, 255, 0.2);
}

/* Tarjetas de producto WooCommerce - compactas en vertical para no perder la conversación */
.hexbot-product-cards {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 10px;
    padding: 2px 0;
    width: 100%;
    max-height: 280px;
    overflow-y: auto;
}

.hexbot-product-card {
    display: flex;
    flex-direction: row;
    align-items: center;
    width: 100%;
    max-width: 100%;
    text-decoration: none;
    color: inherit;
    border: 1px solid rgba(0, 0, 0, 0.06);
    border-radius: 8px;
    overflow: hidden;
    background: #fff;
    transition: all 0.2s ease;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
    flex-shrink: 0;
}

.hexbot-product-card:hover {
    border-color: var(--hexbot-primary-color, #0073aa);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.hexbot-product-card__img-wrap {
    flex-shrink: 0;
    width: 56px;
    height: 56px;
    background: linear-gradient(135deg, #f0f2f5 0%, #e4e8ec 100%);
    overflow: hidden;
}

.hexbot-product-card__img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.hexbot-product-card__body {
    flex: 1;
    padding: 8px 10px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.hexbot-product-card__title {
    font-size: 12px;
    font-weight: 600;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    color: #1a1a1a;
}

.hexbot-product-card__price {
    font-size: 11px;
    font-weight: 700;
    color: var(--hexbot-primary-color, #0073aa);
}

.hexbot-product-card__cta {
    display: inline-flex;
    align-items: center;
    margin-top: 4px;
    padding: 4px 8px;
    font-size: 10px;
    font-weight: 600;
    color: #fff;
    background: var(--hexbot-primary-color, #0073aa);
    border-radius: 4px;
    transition: background 0.2s;
    width: fit-content;
}

.hexbot-product-card__cta::after {
    content: "→";
    font-size: 10px;
    margin-left: 2px;
}

.hexbot-product-card:hover .hexbot-product-card__cta {
    background: var(--hexbot-secondary-color, #005177);
}

/* Responsive - Modo móvil / teléfono */
@media (max-width: 480px) {
    .hexbot-chat-wrapper {
        left: 0 !important;
        right: 0 !important;
        max-height: calc(100vh - 90px) !important;
    }
    
    .hexbot-position-bottom-right .hexbot-chat-wrapper,
    .hexbot-position-bottom-left .hexbot-chat-wrapper {
        bottom: 80px !important;
        left: 0 !important;
        right: 0 !important;
    }
    
    .hexbot-position-top-right .hexbot-chat-wrapper,
    .hexbot-position-top-left .hexbot-chat-wrapper {
        top: 80px !important;
        left: 0 !important;
        right: 0 !important;
    }
    
    .hexbot-chatbot {
        width: calc(100vw - 24px) !important;
        min-width: unset !important;
        height: calc(100vh - 100px) !important;
        max-height: calc(100vh - 100px) !important;
        border-radius: 12px 12px 0 0;
        margin: 0 auto;
    }
    
    .hexbot-chat-header {
        padding: 12px 16px;
    }
    
    .hexbot-chat-messages {
        padding: 12px 16px;
    }
    
    .hexbot-chat-input-container {
        padding: 12px;
    }
    
    .hexbot-toggle {
        width: 52px;
        height: 52px;
    }
}
