/* AI Water Booking Agent — Public CSS v2.2
 * Design language extracted from water-filtration-booking-flow.jsx
 * Font: DM Sans | Accent: Teal #0d9488 | Bubbles: asymmetric radius
 */

@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,500;0,9..40,700;0,9..40,800;1,9..40,400&display=swap');

/* ── CSS Variables ─────────────────────────────────────────────────── */
.aiwb-agent-wrap {
    --bg:            #f8fafb;
    --card-bg:       #ffffff;
    --heading-color: #0f172a;
    --text-color:    #334155;
    --text-muted:    #94a3b8;
    --border-color:  #e2e8f0;
    --accent-color:  #0d9488;
    --accent-light:  #ccfbf1;
    --system-bubble: #f0fdfa;
    --system-text:   #134e4a;
    --user-bubble:   #0d9488;
    --user-text:     #ffffff;
    --option-bg:     #f0fdfa;
    --shadow-color:  rgba(0, 0, 0, 0.04);
    --shadow-md:     0 4px 24px rgba(0, 0, 0, 0.08);
}

/* ── Animations ────────────────────────────────────────────────────── */
@keyframes aiwbFadeSlideIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes aiwbTypingBounce {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
    40%           { transform: scale(1);   opacity: 1; }
}

/* ── Wrapper ───────────────────────────────────────────────────────── */
.aiwb-agent-wrap {
    max-width: 680px;
    margin: 0 auto 40px;
    border-radius: 16px;
    box-shadow: var(--shadow-md);
    background: var(--card-bg);
    overflow: hidden;
    font-family: 'DM Sans', 'Helvetica Neue', system-ui, sans-serif;
    font-size: 14px;
    color: var(--text-color);
    border: 1px solid var(--border-color);
    box-sizing: border-box;
}

.aiwb-agent-wrap *,
.aiwb-agent-wrap *::before,
.aiwb-agent-wrap *::after {
    box-sizing: border-box;
    margin: 0;
}

/* ── Header ────────────────────────────────────────────────────────── */
.aiwb-agent-header {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px 20px;
    background: var(--accent-color);
    color: #fff;
}

.aiwb-agent-avatar {
    position: relative;
    flex-shrink: 0;
}

.aiwb-avatar-img {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(255, 255, 255, 0.5);
    display: block;
}

.aiwb-avatar-icon.aiwb-avatar-initials {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    font-size: 20px;
    font-weight: 800;
    color: #fff;
    border: 2px solid rgba(255, 255, 255, 0.4);
}

.aiwb-online-dot {
    position: absolute;
    bottom: 1px;
    right: 1px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #4ade80;
    border: 2px solid var(--accent-color);
}

.aiwb-agent-info {
    flex: 1;
    min-width: 0;
}

.aiwb-agent-name {
    font-size: 15px;
    font-weight: 800;
    color: #fff;
    letter-spacing: 0.01em;
}

.aiwb-agent-title {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.8);
    margin-top: 2px;
}

/* ── Chat Window ───────────────────────────────────────────────────── */
.aiwb-chat-window {
    height: 380px;
    overflow-y: auto;
    padding: 16px 16px 8px;
    background: var(--bg);
    display: flex;
    flex-direction: column;
    gap: 0;
    scroll-behavior: smooth;
}

.aiwb-chat-window::-webkit-scrollbar { width: 5px; }
.aiwb-chat-window::-webkit-scrollbar-track { background: transparent; }
.aiwb-chat-window::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 10px; }

/* ── Message rows ──────────────────────────────────────────────────── */
.aiwb-msg {
    display: flex;
    margin-bottom: 8px;
    animation: aiwbFadeSlideIn 0.35s ease forwards;
}

.aiwb-msg-bot  { justify-content: flex-start; }
.aiwb-msg-user { justify-content: flex-end; }

/* ── Message avatars ───────────────────────────────────────────────── */
.aiwb-msg-avatar {
    flex-shrink: 0;
    margin-right: 8px;
    align-self: flex-end;
}

