/**
 * SCAP Chatbot - Modern Conversational Interface
 *
 * Design Direction: "Clinical Intelligence"
 * Inspired by Claude's clean, spacious interface
 * - Flowing conversation, no bubble clutter
 * - Refined typography with Nunito + Open Sans
 * - Soft, trustworthy blue palette
 * - Maximum content breathing room
 */

/* ==========================================================================
   1. FONTS & CSS VARIABLES
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@400;600;700&family=Open+Sans:wght@400;500;600&display=swap');

:root {
    /* Primary - Soft healthcare blue */
    --scap-primary: #2563eb;
    --scap-primary-dark: #1d4ed8;
    --scap-primary-light: #3b82f6;
    --scap-primary-soft: #dbeafe;
    --scap-primary-subtle: rgba(37, 99, 235, 0.06);

    /* Neutral - Cool grays */
    --scap-text: #0f172a;
    --scap-text-secondary: #475569;
    --scap-text-muted: #94a3b8;
    --scap-text-light: #cbd5e1;
    --scap-bg: #ffffff;
    --scap-bg-subtle: #f8fafc;
    --scap-bg-hover: #f1f5f9;
    --scap-border: #e2e8f0;
    --scap-border-light: #f1f5f9;

    /* Semantic */
    --scap-success: #10b981;
    --scap-error: #ef4444;

    /* Typography */
    --scap-font: 'Open Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    --scap-font-display: 'Nunito', -apple-system, BlinkMacSystemFont, sans-serif;
    --scap-font-size-xs: 11px;
    --scap-font-size-sm: 13px;
    --scap-font-size-base: 15px;
    --scap-font-size-md: 16px;
    --scap-font-size-lg: 18px;
    --scap-font-size-xl: 22px;
    --scap-font-size-2xl: 28px;
    --scap-line-height: 1.6;
    --scap-line-height-tight: 1.3;

    /* Spacing */
    --scap-space-1: 4px;
    --scap-space-2: 8px;
    --scap-space-3: 12px;
    --scap-space-4: 16px;
    --scap-space-5: 20px;
    --scap-space-6: 24px;
    --scap-space-8: 32px;
    --scap-space-10: 40px;

    /* Radii */
    --scap-radius-sm: 8px;
    --scap-radius-md: 12px;
    --scap-radius-lg: 16px;
    --scap-radius-xl: 24px;
    --scap-radius-full: 9999px;

    /* Shadows */
    --scap-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --scap-shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
    --scap-shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.12);
    --scap-shadow-xl: 0 24px 48px rgba(0, 0, 0, 0.16);

    /* Z-index */
    --scap-z-widget: 999998;
    --scap-z-button: 999999;

    /* Transitions */
    --scap-ease: cubic-bezier(0.4, 0, 0.2, 1);
    --scap-ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
    --scap-duration-fast: 150ms;
    --scap-duration-base: 250ms;
    --scap-duration-slow: 400ms;
}

/* ==========================================================================
   2. BASE RESET
   ========================================================================== */

#scap-chatbot-wrapper {
    font-family: var(--scap-font);
    font-size: var(--scap-font-size-base);
    line-height: var(--scap-line-height);
    color: var(--scap-text);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    box-sizing: border-box;
}

#scap-chatbot-wrapper *,
#scap-chatbot-wrapper *::before,
#scap-chatbot-wrapper *::after {
    box-sizing: inherit;
}

#scap-chatbot-wrapper button {
    font-family: inherit;
    cursor: pointer;
    border: none;
    background: none;
    padding: 0;
}

#scap-chatbot-wrapper input {
    font-family: inherit;
}

/* ==========================================================================
   3. LAYOUT POSITIONING
   ========================================================================== */

#scap-chatbot-wrapper {
    position: fixed;
    z-index: var(--scap-z-button);
}

#scap-chatbot-wrapper.scap-position-bottom-right {
    bottom: 24px;
    right: 24px;
}

#scap-chatbot-wrapper.scap-position-bottom-left {
    bottom: 24px;
    left: 24px;
}

@media (min-width: 992px) {
    #scap-chatbot-wrapper.scap-position-bottom-right {
        bottom: 84px;
    }
}

/* ==========================================================================
   4. FLOATING TOGGLE BUTTON
   ========================================================================== */

