/* GFZA AfCFTA Desk AI Chatbot - Frontend Styles */
:root {
    --gfza-primary: #006633;
    --gfza-primary-dark: #004d26;
    --gfza-primary-light: #e8f5ee;
    --gfza-gold: #d4a017;
    --gfza-text: #1a1a2e;
    --gfza-text-muted: #6b7280;
    --gfza-bg: #ffffff;
    --gfza-bg-light: #f8fafb;
    --gfza-border: #e5e7eb;
    --gfza-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
    --gfza-radius: 16px;
    --gfza-radius-sm: 8px;
    --gfza-font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* Root Container */
.gfza-chatbot-root {
    position: fixed;
    z-index: 99999;
    font-family: var(--gfza-font);
}

.gfza-chatbot-root.pos-bottom-right {
    bottom: 24px;
    right: 24px;
}

.gfza-chatbot-root.pos-bottom-left {
    bottom: 24px;
    left: 24px;
}

/* Toggle Button */
.gfza-toggle-btn {
    width: 58px;
    height: 58px;
    border-radius: 50%;
    background: var(--gfza-primary);
    color: #fff;
    border: none;
    cursor: pointer;
    font-size: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 20px rgba(0, 102, 51, 0.4);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    position: relative;
}

.gfza-toggle-btn:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 28px rgba(0, 102, 51, 0.5);
}

.gfza-notification-dot {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 12px;
    height: 12px;
    background: var(--gfza-gold);
    border-radius: 50%;
    border: 2px solid #fff;
    display: none;
    animation: gfza-pulse 1.5s infinite;
}

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

/* Chat Window */
.gfza-chatbot-window {
    position: absolute;
    bottom: 70px;
    width: 380px;
    max-height: 580px;
    background: var(--gfza-bg);
    border-radius: var(--gfza-radius);
    box-shadow: var(--gfza-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: scale(0.8) translateY(20px);
    transform-origin: bottom right;
    opacity: 0;
    pointer-events: none;
    transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.2s ease;
    border: 1px solid var(--gfza-border);
}

.pos-bottom-right .gfza-chatbot-window { right: 0; }
.pos-bottom-left .gfza-chatbot-window { left: 0; transform-origin: bottom left; }

.gfza-chatbot-window.gfza-open {
    opacity: 1;
    transform: scale(1) translateY(0);
    pointer-events: all;
}

/* Header */
.gfza-chat-header {
    background: var(--gfza-primary);
    color: #fff;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.gfza-header-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.gfza-avatar {
    width: 38px;
    height: 38px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
}

.gfza-header-info strong {
    display: block;
    font-size: 14px;
    font-weight: 600;
    line-height: 1.3;
}

.gfza-status {
    font-size: 11px;
    opacity: 0.85;
    display: flex;
    align-items: center;
    gap: 4px;
}

.gfza-status .fa-circle {
    font-size: 7px;
    color: #4ade80;
}

.gfza-header-actions {
    display: flex;
    gap: 4px;
}

.gfza-icon-btn {
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: #fff;
    width: 30px;
    height: 30px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
}

.gfza-icon-btn:hover {
    background: rgba(255, 255, 255, 0.25);
}

/* Messages */
.gfza-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    scroll-behavior: smooth;
    background: var(--gfza-bg-light);
}

.gfza-messages::-webkit-scrollbar { width: 4px; }
.gfza-messages::-webkit-scrollbar-track { background: transparent; }
.gfza-messages::-webkit-scrollbar-thumb { background: var(--gfza-border); border-radius: 2px; }

/* Message Bubbles */
.gfza-msg {
    display: flex;
    gap: 8px;
    max-width: 88%;
    animation: gfza-fade-in 0.2s ease;
}

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

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

.gfza-msg-icon {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--gfza-primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    flex-shrink: 0;
    margin-top: 2px;
}

.gfza-msg.gfza-user .gfza-msg-icon {
    background: var(--gfza-text-muted);
}

.gfza-bubble {
    padding: 10px 13px;
    border-radius: 14px;
    font-size: 13.5px;
    line-height: 1.55;
    color: var(--gfza-text);
    max-width: 100%;
    word-break: break-word;
}

.gfza-msg.gfza-bot .gfza-bubble {
    background: var(--gfza-bg);
    border: 1px solid var(--gfza-border);
    border-top-left-radius: 4px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.gfza-msg.gfza-user .gfza-bubble {
    background: var(--gfza-primary);
    color: #fff;
    border-top-right-radius: 4px;
}

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

.gfza-msg.gfza-user .gfza-msg-time {
    text-align: right;
}

/* Typing Indicator */
.gfza-typing-indicator {
    display: flex;
    gap: 4px;
    padding: 8px 10px;
    align-items: center;
}

.gfza-typing-indicator span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--gfza-primary);
    opacity: 0.5;
    animation: gfza-typing 1.2s infinite;
}