.aiwb-msg-user .aiwb-msg-avatar {
    margin-right: 0;
    margin-left: 8px;
    order: 2;
}

.aiwb-msg-avatar-img {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: cover;
    border: 1px solid var(--border-color);
    display: block;
}

.aiwb-avatar-letter {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--accent-color);
    color: #fff;
    font-size: 11px;
    font-weight: 800;
    line-height: 1;
}

.aiwb-msg-user .aiwb-avatar-letter {
    background: var(--border-color);
    color: var(--text-muted);
    font-size: 9px;
    font-weight: 700;
}

/* ── Chat bubbles ──────────────────────────────────────────────────── */
/* Bot bubble: flat top-left corner (coming from left) */
.aiwb-msg-bubble {
    max-width: 78%;
    padding: 10px 14px;
    font-size: 14px;
    line-height: 1.55;
    white-space: pre-line;
    word-break: break-word;
}

.aiwb-msg-bot .aiwb-msg-bubble {
    border-radius: 4px 16px 16px 16px;
    background: var(--system-bubble);
    color: var(--system-text);
    box-shadow: 0 1px 3px var(--shadow-color);
    border: 1px solid #ccfbf1;
}

/* User bubble: flat top-right corner (coming from right) */
.aiwb-msg-user .aiwb-msg-bubble {
    border-radius: 16px 4px 16px 16px;
    background: var(--user-bubble);
    color: var(--user-text);
    box-shadow: 0 1px 3px rgba(13, 148, 136, 0.2);
}

/* ── Typing indicator ──────────────────────────────────────────────── */
#aiwb-typing .aiwb-typing-bubble {
    display: flex;
    gap: 4px;
    align-items: center;
    padding: 12px 16px;
    border-radius: 4px 16px 16px 16px;
    background: var(--system-bubble);
    border: 1px solid #ccfbf1;
    box-shadow: 0 1px 3px var(--shadow-color);
}

#aiwb-typing .aiwb-typing-bubble span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--accent-color);
    animation: aiwbTypingBounce 1s infinite ease-in-out;
    display: block;
}

#aiwb-typing .aiwb-typing-bubble span:nth-child(2) { animation-delay: 0.15s; }
#aiwb-typing .aiwb-typing-bubble span:nth-child(3) { animation-delay: 0.30s; }

/* ── Input area ────────────────────────────────────────────────────── */
.aiwb-input-area {
    padding: 12px 16px 14px;
    background: var(--card-bg);
    border-top: 1px solid var(--border-color);
    position: relative;
    min-height: 58px;
}

/* ── Quick reply chips ─────────────────────────────────────────────── */
.aiwb-quick-replies {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 2px 0;
}

.aiwb-chip {
    padding: 10px 16px;
    border-radius: 12px;
    border: 1.5px solid var(--accent-color);
    background: var(--option-bg);
    color: var(--accent-color);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
    font-family: inherit;
    line-height: 1.4;
}

.aiwb-chip:hover {
    background: var(--accent-color);
    color: #fff;
}

/* Multi-select chip (symptoms) */
.aiwb-chip-multi {
    display: inline-block;
    padding: 8px 14px;
    border-radius: 22px;
    font-size: 13px;
    text-align: center;
}

.aiwb-chip-multi.aiwb-chip-selected {
    background: var(--accent-color);
    color: #fff;
    border-color: var(--accent-color);
}

/* When showing multi-select, lay them out in a wrap row */
.aiwb-quick-replies:has(.aiwb-chip-multi) {
    flex-direction: row;
    flex-wrap: wrap;
}

/* Confirm button for multi-select */
.aiwb-chip-confirm {
    display: block;
    width: 100%;
    padding: 10px 20px;
    border-radius: 12px;
    border: none;
    background: var(--accent-color);
    color: #fff;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    margin-top: 6px;
    transition: background 0.2s;
    font-family: inherit;
}

.aiwb-chip-confirm:hover {
    background: #0f766e;
}

