/**
 * Niko Dental & Aesthetics — CareFirst-Style AI Assistant Styling
 * Clean, modern, trustworthy medical assistant theme.
 */

:root {
    --niko-navy-dark: #0A1C30;
    --niko-navy-primary: #0F2B48;
    --niko-blue-accent: #3B82F6;
    --niko-blue-hover: #2563EB;
    --niko-blue-soft: #EFF6FF;
    --niko-emerald: #10B981;
    --niko-text-dark: #0F172A;
    --niko-text-muted: #64748B;
    --niko-text-light: #94A3B8;
    --niko-border-color: #E2E8F0;
    --niko-bg-surface: #F8FAFC;
    --niko-font: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* ==========================================================================
   0. Messenger-Style Proactive Rotating Greeting Popup (Vibrant Red Theme)
   ========================================================================== */

.niko-greeting-bubble {
    position: absolute;
    bottom: calc(100% + 16px);
    left: 4px;
    width: max-content;
    max-width: 260px;
    min-width: 175px;
    background: linear-gradient(135deg, #E11D48 0%, #DC2626 50%, #B91C1C 100%);
    color: #FFFFFF;
    font-size: 0.88rem;
    font-weight: 700;
    line-height: 1.38;
    padding: 11px 34px 11px 16px;
    border-radius: 18px;
    box-shadow: 0 14px 34px rgba(220, 38, 38, 0.38), 0 4px 12px rgba(0, 0, 0, 0.15);
    border: 1.5px solid rgba(255, 255, 255, 0.28);
    cursor: pointer;
    z-index: 9999999;
    user-select: none;
    animation: nikoGreetingSlideUp 0.35s cubic-bezier(0.16, 1, 0.3, 1);
    transition: transform 0.25s ease, box-shadow 0.25s ease, opacity 0.3s ease;
    display: none;
}

.niko-greeting-bubble.is-active {
    display: block !important;
}

.niko-greeting-bubble:hover {
    transform: translateY(-3px) scale(1.02);
    box-shadow: 0 18px 40px rgba(220, 38, 38, 0.48);
}

.niko-greeting-bubble.fade-out {
    opacity: 0;
    transform: translateY(8px) scale(0.95);
    pointer-events: none;
}

.niko-greeting-bubble.text-transitioning {
    opacity: 0.2;
    transform: translateY(-3px);
}

@keyframes nikoGreetingSlideUp {
    from {
        opacity: 0;
        transform: translateY(12px) scale(0.92);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.greeting-text {
    display: block;
    color: #FFFFFF;
    font-size: 0.88rem;
    font-weight: 700;
    letter-spacing: 0.2px;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
    transition: opacity 0.25s ease, transform 0.25s ease;
}

.greeting-close-btn {
    position: absolute;
    top: 6px;
    right: 7px;
    width: 22px;
    height: 22px;
    border: none;
    background: rgba(255, 255, 255, 0.2);
    color: #FFFFFF;
    font-size: 1.15rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border-radius: 50%;
    transition: color 0.15s ease, background-color 0.15s ease, transform 0.15s ease;
}

.greeting-close-btn:hover {
    color: #FFFFFF;
    background-color: rgba(255, 255, 255, 0.35);
    transform: scale(1.08);
}

.greeting-tail {
    position: absolute;
    bottom: -6px;
    left: 26px;
    width: 12px;
    height: 12px;
    background: #B91C1C;
    transform: rotate(45deg);
    border-right: 1.5px solid rgba(255, 255, 255, 0.28);
    border-bottom: 1.5px solid rgba(255, 255, 255, 0.28);
    pointer-events: none;
}

/* 1. Fixed Root Container */
.niko-chatbot-root {
    position: fixed;
    bottom: 24px;
    left: 24px;
    z-index: 999999;
    font-family: var(--niko-font, sans-serif);
}

.niko-ai-launcher {
    position: relative;
    width: 66px;
    height: 66px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.3);
    background: 
        radial-gradient(circle at 30% 25%, rgba(255, 255, 255, 0.35), transparent 45%),
        linear-gradient(135deg, #116053 0%, #0b4a41 50%, #07342e 100%);
    box-shadow: 0 12px 30px rgba(7, 43, 37, 0.38), 0 4px 10px rgba(0, 0, 0, 0.15);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    outline: none;
    padding: 0;
    transition: transform 0.28s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.28s ease;
    animation: nikoOrbBreathe 3.4s infinite ease-in-out;
}

@keyframes nikoOrbBreathe {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 12px 30px rgba(7, 43, 37, 0.38), 0 0 0 0 rgba(16, 185, 129, 0.4);
    }
    50% {
        transform: scale(1.04);
        box-shadow: 0 16px 36px rgba(7, 43, 37, 0.46), 0 0 0 8px rgba(16, 185, 129, 0);
    }
}

.niko-ai-launcher:hover {
    transform: translateY(-4px) scale(1.05);
    box-shadow: 0 20px 42px rgba(7, 43, 37, 0.5);
}

.launcher-ambient-aura {
    position: absolute;
    inset: -3px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(16, 185, 129, 0.3) 0%, transparent 70%);
    pointer-events: none;
    z-index: 1;
}

.launcher-icon-wrap {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    font-size: 1.65rem;
    z-index: 2;
}

.ai-sparkle-star {
    position: absolute;
    top: -7px;
    right: -7px;
    color: #fce77d;
    font-size: 0.95rem;
    animation: sparkleTwinkle 2.4s infinite ease-in-out;
}

@keyframes sparkleTwinkle {
    0%, 100% { transform: scale(0.9) rotate(0deg); opacity: 0.85; }
    50% { transform: scale(1.18) rotate(12deg); opacity: 1; }
}

.launcher-presence-dot {
    position: absolute;
    top: 3px;
    right: 3px;
    width: 13px;
    height: 13px;
    border-radius: 50%;
    background: #10b981;
    border: 2px solid #ffffff;
    box-shadow: 0 0 6px rgba(16, 185, 129, 0.8);
    z-index: 3;
}

.launcher-expand-label {
    position: absolute;
    left: calc(100% + 14px);
    top: 50%;
    transform: translateY(-50%) translateX(-8px);
    background: #0A1C30;
    color: #ffffff;
    padding: 7px 14px;
    border-radius: 50px;
    font-size: 0.82rem;
    font-weight: 700;
    letter-spacing: 0.3px;
    white-space: nowrap;
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease, transform 0.25s ease;
    display: flex;
    align-items: center;
    gap: 6px;
    z-index: 4;
}

.niko-ai-launcher:hover .launcher-expand-label {
    opacity: 1;
    transform: translateY(-50%) translateX(0);
}

/* 2. Unified Chat Window (CareFirst Style Layout) */
.niko-chat-card {
    position: fixed;
    bottom: 104px;
    left: 24px;
    width: 395px;
    max-width: calc(100vw - 48px);
    height: 580px;
    max-height: calc(100vh - 124px);
    background: #ffffff;
    border-radius: 20px;
    border: 1px solid rgba(15, 43, 72, 0.12);
    box-shadow: 0 20px 48px rgba(10, 28, 48, 0.24), 0 4px 12px rgba(0, 0, 0, 0.08);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 999999;
    animation: nikoChatSlideIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

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

/* 3. Header (CareFirst Style) */
.chat-header {
    background: linear-gradient(135deg, #0A1C30 0%, #0F2B48 100%);
    padding: 16px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: #ffffff;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

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

.avatar-container {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: #ffffff;
    padding: 3px;
    border: 2px solid rgba(255, 255, 255, 0.25);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.header-avatar {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 50%;
}

.header-meta {
    display: flex;
    flex-direction: column;
}

.header-title-row {
    display: flex;
    align-items: center;
    gap: 4px;
}

.header-title {
    font-size: 1.12rem;
    font-weight: 800;
    color: #ffffff;
    margin: 0;
    letter-spacing: -0.2px;
}

.text-blue-accent {
    color: #38BDF8;
    font-weight: 800;
    margin-left: 3px;
}

.header-sub-row {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.74rem;
    color: rgba(255, 255, 255, 0.85);
    margin-top: 2px;
}

.online-indicator-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #10B981;
    box-shadow: 0 0 6px #10B981;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.header-btn {
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.18);
    color: #ffffff;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 0.92rem;
    transition: background 0.2s ease, transform 0.2s ease;
}

.header-btn:hover {
    background: rgba(255, 255, 255, 0.24);
    transform: scale(1.05);
}

/* 4. Chat Body */
.chat-body {
    flex: 1;
    overflow-y: auto;
    background: #F8FAFC;
    padding: 16px;
    display: flex;
    flex-direction: column;
}

.chat-messages {
    display: flex;
    flex-direction: column;
    gap: 16px;
    width: 100%;
}

/* Welcome Card */
.welcome-container {
    padding: 6px 0 10px;
}

.welcome-card {
    background: #ffffff;
    border: 1px solid #E2E8F0;
    border-radius: 16px;
    padding: 18px 20px;
    box-shadow: 0 4px 14px rgba(15, 43, 72, 0.05);
}

.welcome-greeting-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}

.welcome-name {
    font-size: 1.05rem;
    font-weight: 800;
    color: #0F2B48;
    margin: 0;
}

.welcome-text {
    font-size: 0.88rem;
    color: #475569;
    line-height: 1.55;
    margin: 0;
}

/* Messages */
.chat-msg {
    display: flex;
    flex-direction: column;
    width: 100%;
    animation: msgFadeIn 0.25s ease-out;
}

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

.msg-user {
    align-items: flex-end;
}

.msg-user .msg-content-wrap {
    max-width: 82%;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.msg-user .msg-bubble {
    background: #3B82F6;
    color: #ffffff;
    border-radius: 18px 18px 4px 18px;
    padding: 12px 18px;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.25);
}

.msg-user .msg-bubble p {
    margin: 0;
    font-size: 0.92rem;
    font-weight: 500;
    line-height: 1.45;
    color: #ffffff;
}

.msg-user .msg-time {
    font-size: 0.72rem;
    color: #94A3B8;
    margin-top: 4px;
    padding-right: 4px;
}

/* Bot Message Card */
.msg-bot {
    align-items: flex-start;
}

.msg-bot .msg-content-wrap {
    max-width: 95%;
    display: flex;
    flex-direction: column;
}

.msg-bot .msg-bubble {
    background: #ffffff;
    border: 1px solid #E2E8F0;
    border-radius: 18px 18px 18px 4px;
    padding: 16px 18px;
    color: #0F172A;
    box-shadow: 0 4px 14px rgba(15, 43, 72, 0.05);
    font-size: 0.92rem;
    line-height: 1.6;
}

.msg-bot .msg-bubble p {
    margin-bottom: 10px;
}

.msg-bot .msg-bubble p:last-child {
    margin-bottom: 0;
}

.msg-bot .msg-bubble strong {
    color: #0F2B48;
    font-weight: 700;
}

.msg-bot .msg-bubble h3,
.msg-bot .msg-bubble h4,
.msg-bot .msg-bubble h5 {
    color: #0F2B48;
    font-weight: 800;
    margin: 6px 0 8px;
}

.msg-bot .msg-bubble ul,
.msg-bot .msg-bubble .md-ul {
    margin: 8px 0 12px;
    padding-left: 0;
    list-style: none;
}

.msg-bot .msg-bubble li,
.msg-bot .msg-bubble .md-li {
    position: relative;
    padding-left: 18px;
    margin-bottom: 8px;
    line-height: 1.55;
}

.msg-bot .msg-bubble li:last-child,
.msg-bot .msg-bubble .md-li:last-child {
    margin-bottom: 0;
}

.msg-bot .msg-bubble li::before,
.msg-bot .msg-bubble .md-li::before {
    content: '•';
    position: absolute;
    left: 2px;
    top: -1px;
    color: #3B82F6;
    font-size: 1.25rem;
    line-height: 1;
    font-weight: 800;
}

/* Action Links in Bot Message */
.msg-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}

.action-link-btn {
    background: #EFF6FF;
    border: 1px solid #BFDBFE;
    color: #1D5FA7;
    padding: 6px 14px;
    border-radius: 50px;
    font-size: 0.78rem;
    font-weight: 700;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s ease;
}

.action-link-btn:hover {
    background: #1D5FA7;
    color: #ffffff;
    border-color: #1D5FA7;
    transform: translateY(-1px);
}

/* Feedback Row */
.msg-footer-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 6px;
    padding: 0 4px;
}

.msg-feedback-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.feedback-label {
    font-size: 0.74rem;
    color: #94A3B8;
}

.btn-feedback {
    background: transparent;
    border: 1px solid #CBD5E1;
    border-radius: 50px;
    padding: 2px 8px;
    font-size: 0.72rem;
    color: #475569;
    cursor: pointer;
    transition: background 0.2s ease, border-color 0.2s ease;
}

.btn-feedback:hover {
    background: #EFF6FF;
    border-color: #3B82F6;
    color: #1D5FA7;
}

.feedback-given-text {
    font-size: 0.74rem;
    color: #10B981;
    font-weight: 600;
}

.msg-bot .msg-time {
    font-size: 0.72rem;
    color: #94A3B8;
    margin-left: auto;
}

/* Typing Indicator */
.chat-typing-container {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    margin-top: 4px;
}

.typing-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: #0F2B48;
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
}

