/* =========================================================
   SIA Interiors — Chatbot Widget
   Scoped entirely under .sia-chatbot. Does not touch global
   button/input styles.
   ========================================================= */

.sia-chatbot {
    --sia-chat-primary: var(--primary-color, #123524);
    --sia-chat-primary-dark: var(--primary-dark, #0b2318);
    --sia-chat-gold: #dabd79;
    --sia-chat-bg: #ffffff;
    --sia-chat-surface: #f7f7f3;
    --sia-chat-border: #e5e5df;
    --sia-chat-text: #222222;
    --sia-chat-muted: #6b6b63;

    position: fixed;
    right: 24px;
    bottom: 24px;
    z-index: 1200;
    font-family: 'Segoe UI', Arial, sans-serif;
}

.sia-chatbot * {
    box-sizing: border-box;
}

/* --- Launcher button --- */

.sia-chatbot-launcher {
    position: relative;
    width: 62px;
    height: 62px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, var(--sia-chat-primary) 0%, var(--sia-chat-primary-dark) 100%);
    color: var(--sia-chat-gold);
    font-size: 1.5rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 12px 28px rgba(11, 35, 24, 0.35);
    transition: transform 220ms ease, box-shadow 220ms ease;
}

.sia-chatbot-launcher:hover {
    transform: translateY(-3px);
    box-shadow: 0 16px 34px rgba(11, 35, 24, 0.4);
}

.sia-chatbot-launcher:focus-visible {
    outline: 2px solid var(--sia-chat-gold);
    outline-offset: 3px;
}

.sia-chatbot-launcher-icon {
    transition: transform 220ms ease;
}

.sia-chatbot-launcher[aria-expanded="true"] .sia-chatbot-launcher-icon {
    transform: scale(0.9) rotate(-8deg);
}

.sia-chatbot-launcher-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    min-width: 20px;
    height: 20px;
    padding: 0 5px;
    border-radius: 999px;
    background-color: #c0392b;
    color: #fff;
    font-size: 0.6875rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--sia-chat-bg);
    animation: siaChatPulse 1.8s ease-in-out infinite;
}

@keyframes siaChatPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.12); }
}

/* --- Panel --- */

.sia-chatbot-panel {
    position: absolute;
    right: 0;
    bottom: 78px;
    width: 380px;
    max-width: calc(100vw - 24px);
    height: min(600px, calc(100vh - 120px));
    max-height: calc(100vh - 120px);
    background-color: var(--sia-chat-bg);
    border-radius: 18px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 24px 60px rgba(11, 35, 24, 0.28), 0 2px 8px rgba(11, 35, 24, 0.08);
    opacity: 0;
    transform: translateY(16px) scale(0.98);
    transform-origin: bottom right;
    transition: opacity 220ms ease, transform 220ms ease;
    pointer-events: none;
}

.sia-chatbot-panel.is-open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

.sia-chatbot-panel[hidden] {
    display: none;
}

/* --- Header --- */

.sia-chatbot-header {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 18px;
    background: linear-gradient(135deg, var(--sia-chat-primary) 0%, var(--sia-chat-primary-dark) 100%);
    color: #fff;
}

.sia-chatbot-header-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.sia-chatbot-header-avatar {
    flex: 0 0 auto;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background-color: rgba(218, 189, 121, 0.16);
    border: 1px solid rgba(218, 189, 121, 0.4);
    color: var(--sia-chat-gold);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
}

.sia-chatbot-header-title {
    margin: 0;
    font-family: 'Bodoni Moda', 'Didot', Georgia, serif;
    font-size: 1.0625rem;
    font-weight: 600;
    line-height: 1.25;
    color: #fff;
}

.sia-chatbot-header-subtitle {
    margin: 2px 0 0;
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.7);
}

.sia-chatbot-header-actions {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 8px;
}

.sia-chatbot-status {
    display: none;
    align-items: center;
    gap: 5px;
    font-size: 0.6875rem;
    color: rgba(255, 255, 255, 0.75);
    white-space: nowrap;
}

