/* ============================================================
   Mfano Bora Africa — Chat Widget Styles
   ============================================================ */

/* ---------- Variables ---------- */
:root {
    --mfano-primary: #2c5282;
    --mfano-primary-dark: #1a365d;
    --mfano-accent: #38a169;
    --mfano-bg: #ffffff;
    --mfano-bg-alt: #f7fafc;
    --mfano-text: #1a202c;
    --mfano-text-muted: #718096;
    --mfano-border: #e2e8f0;
    --mfano-user-bubble: #2c5282;
    --mfano-bot-bubble: #edf2f7;
    --mfano-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    --mfano-radius: 16px;
}

/* ---------- Widget container ---------- */
#mfano-chat-widget {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 999999;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: var(--mfano-text);
}

#mfano-chat-widget * {
    box-sizing: border-box;
}

/* ---------- Floating toggle button ---------- */
#mfano-chat-toggle {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--mfano-primary);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 6px 20px rgba(44, 82, 130, 0.4);
    transition: all 0.25s ease;
    position: relative;
}

#mfano-chat-toggle:hover {
    background: var(--mfano-primary-dark);
    transform: scale(1.05);
    box-shadow: 0 8px 24px rgba(44, 82, 130, 0.5);
}

#mfano-chat-toggle:active {
    transform: scale(0.98);
}

#mfano-chat-toggle svg {
    width: 28px;
    height: 28px;
}

/* Badge on the toggle */
.mfano-chat-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #e53e3e;
    color: white;
    border-radius: 50%;
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    border: 2px solid white;
}

/* ---------- Chat panel ---------- */
#mfano-chat-panel {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 380px;
    height: 560px;
    max-height: calc(100vh - 120px);   /* never taller than viewport (with room for toggle) */
    background: var(--mfano-bg);
    border-radius: var(--mfano-radius);
    box-shadow: var(--mfano-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform-origin: bottom right;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.mfano-chat-hidden {
    opacity: 0;
    transform: scale(0.9) translateY(10px);
    pointer-events: none;
}

/* ---------- Header ---------- */
.mfano-chat-header {
    background: linear-gradient(135deg, var(--mfano-primary) 0%, var(--mfano-primary-dark) 100%);
    color: white;
    padding: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
    height: 72px;
    min-height: 72px;
    box-sizing: border-box;
}

.mfano-chat-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.mfano-chat-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 18px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    flex-shrink: 0;
}

.mfano-chat-title {
    font-weight: 600;
    font-size: 15px;
    line-height: 1.2;
}

.mfano-chat-subtitle {
    font-size: 12px;
    opacity: 0.85;
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 2px;
}

.mfano-chat-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #48bb78;
    box-shadow: 0 0 0 2px rgba(72, 187, 120, 0.3);
    flex-shrink: 0;
}

#mfano-chat-close {
    background: transparent;
    border: none;
    color: white;
    cursor: pointer;
    padding: 6px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s ease;
    flex-shrink: 0;
}

#mfano-chat-close:hover {
    background: rgba(255, 255, 255, 0.15);
}

#mfano-chat-close svg {
    width: 20px;
    height: 20px;
}

/* ---------- Messages area ---------- */
.mfano-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background: var(--mfano-bg-alt);
    display: flex;
    flex-direction: column;
    gap: 12px;
    scroll-behavior: smooth;
    min-height: 0;   /* ensures flex child can shrink below content size */
}

.mfano-chat-messages::-webkit-scrollbar {
    width: 6px;
}

.mfano-chat-messages::-webkit-scrollbar-thumb {
    background: #cbd5e0;
    border-radius: 3px;
}

.mfano-chat-messages::-webkit-scrollbar-thumb:hover {
    background: #a0aec0;
}

/* ---------- Message bubbles ---------- */
.mfano-message {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
    white-space: pre-wrap;
    animation: mfano-fade-in 0.25s ease;
}