.scap-chatbot-button {
    width: 60px;
    height: 60px;
    border-radius: var(--scap-radius-full);
    background: var(--scap-primary);
    box-shadow: var(--scap-shadow-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    transition:
        transform var(--scap-duration-base) var(--scap-ease-spring),
        box-shadow var(--scap-duration-base) var(--scap-ease),
        background-color var(--scap-duration-fast) var(--scap-ease);
}

.scap-chatbot-button:hover {
    transform: scale(1.08);
    box-shadow: var(--scap-shadow-xl);
    background: var(--scap-primary-dark);
}

.scap-chatbot-button:active {
    transform: scale(0.98);
}

.scap-chatbot-button svg {
    width: 26px;
    height: 26px;
    color: white;
    transition: transform var(--scap-duration-fast) var(--scap-ease);
}

.scap-notification-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    background: var(--scap-error);
    color: white;
    border-radius: var(--scap-radius-full);
    font-size: var(--scap-font-size-xs);
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--scap-bg);
}

/* ==========================================================================
   5. CHAT WINDOW - MAIN CONTAINER
   ========================================================================== */

.scap-chatbot-window {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: min(400px, calc(100vw - 48px));
    height: min(540px, calc(100vh - 100px));
    background: var(--scap-bg);
    border-radius: var(--scap-radius-xl);
    box-shadow: var(--scap-shadow-xl);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: var(--scap-z-widget);
    border: 1px solid var(--scap-border-light);

    /* Entry animation */
    transform: translateY(24px) scale(0.95);
    opacity: 0;
    transition:
        transform var(--scap-duration-slow) var(--scap-ease-spring),
        opacity var(--scap-duration-base) var(--scap-ease);
}

.scap-chatbot-window.scap-visible {
    transform: translateY(0) scale(1);
    opacity: 1;
}

.scap-chatbot-window.scap-fullscreen {
    top: 24px;
    left: 24px;
    right: 24px;
    bottom: 24px;
    width: auto;
    height: auto;
    max-width: 900px;
    margin: 0 auto;
}

/* ==========================================================================
   6. HEADER - MINIMAL TOP BAR
   ========================================================================== */

.scap-chatbot-header {
    padding: var(--scap-space-4) var(--scap-space-6);
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--scap-border-light);
    background: var(--scap-bg);
    flex-shrink: 0;
}

.scap-chatbot-info {
    display: flex;
    align-items: center;
    gap: var(--scap-space-3);
}

.scap-bot-icon {
    width: 32px;
    height: 32px;
    border-radius: var(--scap-radius-sm);
    background: var(--scap-primary-soft);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--scap-primary);
}

.scap-bot-icon svg {
    width: 18px;
    height: 18px;
}

.scap-chatbot-info h3 {
    margin: 0;
    font-size: var(--scap-font-size-md);
    font-weight: 600;
    color: var(--scap-text);
    letter-spacing: -0.01em;
}

.scap-header-divider {
    display: none;
}

.scap-status {
    font-size: var(--scap-font-size-xs);
    color: var(--scap-text-muted);
    display: flex;
    align-items: center;
    gap: 6px;
}

.scap-status-dot {
    width: 6px;
    height: 6px;
    border-radius: var(--scap-radius-full);
    background: var(--scap-success);
}

.scap-header-actions {
    display: flex;
    align-items: center;
    gap: var(--scap-space-1);
}

.scap-header-btn {
    width: 32px;
    height: 32px;
    border-radius: var(--scap-radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--scap-text-muted);
    transition:
        background-color var(--scap-duration-fast) var(--scap-ease),
        color var(--scap-duration-fast) var(--scap-ease);
}

.scap-header-btn:hover {
    background: var(--scap-bg-hover);
    color: var(--scap-text);
}

.scap-header-btn svg {
    width: 18px;
    height: 18px;
}

/* Phone link - prevent visited/active state issues */
a.scap-header-btn,
a.scap-header-btn:link,
a.scap-header-btn:visited,
a.scap-header-btn:active {
    color: var(--scap-text-muted);
    text-decoration: none;
}

a.scap-header-btn:hover {
    color: var(--scap-text);
}

/* ==========================================================================
   7. MESSAGES AREA - CONVERSATION FLOW
   ========================================================================== */

.scap-chatbot-messages {
    flex: 1;
    padding: var(--scap-space-4);
    padding-bottom: var(--scap-space-3);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: var(--scap-space-3);
    background: var(--scap-bg);
    scroll-behavior: smooth;
}

/* Scrollbar */
.scap-chatbot-messages::-webkit-scrollbar {
    width: 6px;
}

.scap-chatbot-messages::-webkit-scrollbar-track {
    background: transparent;
}

.scap-chatbot-messages::-webkit-scrollbar-thumb {
    background: var(--scap-border);
    border-radius: var(--scap-radius-full);
}

.scap-chatbot-messages::-webkit-scrollbar-thumb:hover {
    background: var(--scap-text-muted);
}