.sia-chatbot-status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background-color: #4caf50;
    box-shadow: 0 0 0 2px rgba(76, 175, 80, 0.25);
}

.sia-chatbot-icon-btn {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: none;
    background-color: rgba(255, 255, 255, 0.12);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    cursor: pointer;
    transition: background-color 180ms ease;
}

.sia-chatbot-icon-btn:hover {
    background-color: rgba(255, 255, 255, 0.22);
}

.sia-chatbot-icon-btn:focus-visible {
    outline: 2px solid var(--sia-chat-gold);
    outline-offset: 2px;
}

/* --- Messages --- */

.sia-chatbot-messages {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 18px 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background-color: var(--sia-chat-surface);
    scroll-behavior: smooth;
}

.sia-chatbot-msg {
    display: flex;
    max-width: 88%;
    animation: siaChatFadeIn 220ms ease;
}

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

.sia-chatbot-msg-bot {
    align-self: flex-start;
}

.sia-chatbot-msg-user {
    align-self: flex-end;
}

.sia-chatbot-bubble {
    padding: 11px 14px;
    border-radius: 14px;
    font-size: 0.875rem;
    line-height: 1.55;
}

.sia-chatbot-msg-bot .sia-chatbot-bubble {
    background-color: #fff;
    border: 1px solid var(--sia-chat-border);
    color: var(--sia-chat-text);
    border-bottom-left-radius: 4px;
}

.sia-chatbot-msg-user .sia-chatbot-bubble {
    background-color: var(--sia-chat-primary);
    color: #fff;
    border-bottom-right-radius: 4px;
}

/* Typing indicator */

.sia-chatbot-typing {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 13px 16px;
}

.sia-chatbot-typing span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background-color: var(--sia-chat-muted);
    animation: siaChatTypingBounce 1.1s ease-in-out infinite;
}

.sia-chatbot-typing span:nth-child(2) { animation-delay: 0.15s; }
.sia-chatbot-typing span:nth-child(3) { animation-delay: 0.3s; }

@keyframes siaChatTypingBounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
    30% { transform: translateY(-4px); opacity: 1; }
}

/* --- Option cards --- */

.sia-chatbot-options {
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-self: stretch;
    max-width: 92%;
}

.sia-chatbot-options.is-answered {
    opacity: 0.55;
}

.sia-chatbot-option-wrap {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.sia-chatbot-option {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    background-color: #fff;
    border: 1px solid var(--sia-chat-border);
    border-radius: 11px;
    padding: 12px 14px;
    font-size: 0.8438rem;
    font-weight: 600;
    color: var(--sia-chat-text);
    text-align: left;
    cursor: pointer;
    transition: transform 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}

.sia-chatbot-option:hover:not(:disabled) {
    transform: translateY(-2px);
    border-color: var(--sia-chat-gold);
    box-shadow: 0 8px 18px rgba(11, 35, 24, 0.1);
}

.sia-chatbot-option:focus-visible {
    outline: 2px solid var(--sia-chat-gold);
    outline-offset: 2px;
}

.sia-chatbot-option:disabled {
    cursor: not-allowed;
    opacity: 0.6;
    transform: none;
}

.sia-chatbot-option-icon {
    flex: 0 0 auto;
    width: 20px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--sia-chat-primary);
    font-size: 0.9375rem;
}

.sia-chatbot-option-label {
    flex: 1;
    min-width: 0;
}

.sia-chatbot-option-arrow {
    flex: 0 0 auto;
    color: var(--sia-chat-gold);
    font-size: 1rem;
}

.sia-chatbot-option-viewlink {
    align-self: flex-end;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--sia-chat-primary);
    text-decoration: none;
    padding: 0 4px;
}

.sia-chatbot-option-viewlink:hover {
    text-decoration: underline;
}

/* Restart / retry buttons */

.sia-chatbot-restart-btn {
    align-self: flex-start;
    background-color: var(--sia-chat-primary-dark);
    background-image: linear-gradient(135deg, var(--sia-chat-primary) 0%, var(--sia-chat-primary-dark) 100%);
    border: none;
    border-radius: 10px;
    color: var(--sia-chat-gold);
    font-weight: 700;
    font-size: 0.8125rem;
    letter-spacing: 0.5px;
    padding: 11px 20px;
    cursor: pointer;
    transition: transform 160ms ease, box-shadow 160ms ease;
}

