/* ==========================================================================
   CareSource In-App Chatbot Widget Styles
   ========================================================================== */

:root {
    --cb-primary: #24578c;
    --cb-primary-dark: #134e8b;
    --cb-primary-gradient: linear-gradient(135deg, #24578c 0%, #134e8b 100%);
    --cb-secondary-gradient: linear-gradient(135deg, #1b3a5c 0%, #10263f 100%);
    --cb-bg-light: #f8fafc;
    --cb-user-bubble: linear-gradient(135deg, #24578c 0%, #184b7d 100%);
    --cb-bot-bubble: #ffffff;
    --cb-border: #e2e8f0;
    --cb-text-dark: #1e293b;
    --cb-text-muted: #64748b;
    --cb-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.15), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
    --cb-glow: 0 0 15px rgba(36, 87, 140, 0.4);
}

/* Floating Action Button */
.cs-chatbot-launcher {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--cb-primary-gradient);
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--cb-shadow), var(--cb-glow);
    cursor: pointer;
    z-index: 99998;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    border: none;
    outline: none;
}

.cs-chatbot-launcher:hover {
    transform: scale(1.08);
    box-shadow: 0 12px 28px rgba(36, 87, 140, 0.45);
}

.cs-chatbot-launcher:active {
    transform: scale(0.95);
}

.cs-chatbot-launcher .cs-icon-chat,
.cs-chatbot-launcher .cs-icon-close {
    font-size: 24px;
    transition: transform 0.3s ease, opacity 0.3s ease;
}

.cs-chatbot-launcher .cs-icon-close {
    display: none;
}

.cs-chatbot-launcher.active .cs-icon-chat {
    display: none;
}

.cs-chatbot-launcher.active .cs-icon-close {
    display: block;
    transform: rotate(90deg);
}

/* Notification / Pulse Badge */
.cs-chatbot-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    width: 14px;
    height: 14px;
    background-color: #f87171;
    border: 2px solid #ffffff;
    border-radius: 50%;
    animation: cs-pulse 2s infinite;
}

@keyframes cs-pulse {
    0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(248, 113, 113, 0.7); }
    70% { transform: scale(1.15); box-shadow: 0 0 0 8px rgba(248, 113, 113, 0); }
    100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(248, 113, 113, 0); }
}

/* Chatbot Main Window */
.cs-chatbot-window {
    position: fixed;
    bottom: 96px;
    right: 24px;
    width: 440px;
    max-width: calc(100vw - 32px);
    height: 620px;
    max-height: calc(100vh - 110px);
    background-color: var(--cb-bg-light);
    border-radius: 18px;
    box-shadow: var(--cb-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 99999;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px) scale(0.96);
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    border: 1px solid rgba(226, 232, 240, 0.8);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

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

/* Header */
.cs-chatbot-header {
    background: var(--cb-secondary-gradient);
    color: #ffffff;
    padding: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-top-left-radius: 16px;
    border-top-right-radius: 16px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.cs-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.cs-bot-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--cb-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    font-size: 18px;
    position: relative;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.cs-bot-avatar::after {
    content: '';
    position: absolute;
    bottom: 0;
    right: 0;
    width: 10px;
    height: 10px;
    background-color: #10b981;
    border: 2px solid #2f4050;
    border-radius: 50%;
}

.cs-header-title {
    font-size: 15px;
    font-weight: 700;
    margin: 0;
    line-height: 1.2;
    color: #ffffff;
}

.cs-header-status {
    font-size: 11px;
    color: #94a3b8;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 4px;
}

.cs-header-actions {
    display: flex;
    gap: 6px;
}

.cs-header-btn {
    background: transparent;
    border: none;
    color: #cbd5e1;
    cursor: pointer;
    font-size: 14px;
    padding: 6px;
    border-radius: 6px;
    transition: background 0.2s, color 0.2s;
}

.cs-header-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    color: #ffffff;
}

/* Chat Body / Messages Thread */
.cs-chatbot-body {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 14px;
    scroll-behavior: smooth;
}

.cs-chatbot-body::-webkit-scrollbar {
    width: 5px;
}

.cs-chatbot-body::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

/* Message Bubbles */
.cs-message {
    display: flex;
    flex-direction: column;
    max-width: 88%;
    animation: cs-fade-in 0.25s ease forwards;
}

@keyframes cs-fade-in {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.cs-message.bot {
    align-self: flex-start;
}

.cs-message.user {
    align-self: flex-end;
}

.cs-bubble {
    padding: 12px 16px;
    border-radius: 14px;
    font-size: 14px;
    line-height: 1.55;
    word-break: break-word;
}

.cs-message.bot .cs-bubble {
    background-color: var(--cb-bot-bubble);
    color: var(--cb-text-dark);
    border: 1px solid var(--cb-border);
    border-top-left-radius: 4px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.04);
}

.cs-message.user .cs-bubble {
    background: var(--cb-user-bubble);
    color: #ffffff;
    border-top-right-radius: 4px;
    box-shadow: 0 2px 5px rgba(36, 87, 140, 0.2);
}

.cs-msg-time {
    font-size: 10px;
    color: var(--cb-text-muted);
    margin-top: 4px;
}

.cs-message.user .cs-msg-time {
    align-self: flex-end;
}

.cs-message.bot .cs-msg-time {
    align-self: flex-start;
}

/* Navigation Guide Card */
.cs-guide-card {
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 10px 12px;
    margin-top: 8px;
}

.cs-guide-step {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin-bottom: 8px;
    font-size: 12.5px;
}

.cs-guide-step:last-child {
    margin-bottom: 0;
}

.cs-step-badge {
    background: var(--cb-primary);
    color: #ffffff;
    font-weight: bold;
    font-size: 10.5px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-top: 2px;
}

/* Action Button Inside Bubble */
.cs-action-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 10px;
    background: var(--cb-primary);
    color: #ffffff !important;
    text-decoration: none !important;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    transition: background 0.2s, transform 0.1s;
}