.gfza-typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.gfza-typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

@keyframes gfza-typing {
    0%, 80%, 100% { transform: scale(1); opacity: 0.5; }
    40% { transform: scale(1.3); opacity: 1; }
}

/* Suggestions */
.gfza-suggestions {
    padding: 8px 12px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    background: var(--gfza-bg);
    border-top: 1px solid var(--gfza-border);
    flex-shrink: 0;
}

.gfza-suggestion-btn {
    background: var(--gfza-primary-light);
    border: 1px solid rgba(0, 102, 51, 0.2);
    color: var(--gfza-primary);
    border-radius: 20px;
    padding: 5px 11px;
    font-size: 11.5px;
    cursor: pointer;
    font-family: var(--gfza-font);
    transition: background 0.15s;
    white-space: nowrap;
}

.gfza-suggestion-btn:hover {
    background: rgba(0, 102, 51, 0.15);
}

/* Input Area */
.gfza-input-area {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 10px 12px;
    background: var(--gfza-bg);
    border-top: 1px solid var(--gfza-border);
    flex-shrink: 0;
}

.gfza-input {
    flex: 1;
    border: 1px solid var(--gfza-border);
    border-radius: var(--gfza-radius-sm);
    padding: 9px 12px;
    font-size: 13.5px;
    font-family: var(--gfza-font);
    resize: none;
    outline: none;
    max-height: 100px;
    overflow-y: auto;
    line-height: 1.5;
    color: var(--gfza-text);
    transition: border-color 0.15s;
}

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

.gfza-send-btn {
    background: var(--gfza-primary);
    color: #fff;
    border: none;
    width: 38px;
    height: 38px;
    border-radius: var(--gfza-radius-sm);
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.15s;
}

.gfza-send-btn:hover { background: var(--gfza-primary-dark); }
.gfza-send-btn:disabled { background: #9ca3af; cursor: not-allowed; }

/* Footer */
.gfza-chat-footer {
    background: var(--gfza-primary-light);
    border-top: 1px solid rgba(0, 102, 51, 0.1);
    padding: 7px 12px;
    font-size: 10.5px;
    color: var(--gfza-primary-dark);
    text-align: center;
    flex-shrink: 0;
}

.gfza-chat-footer i {
    margin-right: 2px;
}

/* Error message */
.gfza-msg-error .gfza-bubble {
    background: #fef2f2;
    border-color: #fca5a5;
    color: #dc2626;
}

/* Inline shortcode */
.gfza-inline-wrap {
    border-radius: var(--gfza-radius);
    overflow: hidden;
    box-shadow: var(--gfza-shadow);
    border: 1px solid var(--gfza-border);
    display: flex;
    flex-direction: column;
    font-family: var(--gfza-font);
    max-width: 600px;
    margin: 20px auto;
}

.gfza-inline-wrap .gfza-chat-header {
    position: relative;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.gfza-inline-messages {
    min-height: 300px;
    max-height: 400px;
}

/* ── Mobile Fullscreen Takeover ── */
@media (max-width: 600px) {

    /* Root stays fixed but covers the whole screen when open */
    .gfza-chatbot-root.gfza-mobile-open {
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        height: 100%;
    }

    /* Fullscreen window */
    .gfza-chatbot-root.gfza-mobile-open .gfza-chatbot-window {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        height: 100%;
        max-height: 100%;
        border-radius: 0;
        transform: translateY(100%);
        opacity: 1;
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        border: none;
    }

    .gfza-chatbot-root.gfza-mobile-open .gfza-chatbot-window.gfza-open {
        transform: translateY(0);
    }

    /* Keep toggle button on top of the overlay */
    .gfza-chatbot-root.gfza-mobile-open .gfza-toggle-btn {
        position: fixed;
        /* positioned by JS per original side */
        z-index: 100001;
    }

    /* Messages fill available space — keyboard-aware via JS */
    .gfza-chatbot-root.gfza-mobile-open .gfza-messages {
        flex: 1;
        max-height: none;
    }

    /* Slightly larger input tap target */
    .gfza-chatbot-root.gfza-mobile-open .gfza-input {
        font-size: 16px; /* prevents iOS zoom-on-focus */
    }

    /* Header gets a safe-area top pad for notched phones */
    .gfza-chatbot-root.gfza-mobile-open .gfza-chat-header {
        padding-top: max(14px, env(safe-area-inset-top));
    }

    /* Input area gets safe-area bottom pad */
    .gfza-chatbot-root.gfza-mobile-open .gfza-chat-footer {
        padding-bottom: max(7px, env(safe-area-inset-bottom));
    }
}
