/* ============================================================
   MedCafe AI Assistant — Chatbot Widget Styles
   Color Palette: #FF2E2E (primary), #00C2CB (secondary), #1F2937 (text)
   ============================================================ */

/* ---- CSS Variables (matching website palette) ---- */
:root {
    --mc-primary:    #FF2E2E;
    --mc-primary-dk: #e60000;
    --mc-secondary:  #00C2CB;
    --mc-text:       #1F2937;
    --mc-footer:     #111827;
    --mc-grad:       linear-gradient(135deg, #FF2E2E, #d62020);
    --mc-grad-sec:   linear-gradient(135deg, #00C2CB, #009ba3);
}

/* ---- Floating Button ---- */
#medcafe-chat-btn {
    position: fixed;
    bottom: 28px;
    right: 28px;
    width: 62px;
    height: 62px;
    border-radius: 50%;
    background: var(--mc-grad);
    border: none;
    cursor: pointer;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 25px rgba(255, 46, 46, 0.45);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    animation: chatBtnPulse 2.5s infinite;
}

#medcafe-chat-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 12px 35px rgba(255, 46, 46, 0.65);
    animation: none;
}

#medcafe-chat-btn i {
    color: white;
    font-size: 24px;
}

@keyframes chatBtnPulse {
    0%, 100% { box-shadow: 0 8px 25px rgba(255, 46, 46, 0.45); }
    50%       { box-shadow: 0 8px 35px rgba(255, 46, 46, 0.7), 0 0 0 8px rgba(255, 46, 46, 0.1); }
}

.chat-notif-dot {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 13px;
    height: 13px;
    background: var(--mc-secondary);
    border-radius: 50%;
    border: 2px solid white;
    animation: dotBlink 2s infinite;
}

@keyframes dotBlink {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.25; }
}

/* ---- Chat Window (normal mode) ---- */
#medcafe-chat-window {
    position: fixed;
    bottom: 104px;
    right: 28px;
    width: 380px;
    max-height: 560px;
    border-radius: 20px;
    /* Website glassmorphism */
    background: rgba(255, 255, 255, 0.18);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid rgba(255, 255, 255, 0.6);
    box-shadow:
        0 20px 60px rgba(0, 0, 0, 0.15),
        0 4px 15px rgba(255, 46, 46, 0.1);
    z-index: 9998;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    /* Animation defaults */
    transform: scale(0.85) translateY(20px);
    transform-origin: bottom right;
    opacity: 0;
    pointer-events: none;
    transition:
        transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1),
        opacity 0.25s ease,
        width 0.3s ease,
        height 0.3s ease,
        max-height 0.3s ease,
        border-radius 0.3s ease,
        bottom 0.3s ease,
        right 0.3s ease;
}

#medcafe-chat-window.open {
    transform: scale(1) translateY(0);
    opacity: 1;
    pointer-events: all;
}

/* ---- Fullscreen Mode (desktop) ---- */
#medcafe-chat-window.fullscreen {
    width: 80vw;
    max-width: 900px;
    max-height: 85vh;
    height: 85vh;
    bottom: 50%;
    right: 50%;
    transform: translate(50%, 50%) scale(1);
    border-radius: 20px;
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.25), 0 0 0 1px rgba(255,255,255,0.5);
}

/* ---- Header ---- */
.mc-chat-header {
    background: var(--mc-grad);
    padding: 15px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
    box-shadow: 0 2px 12px rgba(255, 46, 46, 0.25);
}

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

.mc-chat-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.25);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    border: 2px solid rgba(255, 255, 255, 0.5);
    box-shadow: inset 0 0 0 1px rgba(255,255,255,0.2);
}

.mc-chat-header-info h4 {
    margin: 0;
    font-size: 0.97rem;
    font-weight: 700;
    color: white;
    font-family: 'Inter', sans-serif;
    letter-spacing: 0.1px;
    display: flex;
    align-items: center;
    gap: 5px;
    text-shadow: 0 1px 3px rgba(0,0,0,0.15);
}