.cs-action-btn:hover {
    background: var(--cb-primary-dark);
    transform: translateY(-1px);
}

/* Escalation Card */
.cs-escalation-card {
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: 8px;
    padding: 10px;
    margin-top: 6px;
    font-size: 12px;
    color: #1e40af;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Quick Reply Chips */
.cs-quick-replies {
    padding: 6px 14px;
    background: var(--cb-bg-light);
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    max-height: 110px;
    overflow-y: auto;
    border-top: 1px solid #f1f5f9;
}

.cs-chip {
    background: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: 16px;
    padding: 5px 11px;
    font-size: 11.5px;
    font-weight: 500;
    color: #334155;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    user-select: none;
}

.cs-chip:hover {
    background: var(--cb-primary);
    border-color: var(--cb-primary);
    color: #ffffff;
    transform: translateY(-1px);
}

.cs-chip i {
    font-size: 11px;
}

/* Typing Indicator */
.cs-typing {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 10px 14px;
    background: #ffffff;
    border: 1px solid var(--cb-border);
    border-radius: 14px;
    border-top-left-radius: 4px;
    width: fit-content;
}

.cs-typing-dot {
    width: 6px;
    height: 6px;
    background-color: var(--cb-text-muted);
    border-radius: 50%;
    animation: cs-bounce 1.4s infinite ease-in-out both;
}

.cs-typing-dot:nth-child(1) { animation-delay: -0.32s; }
.cs-typing-dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes cs-bounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

/* Input Footer */
.cs-chatbot-footer {
    padding: 10px 14px;
    background: #ffffff;
    border-top: 1px solid var(--cb-border);
    display: flex;
    align-items: center;
    gap: 8px;
}

.cs-input-field {
    flex: 1;
    border: 1px solid #cbd5e1;
    border-radius: 20px;
    padding: 8px 14px;
    font-size: 13px;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    background: #f8fafc;
}

.cs-input-field:focus {
    border-color: var(--cb-primary);
    background: #ffffff;
    box-shadow: 0 0 0 3px rgba(36, 87, 140, 0.15);
}

.cs-send-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--cb-primary);
    color: #ffffff;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
    flex-shrink: 0;
}

.cs-send-btn:hover {
    background: var(--cb-primary-dark);
}

.cs-send-btn:active {
    transform: scale(0.92);
}

.cs-send-btn:disabled {
    background: #cbd5e1;
    cursor: not-allowed;
}

/* Responsive Mobile Layout */
@media (max-width: 480px) {
    .cs-chatbot-window {
        bottom: 0;
        right: 0;
        width: 100vw;
        height: 100vh;
        max-width: 100vw;
        max-height: 100vh;
        border-radius: 0;
    }
    .cs-chatbot-header {
        border-radius: 0;
    }
    .cs-chatbot-launcher {
        bottom: 16px;
        right: 16px;
    }
}