/* ==========================================================================
   8. WELCOME STATE
   ========================================================================== */

.scap-welcome {
    display: flex;
    flex-direction: column;
    gap: var(--scap-space-4);
    padding: var(--scap-space-4) 0;
    animation: scap-fade-up 0.4s var(--scap-ease) both;
}

.scap-welcome-hero {
    text-align: center;
    padding-bottom: var(--scap-space-2);
}

.scap-welcome-hero h2 {
    margin: 0;
    font-size: var(--scap-font-size-xl);
    font-weight: 600;
    color: var(--scap-text);
}

.scap-welcome-hero p {
    margin: var(--scap-space-3) 0 0;
    font-size: var(--scap-font-size-sm);
    color: var(--scap-text-muted);
}

/* No Referral Badge */
.scap-no-referral {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--scap-font-size-xs);
    font-weight: 600;
    color: var(--scap-success);
    letter-spacing: 0.05em;
}

/* Quick Action Buttons */
.scap-quick-actions {
    display: flex;
    gap: var(--scap-space-3);
}

.scap-action-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--scap-space-2);
    padding: var(--scap-space-3) var(--scap-space-4);
    background: var(--scap-bg);
    border: 1.5px solid var(--scap-border);
    border-radius: var(--scap-radius-md);
    text-decoration: none;
    color: var(--scap-text-secondary);
    font-size: var(--scap-font-size-sm);
    font-weight: 600;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
    transition: all var(--scap-duration-fast) var(--scap-ease);
}

.scap-action-btn svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.scap-action-btn:hover {
    border-color: var(--scap-primary);
    color: var(--scap-primary);
    background: var(--scap-primary-subtle);
    transform: translateY(-1px);
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.08);
}

.scap-action-btn:active {
    transform: translateY(0);
}

.scap-action-primary {
    background: linear-gradient(135deg, var(--scap-primary) 0%, var(--scap-primary-dark) 100%);
    border-color: var(--scap-primary);
    color: white;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.25);
}

.scap-action-primary:hover {
    background: linear-gradient(135deg, var(--scap-primary-light) 0%, var(--scap-primary) 100%);
    border-color: var(--scap-primary-light);
    color: white;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.35);
}

.scap-action-primary:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.25);
}

/* Quick Info Row */
.scap-quick-info {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--scap-space-2);
    font-size: var(--scap-font-size-xs);
    color: var(--scap-text-muted);
}

.scap-info-dot {
    width: 3px;
    height: 3px;
    background: var(--scap-text-muted);
    border-radius: 50%;
}

/* Chat Prompt Buttons */
.scap-chat-prompts {
    display: flex;
    flex-wrap: wrap;
    gap: var(--scap-space-2);
    justify-content: center;
}

.scap-prompt-btn {
    padding: 8px 14px;
    background: var(--scap-bg);
    border: 1.5px solid var(--scap-border);
    border-radius: 12px;
    color: var(--scap-text-secondary);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
}

.scap-prompt-btn:hover {
    border-color: var(--scap-primary);
    color: var(--scap-primary);
    background: var(--scap-primary-subtle);
}

.scap-prompt-btn:active {
    background: var(--scap-primary);
    border-color: var(--scap-primary);
    color: white;
}

/* Info Cards */
.scap-info-cards {
    display: flex;
    flex-direction: column;
    gap: var(--scap-space-2);
}

.scap-info-card {
    display: flex;
    align-items: center;
    gap: var(--scap-space-3);
    padding: var(--scap-space-3);
    background: var(--scap-bg-subtle);
    border-radius: var(--scap-radius-md);
    border: 1px solid var(--scap-border-light);
}

.scap-info-card-icon {
    width: 36px;
    height: 36px;
    border-radius: var(--scap-radius-sm);
    background: var(--scap-primary-soft);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: var(--scap-primary);
}

.scap-info-card-icon svg {
    width: 18px;
    height: 18px;
}

.scap-info-card-icon-success {
    background: rgba(16, 185, 129, 0.12);
    color: var(--scap-success);
}

