.aichat-widget {
    --aichat-accent: #3182ce;
    font-family: inherit;
    font-size: inherit;
    line-height: 1.5;
}
.aichat-panel {
    font-size: 0.9rem;
}

.aichat-widget-floating {
    position: fixed;
    bottom: 20px;
    z-index: 999999;
}

.aichat-widget-floating.aichat-pos-bottom-right { right: 20px; }
.aichat-widget-floating.aichat-pos-bottom-left { left: 20px; }

/* !important throughout this rule: host themes commonly ship a global
   `button { ... }` reset (padding/width/height/background) that otherwise
   wins on load order or specificity and collapses this into a
   theme-colored, icon-less oval instead of a circular icon button. */
.aichat-bubble-btn {
    box-sizing: border-box !important;
    width: 56px !important;
    height: 56px !important;
    min-width: 56px !important;
    min-height: 56px !important;
    max-width: 56px !important;
    max-height: 56px !important;
    margin: 0 !important;
    padding: 0 !important;
    border-radius: 50% !important;
    border: none !important;
    background: var(--aichat-accent) !important;
    color: #fff !important;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
    cursor: pointer;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    flex-shrink: 0;
    line-height: 1 !important;
    transition: transform 0.15s ease;
}
.aichat-bubble-btn:hover { transform: scale(1.06); }
.aichat-bubble-icon {
    display: block !important;
    width: 26px !important;
    height: 26px !important;
    max-width: none !important;
    flex-shrink: 0;
}
.aichat-bubble-icon-dot { fill: var(--aichat-accent); }

.aichat-widget-floating .aichat-panel {
    position: absolute;
    bottom: 68px;
    width: 320px;
    max-width: calc(100vw - 40px);
    height: 440px;
    max-height: 70vh;
}
.aichat-widget-floating.aichat-pos-bottom-right .aichat-panel { right: 0; }
.aichat-widget-floating.aichat-pos-bottom-left .aichat-panel { left: 0; }

.aichat-widget-inline .aichat-panel {
    width: 100%;
    max-width: 480px;
    height: 480px;
}

.aichat-panel {
    display: flex;
    flex-direction: column;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.18), 0 2px 6px rgba(0, 0, 0, 0.08);
    overflow: hidden;
}
.aichat-panel[hidden] { display: none; }

.aichat-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--aichat-accent);
    color: #fff;
    padding: 12px 16px;
    font-weight: 600;
}
.aichat-close-btn {
    background: none;
    border: none;
    color: #fff;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    padding: 0;
}

.aichat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: #f7f9fb;
}

.aichat-msg {
    max-width: 85%;
    padding: 8px 12px;
    border-radius: 12px;
    white-space: pre-wrap;
    word-break: break-word;
}
.aichat-msg-bot {
    align-self: flex-start;
    background: #fff;
    border: 1px solid #e2e8f0;
    color: #1a202c;
    border-bottom-left-radius: 4px;
}
.aichat-msg-user {
    align-self: flex-end;
    background: var(--aichat-accent);
    color: #fff;
    border-bottom-right-radius: 4px;
}
.aichat-msg-error {
    align-self: flex-start;
    background: #fff5f5;
    border: 1px solid #fed7d7;
    color: #c53030;
}
.aichat-msg-typing {
    align-self: flex-start;
    background: #fff;
    border: 1px solid #e2e8f0;
    color: #a0aec0;
    font-style: italic;
}
.aichat-msg-agent {
    align-self: flex-start;
    background: #fefcbf;
    border: 1px solid #f0e18c;
    color: #744210;
    border-bottom-left-radius: 4px;
}
.aichat-msg-system {
    align-self: center;
    background: none;
    border: none;
    color: #a0aec0;
    font-size: 0.8rem;
    font-style: italic;
    text-align: center;
    max-width: 100%;
}

.aichat-form {
    display: flex;
    gap: 8px;
    padding: 10px;
    border-top: 1px solid #e2e8f0;
    background: #fff;
}
.aichat-widget .aichat-input {
    flex: 1;
    border: 1px solid #cbd5e0;
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 14px;
    background: #ffffff !important;
    color: #333333 !important;
}
.aichat-widget .aichat-input:focus {
    outline: none;
    border-color: var(--aichat-accent);
    box-shadow: 0 0 0 3px rgba(49, 130, 206, 0.2);
}
.aichat-send-btn {
    border: none;
    background: var(--aichat-accent);
    color: #fff;
    border-radius: 8px;
    width: 38px;
    cursor: pointer;
    flex-shrink: 0;
}
.aichat-send-btn:disabled {
    opacity: 0.6;
    cursor: default;
}