.typing-bubble {
    background: #ffffff;
    border: 1px solid #E2E8F0;
    padding: 8px 14px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.typing-text {
    font-size: 0.8rem;
    color: #64748B;
    font-weight: 600;
}

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

.typing-dots .dot {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: #3B82F6;
    animation: typingBounce 1.4s infinite ease-in-out;
}

.typing-dots .dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dots .dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingBounce {
    0%, 80%, 100% { transform: translateY(0); opacity: 0.4; }
    40% { transform: translateY(-5px); opacity: 1; }
}

/* 5. Quick Action Suggestion Pills (CareFirst Style) */
.chat-quick-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 10px 16px;
    background: #F8FAFC;
    border-top: 1px solid #E2E8F0;
}

.quick-action-pill {
    background: #ffffff;
    border: 1.5px solid #CBD5E1;
    color: #1D5FA7;
    border-radius: 50px;
    padding: 6px 14px;
    font-size: 0.78rem;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.03);
    transition: all 0.2s ease;
    white-space: nowrap;
}

.quick-action-pill:hover {
    background: #EFF6FF;
    border-color: #3B82F6;
    color: #2563EB;
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(59, 130, 246, 0.15);
}

/* 6. Composer & Input */
.chat-composer {
    background: #ffffff;
    border-top: 1px solid #E2E8F0;
    padding: 10px 14px 14px;
}

.composer-form {
    margin: 0;
}

.composer-input-pill {
    border: 1.5px solid #CBD5E1;
    border-radius: 50px;
    padding: 4px 6px 4px 16px;
    background: #ffffff;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.composer-input-pill:focus-within {
    border-color: #3B82F6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.12);
}

.composer-textarea {
    flex: 1;
    border: none;
    outline: none;
    background: transparent;
    font-size: 0.88rem;
    color: #0F172A;
    resize: none;
    font-family: inherit;
    line-height: 1.4;
    padding: 6px 0;
    max-height: 75px;
}

.composer-textarea::placeholder {
    color: #94A3B8;
    font-size: 0.84rem;
}

.composer-send-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #3B82F6;
    color: #ffffff;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.05rem;
    transition: background 0.2s ease, transform 0.2s ease;
    flex-shrink: 0;
}

.composer-send-btn:hover {
    background: #2563EB;
    transform: scale(1.05);
}

.composer-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* Mobile Responsiveness */
@media (max-width: 480px) {
    .niko-chat-card {
        bottom: 86px;
        left: 12px;
        right: 12px;
        width: calc(100vw - 24px);
        height: 520px;
    }
    .niko-chatbot-root {
        bottom: 16px;
        left: 16px;
    }
}