/* ── Text input row ────────────────────────────────────────────────── */
.aiwb-text-input-row {
    display: flex;
    gap: 8px;
    align-items: center;
}

.aiwb-text-input-row input[type="text"] {
    flex: 1;
    padding: 10px 14px;
    border: 1.5px solid var(--border-color);
    border-radius: 12px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
    background: var(--bg);
    color: var(--heading-color);
    font-family: inherit;
}

.aiwb-text-input-row input[type="text"]:focus {
    border-color: var(--accent-color);
    background: #fff;
}

.aiwb-text-input-row input[type="text"]::placeholder {
    color: var(--text-muted);
}

#aiwb-send-btn {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: var(--accent-color);
    border: none;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, transform 0.1s;
    flex-shrink: 0;
}

#aiwb-send-btn:hover {
    background: #0f766e;
    transform: scale(1.05);
}

#aiwb-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* ── Address / Location field ──────────────────────────────────────── */
.aiwb-location-field {
    display: flex;
    gap: 8px;
    align-items: center;
}

.aiwb-location-input {
    flex: 1;
    padding: 10px 14px;
    border: 1.5px solid var(--border-color);
    border-radius: 12px;
    font-size: 14px;
    outline: none;
    background: var(--bg);
    color: var(--heading-color);
    transition: border-color 0.2s;
    font-family: inherit;
}

.aiwb-location-input:focus {
    border-color: var(--accent-color);
    background: #fff;
}

.aiwb-location-input::placeholder {
    color: var(--text-muted);
}

.aiwb-location-confirm {
    padding: 10px 18px;
    background: var(--accent-color);
    color: #fff;
    border: none;
    border-radius: 12px;
    font-size: 13.5px;
    font-weight: 700;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.2s;
    font-family: inherit;
}

.aiwb-location-confirm:hover {
    background: #0f766e;
}

/* ── Date field ────────────────────────────────────────────────────── */
.aiwb-date-field {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.aiwb-date-label {
    font-size: 13px;
    color: var(--text-muted);
    font-weight: 600;
    white-space: nowrap;
}

.aiwb-date-input {
    padding: 9px 12px;
    border: 1.5px solid var(--border-color);
    border-radius: 12px;
    font-size: 14px;
    outline: none;
    background: var(--bg);
    color: var(--heading-color);
    transition: border-color 0.2s;
    font-family: inherit;
}

.aiwb-date-input:focus {
    border-color: var(--accent-color);
    background: #fff;
}

.aiwb-date-confirm {
    padding: 9px 18px;
    background: var(--accent-color);
    color: #fff;
    border: none;
    border-radius: 12px;
    font-size: 13.5px;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.2s;
    font-family: inherit;
}

.aiwb-date-confirm:hover {
    background: #0f766e;
}

/* ── Confirm panel ─────────────────────────────────────────────────── */
.aiwb-confirm-panel {
    padding: 20px 20px 16px;
    background: var(--card-bg);
    border-top: 1px solid var(--border-color);
}

.aiwb-confirm-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 14px;
}

.aiwb-confirm-icon {
    font-size: 20px;
    color: var(--accent-color);
}

.aiwb-confirm-header h3 {
    font-size: 16px;
    font-weight: 800;
    color: var(--heading-color);
}