.mc-verified {
    font-size: 0.75rem;
    color: #00C2CB;
    text-shadow: 0 0 6px rgba(0, 194, 203, 0.8);
    animation: verifiedPulse 2s infinite;
}

@keyframes verifiedPulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50%       { opacity: 0.7; transform: scale(1.2); }
}

.mc-chat-header-info span {
    font-size: 0.72rem;
    color: rgba(255, 255, 255, 0.88);
    font-family: 'Inter', sans-serif;
    letter-spacing: 0.2px;
}

.mc-online-dot {
    display: inline-block;
    width: 7px;
    height: 7px;
    background: #10B981;
    border-radius: 50%;
    margin-right: 5px;
    vertical-align: middle;
    box-shadow: 0 0 0 2px rgba(255,255,255,0.4);
    animation: dotBlink 2s infinite;
}

/* Header action buttons (expand + close) */
.mc-header-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.mc-expand-btn,
.mc-close-btn {
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255,255,255,0.35);
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    transition: background 0.2s, transform 0.2s;
    flex-shrink: 0;
}

.mc-expand-btn:hover,
.mc-close-btn:hover {
    background: rgba(255, 255, 255, 0.35);
    transform: scale(1.1);
}

/* ---- Messages Area ---- */
.mc-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    scroll-behavior: smooth;
    /* Transparent so glass window shows through */
    background: transparent;
}

.mc-messages::-webkit-scrollbar { width: 4px; }
.mc-messages::-webkit-scrollbar-track { background: transparent; }
.mc-messages::-webkit-scrollbar-thumb {
    background: rgba(255, 46, 46, 0.2);
    border-radius: 10px;
}

/* ---- Message Bubbles ---- */
.mc-msg {
    display: flex;
    gap: 8px;
    align-items: flex-end;
    max-width: 82%;
    animation: msgIn 0.28s ease;
}

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

.mc-msg.bot  { align-self: flex-start; }
.mc-msg.user { align-self: flex-end; flex-direction: row-reverse; }

.mc-msg-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--mc-grad);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 12px;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(255,46,46,0.3);
}

.mc-msg.user .mc-msg-avatar {
    background: var(--mc-grad-sec);
    box-shadow: 0 2px 8px rgba(0,194,203,0.3);
}

.mc-bubble {
    padding: 10px 15px;
    border-radius: 18px;
    font-size: 0.875rem;
    line-height: 1.6;
    font-family: 'Inter', sans-serif;
    word-break: break-word;
}

.mc-msg.bot .mc-bubble {
    background: rgba(255, 255, 255, 0.55);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    color: var(--mc-text);
    border-bottom-left-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.7);
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.mc-msg.user .mc-bubble {
    background: var(--mc-grad);
    color: white;
    border-bottom-right-radius: 4px;
    box-shadow: 0 4px 12px rgba(255,46,46,0.3);
}

.mc-msg-time {
    font-size: 0.68rem;
    color: #9CA3AF;
    margin-top: 4px;
    display: block;
    padding: 0 4px;
}

/* ---- Typing Indicator ---- */
.mc-typing {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    align-self: flex-start;
    animation: msgIn 0.28s ease;
}

.mc-typing-bubble {
    background: rgba(255, 255, 255, 0.55);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: 18px;
    border-bottom-left-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.7);
    padding: 12px 18px;
    display: flex;
    gap: 5px;
    align-items: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.mc-typing-bubble span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--mc-primary);
    display: inline-block;
    animation: typingDot 1.2s infinite;
    opacity: 0.6;
}