.scap-info-card-content {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.scap-info-card-label {
    font-size: var(--scap-font-size-xs);
    font-weight: 500;
    color: var(--scap-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.scap-info-card-value {
    font-size: var(--scap-font-size-sm);
    font-weight: 600;
    color: var(--scap-text);
}

/* Location Selection Label */
.scap-location-select-label {
    font-size: 10px;
    font-weight: 600;
    color: var(--scap-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: var(--scap-space-1);
}

/* Locations - Selectable Cards */
.scap-locations-detailed {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--scap-space-2);
}

.scap-location-card {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 18px 24px;
    background: var(--scap-bg);
    border-radius: 12px;
    border: 1.5px solid var(--scap-border);
    cursor: pointer;
    position: relative;
    transition: all 0.2s ease;
    text-align: left;
}

.scap-location-card:hover:not(.selected) {
    border-color: var(--scap-primary-light);
    background: var(--scap-bg);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.1);
}

.scap-location-card.selected {
    border-color: var(--scap-primary);
    border-width: 2px;
    padding: 17.5px 23.5px; /* Compensate for thicker border */
    background: linear-gradient(135deg, rgba(37, 99, 235, 0.04) 0%, rgba(37, 99, 235, 0.08) 100%);
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15);
}

.scap-location-check {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 22px;
    height: 22px;
    background: var(--scap-primary);
    color: white;
    border-radius: 50%;
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
    box-shadow: 0 2px 6px rgba(37, 99, 235, 0.3);
}

/* Checkmark hidden - selection indicated by border/background */

.scap-location-header {
    display: flex;
    align-items: center;
    gap: var(--scap-space-2);
}

.scap-location-name {
    font-size: var(--scap-font-size-sm);
    font-weight: 600;
    color: var(--scap-text);
}

.scap-location-badge {
    font-size: 10px;
    font-weight: 600;
    padding: 2px 6px;
    background: var(--scap-primary-soft);
    color: var(--scap-primary);
    border-radius: var(--scap-radius-sm);
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.scap-location-address {
    font-size: var(--scap-font-size-xs);
    color: var(--scap-text-muted);
}

.scap-hours-list {
    display: flex;
    flex-direction: column;
    gap: 3px;
    margin-top: var(--scap-space-2);
    padding-top: var(--scap-space-2);
    border-top: 1px solid var(--scap-border-light);
}

.scap-hours-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 11px;
    color: var(--scap-text-muted);
    gap: 24px;
}

.scap-hours-row span:first-child {
    font-weight: 600;
    color: var(--scap-text);
    min-width: 32px;
    flex-shrink: 0;
}

.scap-hours-row span:last-child {
    text-align: right;
    font-variant-numeric: tabular-nums;
    min-width: 72px;
    padding-right: 6px;
}

.scap-hours-closed {
    opacity: 0.6;
}

.scap-hours-closed span:last-child {
    color: var(--scap-text-muted);
    font-style: italic;
}

/* Better contrast for closed on selected card */
.scap-location-card.selected .scap-hours-closed {
    opacity: 0.7;
}

.scap-location-card.selected .scap-hours-closed span:last-child {
    color: var(--scap-text-secondary);
}

/* ==========================================================================
   9. MESSAGE STYLES - CLEAN CONVERSATION
   ========================================================================== */

.scap-message {
    display: flex;
    flex-direction: column;
    animation: scap-fade-up 0.3s var(--scap-ease) both;
}

.scap-message.scap-user {
    align-items: flex-end;
}

.scap-message.scap-assistant {
    align-items: flex-start;
}

.scap-message-content {
    max-width: 85%;
    font-size: var(--scap-font-size-base);
    line-height: var(--scap-line-height);
    word-wrap: break-word;
}

/* User messages - Soft pill style */
.scap-message.scap-user .scap-message-content {
    background: var(--scap-primary);
    color: white;
    padding: var(--scap-space-3) var(--scap-space-5);
    border-radius: var(--scap-radius-lg);
    border-bottom-right-radius: var(--scap-space-1);
}

/* Assistant messages - Soft bubble style */
.scap-message.scap-assistant .scap-message-content {
    color: var(--scap-text);
    padding: var(--scap-space-3) var(--scap-space-4);
    background: #f1f5f9;
    border: 1px solid var(--scap-border-light);
    border-radius: var(--scap-radius-lg);
    border-bottom-left-radius: var(--scap-space-1);
}

/* Links */
.scap-message-content a {
    color: var(--scap-primary);
    text-decoration: none;
    font-weight: 500;
    transition: opacity var(--scap-duration-fast) var(--scap-ease);
}

.scap-message-content a:hover {
    opacity: 0.8;
}

/* Lists in messages */
.scap-message-content ul,
.scap-message-content ol {
    margin: var(--scap-space-2) 0;
    padding-left: var(--scap-space-5);
}

.scap-message-content li {
    margin-bottom: var(--scap-space-1);
}

/* ==========================================================================
   10. TYPING INDICATOR
   ========================================================================== */

.scap-typing-indicator {
    padding: var(--scap-space-4) var(--scap-space-6);
    display: flex;
    align-items: center;
    gap: var(--scap-space-3);
}

.scap-typing-dots {
    display: flex;
    gap: 4px;
}

.scap-typing-dots span {
    width: 6px;
    height: 6px;
    border-radius: var(--scap-radius-full);
    background: var(--scap-primary);
    opacity: 0.4;
    animation: scap-typing 1.2s ease-in-out infinite;
}

.scap-typing-dots span:nth-child(2) {
    animation-delay: 0.15s;
}

.scap-typing-dots span:nth-child(3) {
    animation-delay: 0.3s;
}

.scap-typing-text {
    color: var(--scap-text-muted);
    font-size: var(--scap-font-size-sm);
}

/* ==========================================================================
   11. INPUT AREA
   ========================================================================== */

.scap-chatbot-input-container {
    border-top: 1px solid var(--scap-border-light);
    background: var(--scap-bg);
    flex-shrink: 0;
    padding: var(--scap-space-4);
    display: flex;
    flex-direction: column;
    gap: var(--scap-space-3);
}

.scap-input-wrapper {
    display: flex;
    gap: var(--scap-space-3);
    align-items: center;
}

.scap-disclaimer {
    margin: 0;
    font-size: var(--scap-font-size-xs);
    color: var(--scap-text-muted);
    text-align: center;
}

.scap-chatbot-input {
    flex: 1;
    border: 1.5px solid var(--scap-border);
    border-radius: var(--scap-radius-full);
    padding: var(--scap-space-3) var(--scap-space-5);
    font-size: 16px;
    line-height: 1.4;
    color: var(--scap-text);
    background: var(--scap-bg);
    transition:
        border-color var(--scap-duration-fast) var(--scap-ease),
        box-shadow var(--scap-duration-fast) var(--scap-ease);
}

.scap-chatbot-input::placeholder {
    color: var(--scap-text-muted);
}

.scap-chatbot-input:hover {
    border-color: var(--scap-text-light);
}

.scap-chatbot-input:focus {
    outline: none;
    border-color: var(--scap-primary);
    box-shadow: 0 0 0 3px var(--scap-primary-subtle);
}

.scap-send-button {
    width: 44px;
    height: 44px;
    border-radius: var(--scap-radius-full);
    background: var(--scap-primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition:
        background-color var(--scap-duration-fast) var(--scap-ease),
        transform var(--scap-duration-base) var(--scap-ease-spring),
        opacity var(--scap-duration-fast) var(--scap-ease);
}

.scap-send-button:not(:disabled):hover {
    background: var(--scap-primary-dark);
    transform: scale(1.05);
}

.scap-send-button:not(:disabled):active {
    transform: scale(0.95);
}

.scap-send-button:disabled {
    background: var(--scap-border);
    cursor: not-allowed;
}

.scap-send-button svg {
    width: 20px;
    height: 20px;
}

/* Send Button sizing */
.scap-chat-input .scap-send-button {
    width: 40px;
    height: 40px;
}

/* ==========================================================================
   12. QUICK ACTIONS / TOOL OPTIONS
   ========================================================================== */

.scap-tool-options {
    display: flex;
    flex-wrap: wrap;
    gap: var(--scap-space-2);
    margin-top: var(--scap-space-3);
}

.scap-tool-question {
    font-weight: 600;
    color: var(--scap-text);
    margin-bottom: var(--scap-space-2);
}

.scap-option-btn {
    display: inline-flex;
    align-items: center;
    padding: var(--scap-space-2) var(--scap-space-4);
    background: linear-gradient(135deg, var(--scap-bg) 0%, var(--scap-bg-subtle) 100%);
    border: 1.5px solid var(--scap-border);
    border-radius: var(--scap-radius-full);
    color: var(--scap-text-secondary);
    font-size: var(--scap-font-size-sm);
    font-weight: 600;
    text-align: center;
    cursor: pointer;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    transition: all var(--scap-duration-fast) var(--scap-ease);
}

.scap-option-btn:hover {
    border-color: var(--scap-primary);
    background: var(--scap-primary-soft);
    color: var(--scap-primary);
    transform: translateY(-1px);
    box-shadow: 0 3px 10px rgba(37, 99, 235, 0.15);
}

.scap-option-btn:active {
    transform: translateY(0);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.scap-tool-free {
    margin-top: var(--scap-space-3);
}

.scap-tool-input {
    width: 100%;
    padding: var(--scap-space-3);
    border: 1.5px solid var(--scap-border);
    border-radius: var(--scap-radius-md);
    font-size: var(--scap-font-size-base);
    transition:
        border-color var(--scap-duration-fast) var(--scap-ease),
        box-shadow var(--scap-duration-fast) var(--scap-ease);
}

.scap-tool-input:focus {
    outline: none;
    border-color: var(--scap-primary);
    box-shadow: 0 0 0 3px var(--scap-primary-subtle);
}

/* Followup Question - Option bubbles (vertical stack) */
.scap-followup-options {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin: var(--scap-space-3) 0;
    align-items: flex-start;
}

.scap-followup-btn {
    display: inline-block;
    padding: 12px 24px;
    background: var(--scap-bg);
    border: 1.5px solid var(--scap-border);
    border-radius: var(--scap-radius-lg);
    color: var(--scap-text-secondary);
    font-size: var(--scap-font-size-base);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
    max-width: 85%;
}

.scap-followup-btn:hover:not(.selected):not(.not-selected) {
    border-color: var(--scap-primary);
    background: var(--scap-primary-subtle);
    color: var(--scap-primary);
}

/* Selected state - blue bubble */
.scap-followup-btn.selected {
    background: var(--scap-primary);
    border-color: var(--scap-primary);
    color: white;
    pointer-events: none;
}

/* Not-selected buttons fade out */
.scap-followup-btn.not-selected {
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s ease;
}

/* Disabled state - answered via free text */
.scap-followup-btn:disabled {
    pointer-events: none;
    cursor: default;
    opacity: 0.5;
}

/* Q: label for questions */
.scap-qa-label {
    font-weight: 700;
    color: var(--scap-primary);
    margin-right: 4px;
}

/* A: label for answers - dark blue on blue bubble (may need adjustment) */
.scap-answer-label {
    font-weight: 700;
    color: #1d4ed8;
    margin-right: 4px;
}

/* Number prefix in options */
.scap-option-num {
    font-weight: 700;
    color: var(--scap-primary);
    margin-right: 4px;
}

.scap-followup-btn.selected .scap-option-num {
    color: white;
}

/* Other option - custom input */
.scap-other-input-wrapper {
    display: flex;
    gap: 8px;
    width: 100%;
    max-width: 280px;
}

.scap-other-input {
    flex: 1;
    padding: 10px 14px;
    border: 1.5px solid var(--scap-border);
    border-radius: var(--scap-radius-lg);
    font-size: var(--scap-font-size-sm);
    font-family: inherit;
    outline: none;
    transition: border-color 0.15s ease;
}

.scap-other-input:focus {
    border-color: var(--scap-primary);
}

.scap-other-submit {
    padding: 10px 12px;
    background: var(--scap-primary);
    border: none;
    border-radius: var(--scap-radius-lg);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s ease;
}

.scap-other-submit:hover {
    background: var(--scap-primary-dark);
}

/* Question record - persisted after user answers */
.scap-question-record {
    font-size: var(--scap-font-size-xs);
    color: var(--scap-text-muted);
    padding: var(--scap-space-1) 0;
    font-style: italic;
}

/* Booking Wizard */
.scap-booking-wizard {
    background: var(--scap-bg);
    border: 1.5px solid var(--scap-border);
    border-radius: var(--scap-radius-md);
    overflow: visible;
    margin: var(--scap-space-1) auto 0;
    max-width: 100%;
    width: 100%;
    align-self: center;
    box-shadow: var(--scap-shadow-sm);
    animation: scap-fade-up 0.3s var(--scap-ease) both;
}

.scap-wizard-header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--scap-space-2);
    padding: var(--scap-space-2) var(--scap-space-3);
    background: var(--scap-primary);
    color: white;
    font-size: var(--scap-font-size-sm);
    font-weight: 600;
    border-radius: var(--scap-radius-md) var(--scap-radius-md) 0 0;
}

.scap-wizard-header svg {
    width: 16px;
    height: 16px;
}

.scap-booking-service {
    padding: var(--scap-space-1) var(--scap-space-3);
    background: var(--scap-primary-soft);
    font-size: var(--scap-font-size-xs);
    color: var(--scap-primary);
    font-weight: 600;
    text-align: center;
}

.scap-wizard-note {
    padding: var(--scap-space-2) var(--scap-space-3);
    background: var(--scap-primary-soft);
    font-size: var(--scap-font-size-xs);
    color: var(--scap-primary);
    font-weight: 600;
    text-align: center;
}

.scap-wizard-questions {
    display: flex;
    flex-direction: column;
    gap: var(--scap-space-2);
    padding: var(--scap-space-2) var(--scap-space-3);
}

.scap-wizard-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--scap-space-3);
}

