/* ==========================================================================
   GeekBrothers.Tech - AI Chatbot Widget Styles
   Version: 1.0
   Description: Floating chatbot widget for MSP website. Uses brand variables
                defined in the main style.css (:root scope).
   ========================================================================== */


/* --------------------------------------------------------------------------
   1. KEYFRAME ANIMATIONS
   -------------------------------------------------------------------------- */

/* Trigger button entrance bounce */
@keyframes gb-chat-bounce {
    0%   { transform: scale(0); opacity: 0; }
    50%  { transform: scale(1.15); }
    70%  { transform: scale(0.92); }
    100% { transform: scale(1); opacity: 1; }
}

/* Chat window slide-up reveal */
@keyframes gb-chat-slide-up {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.96);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Typing indicator dot bounce */
@keyframes gb-typing-dot {
    0%, 60%, 100% { transform: translateY(0); }
    30%           { transform: translateY(-6px); }
}

/* Message fade-in */
@keyframes gb-chat-fade-in {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Notification badge pulse */
@keyframes gb-badge-pulse {
    0%   { transform: scale(1); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.6); }
    70%  { transform: scale(1); box-shadow: 0 0 0 8px rgba(239, 68, 68, 0); }
    100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}


/* --------------------------------------------------------------------------
   2. CHATBOT WRAPPER
   -------------------------------------------------------------------------- */

.gb-chatbot {
    position: fixed;
    bottom: 0;
    right: 0;
    z-index: 9999;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}


/* --------------------------------------------------------------------------
   3. TRIGGER BUTTON (Floating Action Button)
   -------------------------------------------------------------------------- */

.gb-chat-trigger {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--gradient-1);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--white);
    font-size: 24px;
    box-shadow:
        0 4px 14px rgba(184, 134, 11, 0.4),
        0 2px 6px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
    z-index: 9999;
    animation: gb-chat-bounce 0.6s ease-out both;
}

.gb-chat-trigger:hover {
    transform: translateY(-2px);
    box-shadow:
        0 8px 24px rgba(184, 134, 11, 0.5),
        0 4px 10px rgba(0, 0, 0, 0.12);
}

.gb-chat-trigger:active {
    transform: translateY(0) scale(0.95);
}

.gb-chat-trigger svg,
.gb-chat-trigger i {
    width: 26px;
    height: 26px;
    transition: transform 0.3s ease;
}

/* When chat is closed: show chat bubble, hide X */
.gb-chatbot:not(.open) .gb-chat-trigger .gb-chat-close-icon {
    display: none;
}

/* When chat is open: show X, hide chat bubble */
.gb-chatbot.open .gb-chat-trigger .gb-chat-icon {
    display: none;
}


/* --------------------------------------------------------------------------
   4. NOTIFICATION BADGE
   -------------------------------------------------------------------------- */

.gb-chat-badge {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 12px;
    height: 12px;
    background: var(--danger, #ef4444);
    border-radius: 50%;
    border: 2px solid var(--white);
    animation: gb-badge-pulse 2s ease-in-out infinite;
    pointer-events: none;
    font-size: 0;
}


/* --------------------------------------------------------------------------
   5. CHAT WINDOW
   -------------------------------------------------------------------------- */

.gb-chat-window {
    position: fixed;
    bottom: 96px;
    right: 24px;
    width: 440px;
    height: 620px;
    max-height: calc(100vh - 100px);
    background: var(--white);
    border-radius: 24px;
    box-shadow:
        0 20px 60px rgba(0, 0, 0, 0.15),
        0 8px 24px rgba(0, 0, 0, 0.08);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 9998;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

/* Closed state */
.gb-chatbot:not(.open) .gb-chat-window {
    opacity: 0;
    transform: translateY(20px);
    pointer-events: none;
    visibility: hidden;
}

/* Open state */
.gb-chatbot.open .gb-chat-window {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
    visibility: visible;
    animation: gb-chat-slide-up 0.35s ease-out;
}


/* --------------------------------------------------------------------------
   6. CHAT HEADER
   -------------------------------------------------------------------------- */

.gb-chat-header {
    background: var(--gradient-2);
    padding: 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-radius: 24px 24px 0 0;
    flex-shrink: 0;
}

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

.gb-chat-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--gradient-1);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--white);
    font-weight: 700;
    font-size: 14px;
    flex-shrink: 0;
    letter-spacing: 0.5px;
}