/* ==========================================================================
   Task 17.6 Chatbot Widget Styles
   ========================================================================== */
#bot-widget {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 99999;
    font-family: 'Open Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

#bot-toggle {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #24578c 0%, #134e8b 100%);
    color: #ffffff;
    font-size: 26px;
    border: none;
    cursor: pointer;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2), 0 0 15px rgba(36, 87, 140, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    outline: none;
}

#bot-toggle:hover {
    transform: scale(1.08);
    box-shadow: 0 14px 28px rgba(36, 87, 140, 0.45);
}

#bot-toggle:active {
    transform: scale(0.95);
}

#bot-panel {
    position: absolute;
    bottom: 75px;
    right: 0;
    width: 440px;
    max-width: calc(100vw - 32px);
    height: 600px;
    max-height: calc(100vh - 110px);
    background: #ffffff;
    border-radius: 18px;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.18), 0 5px 15px rgba(0, 0, 0, 0.08);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid #e2e8f0;
    animation: botPanelSlideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes botPanelSlideUp {
    from { opacity: 0; transform: translateY(20px) scale(0.96); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

#bot-header {
    background: linear-gradient(135deg, #24578c 0%, #134e8b 100%);
    color: #ffffff;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 16px;
    font-weight: 700;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

#bot-close {
    background: transparent;
    border: none;
    color: #ffffff;
    font-size: 18px;
    cursor: pointer;
    opacity: 0.85;
    transition: opacity 0.2s ease, transform 0.2s ease;
    padding: 4px 8px;
    line-height: 1;
}

#bot-close:hover {
    opacity: 1;
    transform: scale(1.1);
}

#bot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background: #f8fafc;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.bot-msg {
    align-self: flex-start;
    background: #ffffff;
    color: #1e293b;
    padding: 10px 14px;
    border-radius: 14px 14px 14px 2px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
    border: 1px solid #e2e8f0;
    max-width: 85%;
    font-size: 13.5px;
    line-height: 1.45;
    word-break: break-word;
}

.bot-escalate-link {
    color: #24578c;
    font-weight: 700;
    text-decoration: underline;
    display: inline-block;
    margin-top: 4px;
}

.bot-escalate-link:hover {
    color: #134e8b;
}

.user-msg {
    align-self: flex-end;
    background: linear-gradient(135deg, #24578c 0%, #184b7d 100%);
    color: #ffffff;
    padding: 10px 14px;
    border-radius: 14px 14px 2px 14px;
    max-width: 85%;
    font-size: 13.5px;
    line-height: 1.45;
    word-break: break-word;
    box-shadow: 0 2px 6px rgba(36, 87, 140, 0.25);
}

#bot-quick-replies {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 8px 14px;
    background: #ffffff;
    border-top: 1px solid #edf2f7;
}

.bot-chip {
    background: #f1f5f9;
    color: #334155;
    border: 1px solid #cbd5e1;
    border-radius: 16px;
    padding: 5px 12px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    outline: none;
}

.bot-chip:hover {
    background: #24578c;
    color: #ffffff;
    border-color: #24578c;
    transform: translateY(-1px);
}

#bot-input-row {
    display: flex;
    padding: 10px 14px;
    background: #ffffff;
    border-top: 1px solid #e2e8f0;
    gap: 8px;
    align-items: center;
}

#bot-input {
    flex: 1;
    border: 1px solid #cbd5e1;
    border-radius: 20px;
    padding: 8px 16px;
    font-size: 13.5px;
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

#bot-input:focus {
    border-color: #24578c;
    box-shadow: 0 0 0 3px rgba(36, 87, 140, 0.15);
}

#bot-send {
    background: #24578c;
    color: #ffffff;
    border: none;
    border-radius: 20px;
    padding: 8px 18px;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.1s ease;
    outline: none;
}

#bot-send:hover {
    background: #134e8b;
}

#bot-send:active {
    transform: scale(0.95);
}

@media (max-width: 480px) {
    #bot-panel {
        position: fixed;
        bottom: 0;
        right: 0;
        width: 100vw;
        height: 100vh;
        max-height: 100vh;
        border-radius: 0;
    }
}