.scap-wizard-q label {
    display: block;
    font-size: 10px;
    font-weight: 600;
    color: var(--scap-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: var(--scap-space-1);
}

.scap-wizard-options {
    display: flex;
    flex-direction: column;
    gap: var(--scap-space-1);
}

.scap-wizard-options.horizontal {
    flex-direction: row;
    flex-wrap: wrap;
    gap: var(--scap-space-2);
}

.scap-wizard-options.horizontal .scap-wizard-opt {
    flex: 1 1 auto;
    min-width: calc(50% - var(--scap-space-1));
    text-align: center;
    justify-content: center;
}

.scap-wizard-opt {
    padding: 6px 10px;
    background-color: var(--scap-bg);
    border: 1px solid var(--scap-border);
    border-radius: var(--scap-radius-sm);
    font-size: 12px;
    font-weight: 500;
    color: var(--scap-text-secondary);
    cursor: pointer;
    transition: all 0.15s ease;
    text-align: center;
}

.scap-wizard-opt:hover:not(.selected) {
    border-color: var(--scap-primary);
    background-color: var(--scap-primary-subtle);
    color: var(--scap-primary);
}

/* Selected state - force blue background */
.scap-wizard-opt.selected,
button.scap-wizard-opt.selected {
    background: #2563eb !important;
    background-color: #2563eb !important;
    border-color: #2563eb !important;
    color: #fff !important;
}

.scap-wizard-opt.selected:hover,
button.scap-wizard-opt.selected:hover {
    background: #1d4ed8 !important;
    background-color: #1d4ed8 !important;
    border-color: #1d4ed8 !important;
    color: #fff !important;
}

/* Unavailable treatment buttons (location-based restrictions) */
.scap-wizard-opt.unavailable,
button.scap-wizard-opt.unavailable,
.scap-wizard-opt:disabled,
button.scap-wizard-opt:disabled {
    background: #f3f4f6 !important;
    background-color: #f3f4f6 !important;
    border-color: #e5e7eb !important;
    color: #9ca3af !important;
    cursor: not-allowed !important;
    opacity: 0.6;
}

.scap-wizard-opt.unavailable:hover,
button.scap-wizard-opt.unavailable:hover,
.scap-wizard-opt:disabled:hover,
button.scap-wizard-opt:disabled:hover {
    background: #f3f4f6 !important;
    background-color: #f3f4f6 !important;
    border-color: #e5e7eb !important;
    color: #9ca3af !important;
}

/* Practitioner dropdown */
.scap-practitioner-dropdown {
    margin-top: var(--scap-space-1);
}

.scap-practitioner-select {
    width: 100%;
    padding: var(--scap-space-2);
    font-size: var(--scap-font-size-xs);
    font-family: inherit;
    border: 1.5px solid var(--scap-border);
    border-radius: var(--scap-radius-sm);
    background: var(--scap-bg);
    color: var(--scap-text);
    cursor: pointer;
    transition: border-color var(--scap-duration-fast) var(--scap-ease);
}

.scap-practitioner-select:focus {
    outline: none;
    border-color: var(--scap-primary);
}

.scap-wizard-actions {
    padding: var(--scap-space-2) var(--scap-space-3);
    border-top: 1px solid var(--scap-border-light);
}

.scap-wizard-book,
button.scap-wizard-book {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--scap-space-2);
    width: 100%;
    padding: 12px 16px;
    background: #2563eb !important;
    background-color: #2563eb !important;
    border: none !important;
    border-radius: var(--scap-radius-sm);
    color: #fff !important;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
}

