/* CWS Shopper — widget flotante. Todos los colores se leen de CSS custom properties
   inyectadas vía inline style en el contenedor #sekega-bot. Si el operador no las
   define, se aplican los defaults declarados aquí. */

.sekega-bot {
    --cws-accent:    #c9a063;
    --cws-icon:      #1a1a1a;
    --cws-header-bg: #1a1a1a;
    --cws-header-fg: #ffffff;
    --cws-chat-bg:   #f6f5f1;
    --cws-bot-bg:    #ffffff;
    --cws-bot-fg:    #1a1a1a;
    --cws-user-bg:   #1a1a1a;
    --cws-user-fg:   #ffffff;
    --cws-send-bg:   #c9a063;
    --cws-send-fg:   #1a1a1a;

    position: fixed;
    bottom: 24px;
    z-index: 9998;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    color: #1a1a1a;
}

.sekega-bot--left  { left:  24px; }
.sekega-bot--right { right: 24px; }

/* Cuando hay JoinChat (botón WhatsApp) en la misma esquina, apilarse encima. */
.sekega-bot--joinchat-stack { bottom: 110px !important; }
.sekega-bot--joinchat-stack .sekega-bot__window { bottom: 165px; }
@media (max-width: 480px) {
    .sekega-bot--joinchat-stack { bottom: 90px !important; }
    .sekega-bot--joinchat-stack .sekega-bot__window { bottom: 145px; }
}

/* ----- Botón flotante ----- */

.sekega-bot__bubble {
    /* Reset agresivo: themes como WoodMart aplican estilos a TODOS los <button>.
       !important evita que pisen el look del bot. */
    width: 64px !important;
    height: 64px !important;
    min-height: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    border-radius: 50% !important;
    background: var(--cws-accent) !important;
    color: var(--cws-icon) !important;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.18) !important;
    cursor: pointer;
    display: grid;
    place-items: center;
    overflow: hidden;
    transition: transform 0.18s ease, box-shadow 0.18s ease;
    text-transform: none !important;
    font-weight: normal !important;
}
.sekega-bot__bubble:hover,
.sekega-bot__bubble:focus-visible {
    transform: translateY(-2px) scale(1.04);
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.22);
    outline: none;
}
.sekega-bot__bubble:focus-visible {
    outline: 2px solid var(--cws-icon);
    outline-offset: 3px;
}

.sekega-bot__bubble-svg {
    display: grid;
    place-items: center;
}
.sekega-bot__bubble-svg svg {
    width: 38px;
    height: 38px;
    display: block;
    pointer-events: none;
}
.sekega-bot__bubble-img {
    /* Imagen subida por el usuario; se respeta el tamaño que él haya elegido. */
    display: block;
    pointer-events: none;
    max-width: 100%;
    max-height: 100%;
}

/* ----- Ventana ----- */

.sekega-bot__window {
    position: absolute;
    bottom: 80px;
    width: min(380px, calc(100vw - 48px));
    height: min(560px, calc(100vh - 120px));
    background: #ffffff;
    border-radius: 14px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: sekega-bot-pop 0.22s ease-out;
}
.sekega-bot--left  .sekega-bot__window { left: 0;  transform-origin: bottom left; }
.sekega-bot--right .sekega-bot__window { right: 0; transform-origin: bottom right; }
.sekega-bot__window[hidden] { display: none; }

