/*
 * Layout and nothing else: spacing, the floating position and the bubbles. Colours, fonts and radii come from
 * variables so a theme can restyle the chat from its own stylesheet.
 */
.hub-chat {
    --hub-chat-accent: #1d4ed8;
    --hub-chat-accent-text: #fff;
    --hub-chat-surface: #fff;
    --hub-chat-muted: #f1f5f9;
    --hub-chat-border: #cbd5e1;
    --hub-chat-text: #0f172a;
    --hub-chat-error: #b91c1c;
    --hub-chat-radius: 12px;
    font-family: inherit;
    color: var(--hub-chat-text);
}

.hub-chat__panel {
    display: flex;
    flex-direction: column;
    max-width: 420px;
    min-height: 360px;
    max-height: 640px;
    background: var(--hub-chat-surface);
    border: 1px solid var(--hub-chat-border);
    border-radius: var(--hub-chat-radius);
    overflow: hidden;
}

.hub-chat__panel[hidden],
.hub-chat__toggle[hidden],
.hub-chat [hidden] {
    display: none !important;
}

.hub-chat--floating {
    position: fixed;
    right: 16px;
    bottom: 16px;
    z-index: 99999;
}

.hub-chat--floating .hub-chat__panel {
    width: min(380px, calc(100vw - 32px));
    height: min(600px, calc(100vh - 32px));
    box-shadow: 0 12px 32px rgba(15, 23, 42, 0.18);
}

.hub-chat__toggle {
    padding: 12px 18px;
    border: 0;
    border-radius: 999px;
    background: var(--hub-chat-accent);
    color: var(--hub-chat-accent-text);
    font: inherit;
    cursor: pointer;
    box-shadow: 0 6px 18px rgba(15, 23, 42, 0.2);
}

.hub-chat__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 12px 16px;
    background: var(--hub-chat-accent);
    color: var(--hub-chat-accent-text);
}

.hub-chat__title {
    margin: 0;
    font-weight: 600;
}

.hub-chat__minimize {
    border: 0;
    background: transparent;
    color: inherit;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
}

.hub-chat__body {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: 12px;
    min-height: 0;
    padding: 16px;
    overflow-y: auto;
}

.hub-chat__start,
.hub-chat__phone {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.hub-chat__intro,
.hub-chat__notice {
    margin: 0;
}

.hub-chat__field {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.hub-chat__label {
    font-size: 0.875em;
    font-weight: 600;
}

.hub-chat__input {
    box-sizing: border-box;
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--hub-chat-border);
    border-radius: 8px;
    background: #fff;
    color: inherit;
    font: inherit;
}

.hub-chat__input[aria-invalid='true'] {
    border-color: var(--hub-chat-error);
}

.hub-chat__checkbox {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    font-size: 0.875em;
}

.hub-chat__error {
    margin: 0;
    color: var(--hub-chat-error);
    font-size: 0.875em;
}

.hub-chat__button {
    padding: 10px 16px;
    border: 0;
    border-radius: 8px;
    background: var(--hub-chat-accent);
    color: var(--hub-chat-accent-text);
    font: inherit;
    cursor: pointer;
}

.hub-chat__button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.hub-chat__button--secondary {
    border: 1px solid var(--hub-chat-accent);
    background: transparent;
    color: var(--hub-chat-accent);
}

.hub-chat__messages {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: 8px;
    min-height: 120px;
    overflow-y: auto;
}

.hub-chat__message {
    max-width: 85%;
    padding: 8px 12px;
    border-radius: var(--hub-chat-radius);
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.hub-chat__message--assistant {
    align-self: flex-start;
    background: var(--hub-chat-muted);
}

.hub-chat__message--user {
    align-self: flex-end;
    background: var(--hub-chat-accent);
    color: var(--hub-chat-accent-text);
}

.hub-chat__message--system {
    align-self: center;
    font-size: 0.875em;
    opacity: 0.8;
}

.hub-chat__message--error {
    color: var(--hub-chat-error);
    opacity: 1;
}

.hub-chat__message--typing {
    font-style: italic;
    opacity: 0.7;
}

.hub-chat__composer {
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

.hub-chat__input--message {
    resize: none;
}

.hub-chat__contact {
    padding: 12px;
    border: 1px solid var(--hub-chat-border);
    border-radius: 8px;
}

.hub-chat__contact-title {
    margin: 0 0 8px;
    font-weight: 600;
}

.hub-chat__contact-options {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.hub-chat__end {
    align-self: center;
    border: 0;
    background: transparent;
    color: inherit;
    font: inherit;
    font-size: 0.875em;
    text-decoration: underline;
    cursor: pointer;
}