.scap-wizard-book svg {
    width: 14px;
    height: 14px;
}

.scap-wizard-book:disabled,
button.scap-wizard-book:disabled {
    background: #cbd5e1 !important;
    background-color: #cbd5e1 !important;
    color: #94a3b8 !important;
    cursor: not-allowed;
}

.scap-wizard-book:not(:disabled):hover {
    background: #1d4ed8 !important;
    background-color: #1d4ed8 !important;
}

/* Clinician dropdown */
.scap-clinician-select-wrap {
    margin-top: 4px;
}

.scap-clinician-select {
    width: 100%;
    padding: 8px 12px;
    font-size: 12px;
    font-family: inherit;
    border: 1.5px solid var(--scap-border);
    border-radius: var(--scap-radius-sm);
    background: var(--scap-bg);
    color: var(--scap-text);
    cursor: pointer;
}

.scap-clinician-select:focus {
    outline: none;
    border-color: #2563eb;
}

.scap-clinician-select option:disabled {
    color: #9ca3af;
    background-color: #f3f4f6;
}

.scap-wizard-done .scap-wizard-header {
    background: var(--scap-success);
    border-radius: var(--scap-radius-lg);
}

/* ==========================================================================
   13. ERROR STATE
   ========================================================================== */

.scap-error-message {
    position: absolute;
    bottom: 100px;
    left: var(--scap-space-4);
    right: var(--scap-space-4);
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: var(--scap-radius-md);
    padding: var(--scap-space-4);
    animation: scap-fade-up 0.3s var(--scap-ease);
}

