#ags-widget { position: fixed; z-index: 999998; font-family: system-ui, sans-serif; }
#ags-toggle { width: 58px; height: 58px; border-radius: 50%; background: var(--ags-btn-bg); color: var(--ags-btn-color); border: none; box-shadow: 0 4px 14px rgba(0,0,0,0.2); cursor: pointer; display: flex; align-items: center; justify-content: center; transition: transform 0.2s; }
#ags-toggle:hover { transform: scale(1.05); }
#ags-toggle img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }

/* Ventana ampliada a 420px y adaptada a móvil */
#ags-window { 
    position: absolute; 
    bottom: 70px; 
    width: 420px; 
    max-width: 92vw; 
    height: 520px; 
    max-height: 80vh; 
    background: #fff; 
    border-radius: 12px; 
    box-shadow: 0 10px 30px rgba(0,0,0,0.15); 
    display: flex; 
    flex-direction: column; 
    transition: opacity 0.2s, transform 0.2s; 
}
#ags-window.ags-hidden { opacity: 0; pointer-events: none; transform: translateY(10px); }
#ags-header { background: var(--ags-header-bg); color: var(--ags-header-color); padding: 14px; display: flex; justify-content: space-between; align-items: center; border-radius: 12px 12px 0 0; }
.ags-info { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.ags-avatar { width: 28px; height: 28px; border-radius: 50%; }
#ags-close { background: none; border: none; color: inherit; font-size: 24px; cursor: pointer; }
#ags-body { flex: 1; background: #f8f9fa; padding: 16px; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; overflow-x: hidden; }

/* Mensajes generales */
.ags-msg { 
    max-width: 90%; 
    width: auto; 
    padding: 12px 16px; 
    border-radius: 12px; 
    font-size: 14px; 
    line-height: 1.5; 
    word-wrap: break-word; 
    overflow-wrap: break-word; 
    box-sizing: border-box; 
}
.ags-msg.ags-user { 
    background: var(--ags-header-bg); 
    color: var(--ags-header-color); 
    align-self: flex-end; 
    margin-left: auto; 
    border-bottom-right-radius: 2px; 
}

/* Burbuja del bot */
.ags-msg.ags-bot { 
    display: flex; 
    align-items: flex-start; 
    gap: 12px; 
    background: #fff; 
    border: 1px solid #e9ecef; 
    color: #1d2327; 
    margin-right: auto; 
    border-bottom-left-radius: 2px; 
    box-sizing: border-box;
}
.ags-msg.ags-bot > div { 
    flex: 1; 
    min-width: 0; 
    overflow-wrap: break-word; 
    word-break: break-word; 
}

/* Dimensiones estrictas del avatar dentro del chat */
.ags-bot-avatar { 
    width: 28px !important; 
    height: 28px !important; 
    min-width: 28px !important; 
    max-width: 28px !important; 
    min-height: 28px !important; 
    max-height: 28px !important; 
    border-radius: 50%; 
    object-fit: contain !important; 
    flex-shrink: 0 !important; 
    margin-top: 2px; 
}

.ags-loading { font-style: italic; opacity: 0.7; }
#ags-form { display: flex; padding: 10px; border-top: 1px solid #eee; gap: 8px; }
#ags-input { flex: 1; border: 1px solid #ccc; border-radius: 6px; padding: 8px 12px; outline: none; }
#ags-send { background: var(--ags-btn-bg); color: var(--ags-btn-color); border: none; border-radius: 6px; padding: 8px 14px; font-weight: 600; cursor: pointer; }
#ags-send:disabled { opacity: 0.6; }

/* Formato de respuestas Markdown */
.ags-bot { line-height: 1.6; }
.ags-bot ul { list-style-type: disc !important; margin-left: 20px !important; margin-bottom: 15px !important; }
.ags-bot strong { font-weight: 700 !important; color: #111; }
.ags-bot table { width: 100%; border-collapse: collapse; margin-top: 10px; table-layout: fixed; }
.ags-bot th, .ags-bot td { border: 1px solid #ddd; padding: 8px; word-break: break-word; }

/* Marca de agua KnsK Web Studio en el pie del chat */
.ags-branding {
    text-align: center;
    padding: 6px 10px;
    font-size: 11px;
    color: #8c8f94;
    background: #fff;
    border-top: 1px solid #f0f0f1;
    border-radius: 0 0 12px 12px;
}
.ags-branding a {
    color: #646970;
    text-decoration: none;
    font-weight: 600;
    transition: color 0.2s ease;
}
.ags-branding a:hover {
    color: #135e96;
    text-decoration: underline;
}