.aiwb-confirm-body {
    background: var(--bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 14px 16px;
    margin-bottom: 14px;
    font-size: 13.5px;
    line-height: 1.6;
}

/* ── Summary sections ──────────────────────────────────────────────── */
.aiwb-summary-section {
    margin-bottom: 14px;
}

.aiwb-summary-section:last-of-type {
    margin-bottom: 0;
}

.aiwb-summary-title {
    font-size: 10px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    margin-bottom: 6px;
    padding-bottom: 4px;
    border-bottom: 1px solid var(--border-color);
}

.aiwb-summary-row {
    display: flex;
    gap: 8px;
    margin-bottom: 4px;
    font-size: 13px;
    line-height: 1.5;
}

.aiwb-summary-label {
    font-weight: 700;
    color: var(--text-muted);
    min-width: 110px;
    font-size: 12px;
    flex-shrink: 0;
}

.aiwb-summary-value {
    color: var(--heading-color);
    font-size: 13px;
}

/* ── Specialist note ───────────────────────────────────────────────── */
.aiwb-specialist-note {
    margin-top: 12px;
    padding: 10px 14px;
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: 10px;
    font-size: 13px;
    color: #1e40af;
    line-height: 1.55;
}

/* ── Trust nudge ───────────────────────────────────────────────────── */
.aiwb-trust-nudge {
    margin-top: 8px;
    padding: 8px 12px;
    background: var(--accent-light);
    border: 1px solid #99f6e4;
    border-radius: 10px;
    font-size: 12.5px;
    color: #134e4a;
    font-style: italic;
    line-height: 1.5;
}

/* ── Ownership warning ─────────────────────────────────────────────── */
.aiwb-ownership-warning {
    margin-top: 8px;
    padding: 8px 12px;
    background: #fef3c7;
    border: 1px solid #fcd34d;
    border-radius: 10px;
    font-size: 12.5px;
    color: #92400e;
    line-height: 1.5;
}

/* ── Confirm actions ───────────────────────────────────────────────── */
.aiwb-confirm-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.aiwb-btn-edit {
    padding: 10px 20px;
    border: 1.5px solid var(--border-color);
    background: transparent;
    border-radius: 12px;
    font-size: 14px;
    cursor: pointer;
    color: var(--text-muted);
    transition: all 0.2s;
    font-family: inherit;
    font-weight: 600;
}

.aiwb-btn-edit:hover {
    border-color: var(--accent-color);
    color: var(--accent-color);
}

.aiwb-btn-confirm {
    padding: 10px 24px;
    background: var(--accent-color);
    color: #fff;
    border: none;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
    font-family: inherit;
}

.aiwb-btn-confirm:hover {
    background: #0f766e;
    transform: translateY(-1px);
}

.aiwb-btn-confirm:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* ── Success panel ─────────────────────────────────────────────────── */
.aiwb-success-panel {
    padding: 44px 24px 36px;
    text-align: center;
    background: var(--card-bg);
}

.aiwb-success-icon {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--accent-color);
    color: #fff;
    font-size: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
    box-shadow: 0 4px 20px rgba(13, 148, 136, 0.3);
}

.aiwb-success-panel h2 {
    font-size: 22px;
    font-weight: 800;
    color: var(--heading-color);
    margin: 0 0 10px;
}

.aiwb-success-panel p {
    color: var(--text-color);
    font-size: 14px;
    margin: 0 0 14px;
    line-height: 1.6;
}

.aiwb-ref-badge {
    display: inline-block;
    padding: 6px 18px;
    background: var(--accent-light);
    border: 1.5px solid #99f6e4;
    border-radius: 22px;
    font-size: 13px;
    font-weight: 800;
    color: var(--accent-color);
    margin-bottom: 18px;
    letter-spacing: 0.03em;
}

.aiwb-success-trust {
    font-size: 13px;
    color: var(--text-muted);
    font-style: italic;
    margin-bottom: 20px;
    line-height: 1.6;
}

.aiwb-btn-new {
    padding: 11px 28px;
    background: var(--accent-color);
    color: #fff;
    border: none;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.2s;
    font-family: inherit;
}

.aiwb-btn-new:hover {
    background: #0f766e;
}

/* ── Responsive ────────────────────────────────────────────────────── */
@media (max-width: 600px) {
    .aiwb-agent-wrap {
        border-radius: 0;
        margin: 0 0 24px;
    }
    .aiwb-chat-window {
        height: 300px;
    }
    .aiwb-chip {
        font-size: 13px;
        padding: 9px 14px;
    }
    .aiwb-summary-label {
        min-width: 90px;
    }
    .aiwb-confirm-actions {
        flex-direction: column;
    }
    .aiwb-btn-edit,
    .aiwb-btn-confirm {
        width: 100%;
        text-align: center;
    }
}