.scap-error-message p {
    margin: 0 0 var(--scap-space-3);
    color: #dc2626;
    font-size: var(--scap-font-size-sm);
    font-weight: 500;
}

.scap-retry-button {
    background: #dc2626;
    color: white;
    padding: var(--scap-space-2) var(--scap-space-4);
    border-radius: var(--scap-radius-sm);
    font-size: var(--scap-font-size-sm);
    font-weight: 500;
    transition: background-color var(--scap-duration-fast) var(--scap-ease);
}

.scap-retry-button:hover {
    background: #b91c1c;
}

/* ==========================================================================
   14. ANIMATIONS
   ========================================================================== */

@keyframes scap-fade-up {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

/* ==========================================================================
   15. ACCESSIBILITY
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
    /*
     * Scoped to the widget. This used to be a bare universal selector, so simply
     * activating the plugin stripped the animations and transitions from every
     * element on the client's website for any visitor with reduced motion turned
     * on - a plugin has no business restyling the site it is installed into.
     */
    #scap-chatbot-wrapper,
    #scap-chatbot-wrapper *,
    #scap-chatbot-wrapper *::before,
    #scap-chatbot-wrapper *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

@media (prefers-contrast: high) {
    .scap-chatbot-input,
    .scap-option-btn,
    .scap-tool-input {
        border-width: 2px;
    }
}

/* Focus visible */
.scap-chatbot-button:focus-visible,
.scap-header-btn:focus-visible,
.scap-send-button:focus-visible,
.scap-option-btn:focus-visible,
.scap-chatbot-input:focus-visible,
.scap-followup-btn:focus-visible,
.scap-wizard-opt:focus-visible,
.scap-wizard-book:focus-visible {
    outline: 2px solid var(--scap-primary);
    outline-offset: 2px;
}

/* ==========================================================================
   16. RESPONSIVE
   ========================================================================== */

/* Mobile */
@media (max-width: 480px) {
    #scap-chatbot-wrapper.scap-position-bottom-right,
    #scap-chatbot-wrapper.scap-position-bottom-left {
        bottom: 16px;
        right: 16px;
        left: auto;
    }

    .scap-chatbot-button {
        width: 54px;
        height: 54px;
    }

    .scap-chatbot-button svg {
        width: 24px;
        height: 24px;
    }

    .scap-chatbot-window {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        height: 100%;
        border-radius: 0;
        transform: translateY(100%);
    }

    .scap-chatbot-window.scap-visible {
        transform: translateY(0);
    }

    .scap-chatbot-header {
        padding: var(--scap-space-4) var(--scap-space-5);
    }

    .scap-chatbot-messages {
        padding: var(--scap-space-5);
    }

    .scap-input-wrapper {
        padding: var(--scap-space-4) var(--scap-space-5);
    }

    /* Booking wizard: stack columns on mobile */
    .scap-wizard-row {
        grid-template-columns: 1fr;
        gap: var(--scap-space-2);
    }

    .scap-input-footer {
        padding: 0 var(--scap-space-5) var(--scap-space-3);
    }

    .scap-welcome {
        padding: var(--scap-space-6) var(--scap-space-4);
    }

    .scap-message-content {
        max-width: 90%;
    }
}

/* Tablet */
@media (min-width: 481px) and (max-width: 768px) {
    .scap-chatbot-window {
        width: min(420px, calc(100vw - 48px));
        height: min(600px, calc(100vh - 100px));
    }
}

/* Desktop */
@media (min-width: 769px) {
    .scap-chatbot-window {
        width: 440px;
        /* Clamped like every other breakpoint. A flat 680px overflowed short
           desktop viewports (a 1366x768 laptop, or any shortened window), pushing
           the input box off screen with no way to reach it. */
        height: min(680px, calc(100vh - 100px));
    }
}

/* Large screens - fullscreen mode */
@media (min-width: 1200px) {
    .scap-chatbot-window.scap-fullscreen {
        top: 48px;
        left: 50%;
        transform: translateX(-50%);
        right: auto;
        bottom: 48px;
        width: 100%;
        max-width: 800px;
    }

    .scap-chatbot-window.scap-fullscreen.scap-visible {
        transform: translateX(-50%);
    }
}

/* Policy link inside the disclaimer line */
.scap-disclaimer a {
    color: inherit;
    text-decoration: underline;
}