.mc-typing-bubble span:nth-child(2) { animation-delay: 0.2s; background: #FF6B6B; }
.mc-typing-bubble span:nth-child(3) { animation-delay: 0.4s; background: var(--mc-secondary); }

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

/* ---- Divider label ---- */
.mc-date-label {
    text-align: center;
    font-size: 0.7rem;
    color: #9CA3AF;
    font-family: 'Inter', sans-serif;
    letter-spacing: 0.5px;
    margin: 4px 0;
    flex-shrink: 0;
}

/* ---- Input Area ---- */
.mc-input-area {
    padding: 12px 14px 14px;
    border-top: 1px solid rgba(255, 255, 255, 0.4);
    display: flex;
    gap: 10px;
    align-items: flex-end;
    flex-shrink: 0;
    background: rgba(255, 255, 255, 0.35);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

#mc-user-input {
    flex: 1;
    border: 1.5px solid rgba(255, 255, 255, 0.6);
    border-radius: 14px;
    padding: 10px 14px;
    font-size: 0.875rem;
    font-family: 'Inter', sans-serif;
    resize: none;
    outline: none;
    max-height: 100px;
    overflow-y: auto;
    line-height: 1.5;
    transition: border-color 0.2s, box-shadow 0.2s;
    color: var(--mc-text);
    background: rgba(255, 255, 255, 0.5);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

#mc-user-input:focus {
    border-color: var(--mc-primary);
    box-shadow: 0 0 0 3px rgba(255, 46, 46, 0.08);
    background: white;
}

#mc-user-input:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

#mc-send-btn {
    width: 42px;
    height: 42px;
    min-width: 42px;
    border-radius: 14px;
    background: var(--mc-grad);
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    transition: transform 0.2s, box-shadow 0.2s, opacity 0.2s;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(255,46,46,0.3);
}

#mc-send-btn:hover:not(:disabled) {
    transform: scale(1.08);
    box-shadow: 0 6px 18px rgba(255,46,46,0.45);
}

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

/* ---- System (rate limit / error) message ---- */
.mc-system-msg {
    text-align: center;
    font-size: 0.78rem;
    color: var(--mc-primary);
    background: rgba(255, 46, 46, 0.06);
    border: 1px solid rgba(255, 46, 46, 0.2);
    border-radius: 12px;
    padding: 8px 14px;
    align-self: center;
    font-family: 'Inter', sans-serif;
    animation: msgIn 0.28s ease;
}

/* ---- Footer branding ---- */
.mc-powered-by {
    text-align: center;
    font-size: 0.65rem;
    color: rgba(31, 41, 55, 0.5);
    padding: 6px 0 2px;
    font-family: 'Inter', sans-serif;
    background: rgba(255, 255, 255, 0.3);
    flex-shrink: 0;
}

.mc-powered-by span {
    color: var(--mc-secondary);
    font-weight: 600;
}

/* ============================================================
   MOBILE RESPONSIVE
   ============================================================ */
@media (max-width: 600px) {
    #medcafe-chat-window {
        width: calc(100vw - 20px);
        right: 10px;
        bottom: 85px;
        max-height: 75vh;
        border-radius: 18px;
    }

    #medcafe-chat-btn {
        right: 16px;
        bottom: 16px;
        width: 56px;
        height: 56px;
    }

    /* Mobile fullscreen — true fullscreen */
    #medcafe-chat-window.fullscreen {
        width: 100vw;
        height: 100dvh;
        height: 100vh;
        max-height: 100vh;
        bottom: 0;
        right: 0;
        border-radius: 0;
        transform: scale(1) translateY(0);
    }
}

/* =========================================================================
   SUGGESTED QUESTIONS (CHIPS)
   ========================================================================= */
.mc-suggestions-wrapper {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 0 15px 10px 15px;
    margin-top: auto;
}

.mc-suggestion-chip {
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.3);
    color: #059669;
    padding: 8px 14px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: normal;
    text-align: left;
    display: inline-block;
    max-width: 100%;
}

.mc-suggestion-chip:hover {
    background: rgba(16, 185, 129, 0.2);
    border-color: rgba(16, 185, 129, 0.5);
    transform: translateY(-1px);
}