@keyframes mfano-fade-in {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

.mfano-message-user {
    align-self: flex-end;
    background: var(--mfano-user-bubble);
    color: white;
    border-bottom-right-radius: 4px;
}

.mfano-message-bot {
    align-self: flex-start;
    background: var(--mfano-bot-bubble);
    color: var(--mfano-text);
    border-bottom-left-radius: 4px;
}

.mfano-message-bot a {
    color: var(--mfano-primary);
    text-decoration: underline;
}

/* ---------- Feedback row ---------- */
.mfano-feedback-row {
    align-self: flex-start;
    display: flex;
    gap: 6px;
    margin-top: -4px;
    padding-left: 4px;
    animation: mfano-fade-in 0.3s ease;
}

.mfano-feedback-btn {
    background: white;
    border: 1px solid var(--mfano-border);
    border-radius: 20px;
    padding: 4px 10px;
    font-size: 12px;
    color: var(--mfano-text-muted);
    cursor: pointer;
    transition: all 0.15s ease;
    display: flex;
    align-items: center;
    gap: 4px;
}

.mfano-feedback-btn:hover {
    background: var(--mfano-bg-alt);
    border-color: var(--mfano-primary);
    color: var(--mfano-primary);
}

.mfano-feedback-btn.mfano-selected {
    background: var(--mfano-primary);
    color: white;
    border-color: var(--mfano-primary);
}

.mfano-feedback-btn.mfano-thanks {
    background: var(--mfano-accent);
    color: white;
    border-color: var(--mfano-accent);
    cursor: default;
}

/* ---------- Typing indicator ---------- */
.mfano-typing {
    align-self: flex-start;
    background: var(--mfano-bot-bubble);
    padding: 12px 16px;
    border-radius: 14px;
    border-bottom-left-radius: 4px;
    display: flex;
    gap: 4px;
    align-items: center;
}

.mfano-typing-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #a0aec0;
    animation: mfano-typing 1.2s infinite;
}

.mfano-typing-dot:nth-child(2) { animation-delay: 0.15s; }
.mfano-typing-dot:nth-child(3) { animation-delay: 0.3s; }

@keyframes mfano-typing {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-4px); opacity: 1; }
}

/* ---------- Input row ---------- */
.mfano-chat-input-row {
    display: flex;
    gap: 8px;
    padding: 12px;
    background: white;
    border-top: 1px solid var(--mfano-border);
    flex-shrink: 0;
}

#mfano-chat-input {
    flex: 1;
    border: 1px solid var(--mfano-border);
    border-radius: 22px;
    padding: 10px 16px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.15s ease;
    font-family: inherit;
    min-width: 0;
}

#mfano-chat-input:focus {
    border-color: var(--mfano-primary);
}

#mfano-chat-input:disabled {
    background: var(--mfano-bg-alt);
    cursor: not-allowed;
}

#mfano-chat-send {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--mfano-primary);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s ease, transform 0.1s ease;
    flex-shrink: 0;
}

#mfano-chat-send:hover:not(:disabled) {
    background: var(--mfano-primary-dark);
}

#mfano-chat-send:active:not(:disabled) {
    transform: scale(0.95);
}

#mfano-chat-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

#mfano-chat-send svg {
    width: 18px;
    height: 18px;
}

/* ---------- Welcome message ---------- */
.mfano-welcome {
    text-align: center;
    color: var(--mfano-text-muted);
    font-size: 12px;
    padding: 8px 16px;
    line-height: 1.5;
}


/* ---------- Mobile ---------- */
@media (max-width: 480px) {
    #mfano-chat-widget {
        bottom: 16px;
        right: 16px;
    }

    #mfano-chat-toggle {
        width: 54px;
        height: 54px;
    }

    #mfano-chat-panel {
        width: calc(100vw - 32px);
        height: auto;
        max-height: calc(100vh - 160px);   /* fallback */
        max-height: calc(100dvh - 160px);  /* dynamic viewport (mobile) */
        bottom: 74px;
        right: -8px;
        max-width: 400px;
        min-height: 320px;
    }
}

/* ---------- Very short viewports (landscape phones) ---------- */
@media (max-height: 620px) {
    #mfano-chat-panel {
        max-height: calc(100vh - 120px);
        max-height: calc(100dvh - 120px);
    }
}