.gb-chat-header-text {
    display: flex;
    flex-direction: column;
}

.gb-chat-header-text h4 {
    color: var(--white);
    font-size: 15px;
    font-weight: 600;
    margin: 0;
    line-height: 1.3;
}

.gb-chat-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.7);
    margin: 0;
}

.gb-chat-status::before {
    content: '';
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--success, #10b981);
    flex-shrink: 0;
}

.gb-chat-status.offline::before {
    background: var(--gray);
}

.gb-chat-status.checking::before {
    background: #f59e0b;
    animation: statusPulse 1s ease-in-out infinite;
}

.gb-chat-status.error::before {
    background: #ef4444;
}

@keyframes statusPulse {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.35; }
}

.gb-chat-close {
    background: none;
    border: none;
    color: var(--white);
    font-size: 20px;
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    transition: all 0.3s ease;
    opacity: 0.8;
    width: 32px;
    height: 32px;
}

.gb-chat-close:hover {
    opacity: 1;
    color: var(--primary);
    background: rgba(255, 255, 255, 0.1);
}


/* --------------------------------------------------------------------------
   7. MESSAGES AREA
   -------------------------------------------------------------------------- */

.gb-chat-messages {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Custom scrollbar */
.gb-chat-messages::-webkit-scrollbar {
    width: 5px;
}

.gb-chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.gb-chat-messages::-webkit-scrollbar-thumb {
    background: rgba(100, 116, 139, 0.25);
    border-radius: 10px;
}

.gb-chat-messages::-webkit-scrollbar-thumb:hover {
    background: rgba(100, 116, 139, 0.4);
}

/* Firefox scrollbar */
.gb-chat-messages {
    scrollbar-width: thin;
    scrollbar-color: rgba(100, 116, 139, 0.25) transparent;
}


/* --------------------------------------------------------------------------
   8. MESSAGE BUBBLES
   -------------------------------------------------------------------------- */

.gb-chat-message {
    display: flex;
    flex-direction: column;
    max-width: 82%;
    animation: gb-chat-fade-in 0.3s ease-out both;
}

/* Bot messages - left aligned */
.gb-chat-message.bot {
    align-self: flex-start;
}

.gb-chat-message.bot .message-text {
    background: var(--light);
    color: var(--dark, #1e293b);
    border-radius: 18px 18px 18px 4px;
    padding: 12px 16px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* User messages - right aligned */
.gb-chat-message.user {
    align-self: flex-end;
}

.gb-chat-message.user .message-text {
    background: var(--gradient-1);
    color: var(--white);
    border-radius: 18px 18px 4px 18px;
    padding: 12px 16px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* Timestamp */
.gb-chat-message .message-time {
    font-size: 11px;
    color: var(--gray);
    margin-top: 4px;
    padding: 0 4px;
}

.gb-chat-message.user .message-time {
    text-align: right;
}

.gb-chat-message.bot .message-time {
    text-align: left;
}

/* Links inside bot messages */
.gb-chat-message.bot .message-text a {
    color: var(--primary);
    text-decoration: underline;
    text-underline-offset: 2px;
    transition: color 0.3s ease;
}

.gb-chat-message.bot .message-text a:hover {
    color: var(--primary-dark);
}

/* Links inside user messages */
.gb-chat-message.user .message-text a {
    color: var(--white);
    text-decoration: underline;
    text-underline-offset: 2px;
}


/* --------------------------------------------------------------------------
   9. TYPING INDICATOR
   -------------------------------------------------------------------------- */

.gb-chat-typing {
    display: none;
    align-items: center;
    gap: 4px;
    padding: 12px 16px;
    background: var(--light);
    border-radius: 18px 18px 18px 4px;
    align-self: flex-start;
    max-width: 70px;
    flex-shrink: 0;
}

.gb-chat-typing.visible {
    display: flex;
}

.gb-chat-typing span {
    display: block;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--primary);
    animation: gb-typing-dot 1.2s ease-in-out infinite;
}

.gb-chat-typing span:nth-child(2) {
    animation-delay: 0.15s;
}

.gb-chat-typing span:nth-child(3) {
    animation-delay: 0.3s;
}


/* --------------------------------------------------------------------------
   10. SUGGESTION CHIPS
   -------------------------------------------------------------------------- */

.gb-chat-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 12px 20px;
    border-top: 1px solid var(--light);
    flex-shrink: 0;
}

.gb-suggestion {
    display: inline-flex;
    align-items: center;
    padding: 8px 16px;
    border-radius: 100px;
    border: 1.5px solid var(--primary);
    color: var(--primary);
    background: var(--white);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap;
    line-height: 1.3;
}

.gb-suggestion:hover {
    background: var(--primary);
    color: var(--white);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(184, 134, 11, 0.3);
}

.gb-suggestion:active {
    transform: translateY(0);
}


/* --------------------------------------------------------------------------
   11. INPUT AREA
   -------------------------------------------------------------------------- */

.gb-chat-input-area {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    padding: 16px 20px;
    border-top: 1px solid var(--light);
    border-radius: 0 0 24px 24px;
    flex-shrink: 0;
    background: var(--white);
}

.gb-chat-input {
    flex: 1 1 auto;
    border: none;
    outline: none;
    resize: none;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: var(--dark, #1e293b);
    background: var(--light);
    border-radius: 12px;
    padding: 10px 16px;
    max-height: 100px;
    min-height: 42px;
    overflow-y: auto;
}

.gb-chat-input::placeholder {
    color: var(--gray);
    opacity: 0.7;
}

.gb-chat-input:focus {
    background: #f1f5f9;
}

.gb-chat-send {
    width: 44px;
    height: 44px;
    min-width: 44px;
    border-radius: 50%;
    background: var(--gradient-1);
    border: none;
    color: var(--white);
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.gb-chat-send:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 14px rgba(184, 134, 11, 0.4);
}

.gb-chat-send:active {
    transform: scale(0.95);
}

.gb-chat-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.gb-chat-send svg,
.gb-chat-send i {
    width: 20px;
    height: 20px;
}


/* --------------------------------------------------------------------------
   12. PRIVACY BADGE
   -------------------------------------------------------------------------- */

.gb-chat-privacy {
    font-size: 11px;
    color: var(--gray);
    text-align: center;
    padding: 8px 20px;
    flex-shrink: 0;
    border-top: 1px solid var(--light);
    background: var(--white);
    border-radius: 0 0 24px 24px;
}

/* When privacy sits below input area, remove double border-radius */
.gb-chat-input-area + .gb-chat-privacy {
    border-radius: 0 0 24px 24px;
}

.gb-chat-input-area:last-child {
    border-radius: 0 0 24px 24px;
}

/* If privacy is the last element, it gets the bottom radius */
.gb-chat-privacy:last-child {
    border-radius: 0 0 24px 24px;
}

/* Adjust input area when privacy badge follows it */
.gb-chat-input-area:not(:last-child) {
    border-radius: 0;
}


/* --------------------------------------------------------------------------
   13. OPEN / CLOSED STATE OVERRIDES
   -------------------------------------------------------------------------- */

/* Icon toggle is handled above in section 3 (chat trigger) */

/* Hide badge when chat is open */
.gb-chatbot.open .gb-chat-badge {
    display: none;
}


/* --------------------------------------------------------------------------
   14. EMPTY STATE / WELCOME
   -------------------------------------------------------------------------- */

.gb-chat-welcome {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 32px 24px;
    gap: 12px;
}

.gb-chat-welcome-icon {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--gradient-1);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--white);
    font-size: 24px;
    margin-bottom: 4px;
}

.gb-chat-welcome h5 {
    font-size: 16px;
    font-weight: 600;
    color: var(--dark, #1e293b);
    margin: 0;
}

.gb-chat-welcome p {
    font-size: 13px;
    color: var(--gray);
    margin: 0;
    max-width: 280px;
    line-height: 1.5;
}


/* --------------------------------------------------------------------------
   15. ERROR STATE
   -------------------------------------------------------------------------- */

.gb-chat-error {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: #fef2f2;
    color: var(--danger, #ef4444);
    border-radius: 12px;
    font-size: 13px;
    line-height: 1.4;
    align-self: stretch;
    animation: gb-chat-fade-in 0.3s ease-out both;
}

.gb-chat-error svg {
    flex-shrink: 0;
    width: 16px;
    height: 16px;
}


/* --------------------------------------------------------------------------
   16. MOBILE RESPONSIVE (max-width: 768px)
   -------------------------------------------------------------------------- */

@media (max-width: 768px) {

    /* Trigger button adjustments */
    .gb-chat-trigger {
        bottom: 16px;
        right: 16px;
        width: 56px;
        height: 56px;
        font-size: 22px;
    }

    /* Chat window becomes full-screen */
    .gb-chatbot.open .gb-chat-window {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        height: 100%;
        max-height: 100%;
        border-radius: 0;
        z-index: 10000;
    }

    /* Header loses top border-radius on mobile */
    .gb-chat-header {
        border-radius: 0;
        padding: 16px;
    }

    /* Safe area padding for notched devices */
    .gb-chat-header {
        padding-top: max(16px, env(safe-area-inset-top));
    }

    .gb-chat-input-area {
        padding-bottom: max(16px, env(safe-area-inset-bottom));
    }

    .gb-chat-privacy:last-child {
        padding-bottom: max(8px, env(safe-area-inset-bottom));
        border-radius: 0;
    }

    /* Suggestions become horizontally scrollable */
    .gb-chat-suggestions {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        padding: 12px 16px;
        gap: 8px;
        scrollbar-width: none;
    }

    .gb-chat-suggestions::-webkit-scrollbar {
        display: none;
    }

    .gb-suggestion {
        flex-shrink: 0;
    }

    /* Messages padding */
    .gb-chat-messages {
        padding: 16px;
        gap: 12px;
    }

    /* Input area adjustments */
    .gb-chat-input-area {
        padding: 12px 16px;
        border-radius: 0;
    }

    /* Hide trigger when chat is open on mobile */
    .gb-chatbot.open .gb-chat-trigger {
        display: none;
    }
}


/* --------------------------------------------------------------------------
   17. SMALL MOBILE (max-width: 380px)
   -------------------------------------------------------------------------- */

@media (max-width: 380px) {
    .gb-chat-header {
        padding: 14px 12px;
    }

    .gb-chat-avatar {
        width: 36px;
        height: 36px;
        font-size: 12px;
    }

    .gb-chat-header-text h4 {
        font-size: 14px;
    }

    .gb-chat-messages {
        padding: 12px;
    }

    .gb-chat-message {
        max-width: 88%;
    }

    .gb-chat-input-area {
        padding: 10px 12px;
        gap: 8px;
    }

    .gb-chat-send {
        width: 40px;
        height: 40px;
        min-width: 40px;
    }
}


/* --------------------------------------------------------------------------
   18. REDUCED MOTION PREFERENCE
   -------------------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
    .gb-chat-trigger {
        animation: none;
    }

    .gb-chatbot.open .gb-chat-window {
        animation: none;
    }

    .gb-chat-message {
        animation: none;
    }

    .gb-chat-typing span {
        animation: none;
    }

    .gb-chat-badge {
        animation: none;
    }

    .gb-chat-trigger,
    .gb-chat-close,
    .gb-suggestion,
    .gb-chat-send,
    .gb-chat-window {
        transition: none;
    }
}


/* --------------------------------------------------------------------------
   19. PRINT STYLES
   -------------------------------------------------------------------------- */

@media print {
    .gb-chatbot {
        display: none !important;
    }
}