@keyframes sekega-bot-pop {
    from { opacity: 0; transform: translateY(8px) scale(0.96); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ----- Header ----- */

.sekega-bot__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    background: var(--cws-header-bg) !important;
    color: var(--cws-header-fg) !important;
    flex: 0 0 auto;
}
.sekega-bot__title {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
    letter-spacing: 0.2px;
    color: inherit;
}
.sekega-bot__close {
    background: transparent !important;
    border: 0 !important;
    min-height: 0 !important;
    color: inherit !important;
    font-size: 24px !important;
    line-height: 1 !important;
    cursor: pointer;
    padding: 0 4px !important;
    opacity: 0.85;
    text-transform: none !important;
    font-weight: normal !important;
}
.sekega-bot__close:hover { opacity: 1; }

/* ----- Cuerpo (lienzo de la conversación) ----- */

.sekega-bot__body {
    padding: 16px;
    overflow-y: auto;
    flex: 1 1 auto;
    background: var(--cws-chat-bg) !important;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.sekega-bot__messages {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.sekega-bot__msg {
    max-width: 80%;
    padding: 10px 13px;
    border-radius: 14px;
    font-size: 14px;
    line-height: 1.45;
    word-wrap: break-word;
    white-space: pre-wrap;
    animation: sekega-bot-fade 0.2s ease-out;
}
@keyframes sekega-bot-fade {
    from { opacity: 0; transform: translateY(4px); }
    to   { opacity: 1; transform: translateY(0); }
}
.sekega-bot__msg--bot {
    align-self: flex-start;
    background: var(--cws-bot-bg) !important;
    color: var(--cws-bot-fg) !important;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}
.sekega-bot__msg--bot a {
    color: var(--cws-accent) !important;
    text-decoration: underline;
    text-underline-offset: 2px;
    word-break: break-word;
}
.sekega-bot__msg--bot a:hover {
    text-decoration: none;
    filter: brightness(0.9);
}
.sekega-bot__msg--bot strong { font-weight: 600; }
.sekega-bot__msg--user {
    align-self: flex-end;
    background: var(--cws-user-bg) !important;
    color: var(--cws-user-fg) !important;
    border-bottom-right-radius: 4px;
}

/* ----- Indicador "escribiendo..." ----- */

.sekega-bot__typing {
    align-self: flex-start;
    background: var(--cws-bot-bg);
    border-radius: 14px;
    border-bottom-left-radius: 4px;
    padding: 10px 14px;
    display: flex;
    gap: 4px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}
.sekega-bot__typing[hidden] { display: none; }
.sekega-bot__typing span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--cws-accent) !important;
    animation: sekega-bot-bounce 1.2s infinite ease-in-out;
}
.sekega-bot__typing span:nth-child(2) { animation-delay: 0.15s; }
.sekega-bot__typing span:nth-child(3) { animation-delay: 0.3s; }

@keyframes sekega-bot-bounce {
    0%, 80%, 100% { transform: translateY(0);  opacity: 0.4; }
    40%           { transform: translateY(-4px); opacity: 1; }
}

/* ----- Form de envío ----- */

.sekega-bot__form {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    background: #fff;
    border-top: 1px solid #ececec;
}

.sekega-bot__input {
    flex: 1;
    border: 1px solid #d8d8d8;
    border-radius: 999px;
    padding: 9px 14px;
    font-size: 14px;
    background: #fafafa;
    color: #1a1a1a;
    transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
    outline: none; /* quita el outline default del navegador */
    box-shadow: none;
}
.sekega-bot__input:focus,
.sekega-bot__input:focus-visible {
    border-color: var(--cws-accent);
    background: #fff;
    outline: none;
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--cws-accent) 25%, transparent);
}
/* Fallback para navegadores sin color-mix (~Safari < 16.2 y similares) */
@supports not (background: color-mix(in srgb, red 50%, blue)) {
    .sekega-bot__input:focus,
    .sekega-bot__input:focus-visible {
        box-shadow: 0 0 0 2px var(--cws-accent);
    }
}

.sekega-bot__send {
    width: 40px !important;
    height: 40px !important;
    min-height: 0 !important;
    border: 0 !important;
    border-radius: 50% !important;
    background: var(--cws-send-bg) !important;
    color: var(--cws-send-fg) !important;
    cursor: pointer;
    display: grid;
    place-items: center;
    padding: 0 !important;
    flex: 0 0 40px;
    transition: transform 0.15s ease, filter 0.15s ease;
    text-transform: none !important;
    font-weight: normal !important;
}
.sekega-bot__send svg {
    display: block;
    width: 20px;
    height: 20px;
}
.sekega-bot__send:hover:not(:disabled) {
    filter: brightness(0.92);
    transform: scale(1.05);
}
.sekega-bot__send:disabled {
    background: #d8d8d8 !important;
    color: #fff !important;
    cursor: not-allowed;
}

.screen-reader-text {
    position: absolute !important;
    clip: rect(1px, 1px, 1px, 1px);
    height: 1px; width: 1px;
    overflow: hidden;
}

@media (max-width: 480px) {
    .sekega-bot--left  { left:  16px; bottom: 16px; }
    .sekega-bot--right { right: 16px; bottom: 16px; }
    .sekega-bot__window { bottom: 76px; }
}

/* Imágenes inline enviadas por el bot (renderizadas desde ![alt](url)). */
.sekega-bot__inline-img {
    display: block;
    max-width: 100%;
    height: auto;
    margin: 6px 0;
    border-radius: 8px;
    cursor: zoom-in;
    border: 1px solid rgba(0,0,0,0.08);
    transition: transform 0.12s ease;
}
.sekega-bot__inline-img:hover { transform: scale(1.01); }

/* Lightbox: cubre TODO el viewport del navegador (fixed, no absolute). */
.sekega-bot__lightbox {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.92);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 32px;
    z-index: 2147483646; /* por encima de cualquier elemento del sitio */
    cursor: zoom-out;
    box-sizing: border-box;
}
.sekega-bot__lightbox[hidden] { display: none; }
.sekega-bot__lightbox-img {
    max-width: 96vw;
    max-height: 92vh;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.5);
    cursor: default;
}
.sekega-bot__lightbox-close {
    position: fixed;
    top: 16px;
    right: 18px;
    width: 44px;
    height: 44px;
    background: rgba(255,255,255,0.95);
    border: 0;
    border-radius: 50%;
    color: #1a1a1a;
    font-size: 26px;
    line-height: 1;
    cursor: pointer;
    box-shadow: 0 2px 10px rgba(0,0,0,0.4);
    z-index: 2147483647;
}
.sekega-bot__lightbox-close:hover { background: #fff; }
@media (max-width: 480px) {
    .sekega-bot__lightbox { padding: 8px; }
    .sekega-bot__lightbox-img { max-width: 100vw; max-height: 90vh; }
}