.sia-chatbot-restart-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(11, 35, 24, 0.25);
}

.sia-chatbot-restart-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.sia-chatbot-restart-btn-retry {
    background-image: none;
    background-color: #b3261e;
}

/* Success block */

.sia-chatbot-success {
    text-align: center;
    padding: 4px 2px;
}

.sia-chatbot-success-check {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background-color: rgba(76, 175, 80, 0.14);
    color: #2e7d32;
    font-size: 1.125rem;
    margin-bottom: 8px;
    animation: siaChatPop 380ms ease;
}

@keyframes siaChatPop {
    0% { transform: scale(0.4); opacity: 0; }
    70% { transform: scale(1.12); opacity: 1; }
    100% { transform: scale(1); }
}

.sia-chatbot-success-title {
    margin: 0 0 4px;
    font-weight: 700;
    color: var(--sia-chat-text);
}

.sia-chatbot-success-text {
    margin: 0;
    color: var(--sia-chat-muted);
    font-size: 0.8125rem;
    line-height: 1.55;
}

/* Loader (submitting state) */

.sia-chatbot-loader {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 2px solid rgba(18, 53, 36, 0.25);
    border-top-color: var(--sia-chat-primary);
    animation: siaChatSpin 700ms linear infinite;
    vertical-align: middle;
    margin-left: 4px;
}

@keyframes siaChatSpin {
    to { transform: rotate(360deg); }
}

/* --- Input bar --- */

.sia-chatbot-inputbar {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 14px;
    background-color: #fff;
    border-top: 1px solid var(--sia-chat-border);
}

.sia-chatbot-inputbar[hidden] {
    display: none;
}

.sia-chatbot-input {
    flex: 1;
    min-width: 0;
    border: 1px solid var(--sia-chat-border);
    border-radius: 22px;
    padding: 10px 16px;
    font-size: 0.875rem;
    font-family: inherit;
    color: var(--sia-chat-text);
    background-color: var(--sia-chat-surface);
    outline: none;
    transition: border-color 160ms ease, box-shadow 160ms ease;
}

.sia-chatbot-input::placeholder {
    color: #9a9a92;
}

.sia-chatbot-input:focus {
    border-color: var(--sia-chat-gold);
    box-shadow: 0 0 0 3px rgba(218, 189, 121, 0.18);
    background-color: #fff;
}

.sia-chatbot-send {
    flex: 0 0 auto;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: none;
    background-color: var(--sia-chat-primary);
    color: var(--sia-chat-gold);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.875rem;
    cursor: pointer;
    transition: background-color 160ms ease, transform 160ms ease;
}

.sia-chatbot-send:hover {
    background-color: var(--sia-chat-primary-dark);
    transform: translateY(-1px);
}

.sia-chatbot-send:focus-visible {
    outline: 2px solid var(--sia-chat-gold);
    outline-offset: 2px;
}

/* --- Scrollbar polish (webkit) --- */

.sia-chatbot-messages::-webkit-scrollbar {
    width: 6px;
}

.sia-chatbot-messages::-webkit-scrollbar-thumb {
    background-color: rgba(18, 53, 36, 0.2);
    border-radius: 999px;
}

/* --- Responsive --- */

@media (min-width: 576px) {
    .sia-chatbot-status {
        display: inline-flex;
    }
}

@media (max-width: 575px) {
    .sia-chatbot {
        right: 12px;
        bottom: 16px;
    }

    .sia-chatbot-launcher {
        width: 56px;
        height: 56px;
        font-size: 1.375rem;
    }

    .sia-chatbot-panel {
        right: 12px;
        bottom: 76px;
        width: calc(100vw - 24px);
        height: min(78vh, calc(100vh - 100px));
        max-height: calc(100vh - 100px);
        border-radius: 16px;
    }
}
