/* =========================================
   Zyrix AI Chatbot — Premium Dark UI
   ========================================= */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
    --zyrix-primary:        #5b6ef5;
    --zyrix-primary-dark:   #4557e8;
    --zyrix-accent:         #7c3aed;

    /* Gradient used on header & button */
    --zyrix-grad:           linear-gradient(135deg, #4557e8 0%, #7c3aed 100%);
    --zyrix-grad-hover:     linear-gradient(135deg, #3a48d0 0%, #6d28d9 100%);

    /* Surfaces */
    --zyrix-bg:             #0d1117;
    --zyrix-surface:        #161b27;
    --zyrix-surface2:       #1c2333;
    --zyrix-border:         rgba(255,255,255,0.08);
    --zyrix-border-hover:   rgba(255,255,255,0.14);

    /* Text */
    --zyrix-text:           #e6edf3;
    --zyrix-muted:          #7d8590;
    --zyrix-muted2:         #4b5563;

    /* Bubbles */
    --zyrix-user-bg:        var(--zyrix-grad);
    --zyrix-user-text:      #ffffff;
    --zyrix-bot-bg:         #1c2333;
    --zyrix-bot-text:       #e6edf3;
    --zyrix-bot-border:     rgba(255,255,255,0.07);

    /* Shadow */
    --zyrix-shadow:
        0 4px 6px rgba(0,0,0,0.3),
        0 24px 60px rgba(0,0,0,0.6),
        0 0 0 1px rgba(255,255,255,0.05);

    --zyrix-btn-shadow:
        0 4px 20px rgba(85,110,245,0.5);
}

/* =========================================
   Main Container
   ========================================= */

#zyrix-chatbot {
    position: fixed;
    right: 24px;
    bottom: 24px;
    z-index: 999999;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    color: var(--zyrix-text);
}

/* =========================================
   Floating Button
   ========================================= */

.zyrix-chat-button {
    width: 50px;
    height: 50px;
    border: none;
    border-radius: 50%;
    background: var(--zyrix-grad);
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: var(--zyrix-btn-shadow);
    transition: transform 0.25s cubic-bezier(0.34,1.56,0.64,1),
                box-shadow 0.25s ease;
    position: relative;
    overflow: hidden;
}

/* Animated pulse ring */
.zyrix-chat-button::before {
    content: '';
    position: absolute;
    inset: -4px;
    border-radius: 50%;
    background: var(--zyrix-grad);
    opacity: 0;
    animation: zyrixPulse 2.5s ease-out infinite;
    z-index: -1;
}

@keyframes zyrixPulse {
    0%   { transform: scale(1);   opacity: 0.5; }
    100% { transform: scale(1.65); opacity: 0; }
}

.zyrix-chat-button:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 30px rgba(85,110,245,0.7);
}

.zyrix-chat-button svg {
    width: 22px;
    height: 22px;
    position: relative;
    z-index: 1;
    transition: transform 0.2s ease, opacity 0.2s ease;
}

/* =========================================
   Chat Window
   ========================================= */

.zyrix-chat-window {
    position: absolute;
    right: 0;
    bottom: 78px;
    width: 380px;
    height: 590px;
    background: var(--zyrix-bg);
    border: 1px solid var(--zyrix-border);
    border-radius: 20px;
    box-shadow: var(--zyrix-shadow);
    display: none;
    flex-direction: column;
    overflow: hidden;
    transform-origin: bottom right;
    /* open animation is handled via .open class */
}

.zyrix-chat-window.open {
    display: flex;
    animation: zyrixSlideIn 0.3s cubic-bezier(0.34,1.3,0.64,1) forwards;
}

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

/* =========================================
   Header
   ========================================= */

.zyrix-chat-header {
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--zyrix-grad);
    position: relative;
    overflow: hidden;
    flex-shrink: 0;
}

/* Subtle shimmer overlay on header */
.zyrix-chat-header::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,0.06) 50%, transparent 100%);
    pointer-events: none;
}

.zyrix-chat-header-left {
    display: flex;
    align-items: center;
    gap: 11px;
    position: relative;
    z-index: 1;
}

.zyrix-bot-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: rgba(255,255,255,0.18);
    border: 2px solid rgba(255,255,255,0.25);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.25);
    flex-shrink: 0;
}

/* Online dot */
.zyrix-bot-avatar::after {
    content: '';
    position: absolute;
    width: 10px;
    height: 10px;
    background: #22c55e;
    border: 2px solid #4557e8;
    border-radius: 50%;
    bottom: 0;
    right: 0;
    /* relative to avatar — wrapper must be relative */
}

.zyrix-chat-header-left > .zyrix-bot-avatar {
    position: relative;
}

.zyrix-header-info {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.zyrix-header-title {
    font-size: 15px;
    font-weight: 700;
    color: #ffffff;
    letter-spacing: -0.01em;
}

.zyrix-header-subtitle {
    font-size: 11.5px;
    color: rgba(255,255,255,0.75);
    font-weight: 400;
}

/* Status dot row */
.zyrix-header-status {
    display: flex;
    align-items: center;
    gap: 5px;
    margin-top: 1px;
}

.zyrix-status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #4ade80;
    animation: zyrixBlink 2s ease-in-out infinite;
}

@keyframes zyrixBlink {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.4; }
}

.zyrix-status-text {
    font-size: 11px;
    color: rgba(255,255,255,0.75);
}

/* =========================================
   Header Buttons
   ========================================= */

.zyrix-header-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    position: relative;
    z-index: 1;
}

.zyrix-header-button {
    width: 32px;
    height: 32px;
    border: none;
    background: rgba(255,255,255,0.12);
    color: #ffffff;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    transition: background 0.18s ease, transform 0.15s ease;
    border: 1px solid rgba(255,255,255,0.1);
}

.zyrix-header-button:hover {
    background: rgba(255,255,255,0.22);
    transform: scale(1.05);
}

.zyrix-header-button:active {
    transform: scale(0.95);
}

/* =========================================
   Messages Area
   ========================================= */

.zyrix-messages {
    flex: 1;
    padding: 20px 16px 12px;
    overflow-y: auto;
    background: var(--zyrix-bg);
    display: flex;
    flex-direction: column;
    gap: 4px;
    /* Custom scrollbar */
    scrollbar-width: thin;
    scrollbar-color: var(--zyrix-muted2) transparent;
}

.zyrix-messages::-webkit-scrollbar {
    width: 4px;
}

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

.zyrix-messages::-webkit-scrollbar-thumb {
    background: var(--zyrix-muted2);
    border-radius: 4px;
}

/* =========================================
   Message
   ========================================= */

.zyrix-message {
    display: flex;
    align-items: flex-end;
    margin-bottom: 8px;
    animation: zyrixFadeUp 0.22s ease forwards;
}

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

.zyrix-message.user {
    justify-content: flex-end;
}

.zyrix-message.bot {
    justify-content: flex-start;
    gap: 8px;
}

/* =========================================
   Bot Avatar (small icon left of bubble)
   ========================================= */

.zyrix-message-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--zyrix-surface2);
    border: 1px solid var(--zyrix-border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    flex-shrink: 0;
    /* Align avatar bottom with bubble bottom */
    align-self: flex-end;
    margin-bottom: 2px;
}

.zyrix-message-content {
    max-width: 72%;
    padding: 10px 14px;
    border-radius: 18px;
    font-size: 13.5px;
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-word;
    font-weight: 400;
    /* Ensure short text still renders as a proper pill */
    display: inline-block;
}

.zyrix-message.user .zyrix-message-content {
    background: var(--zyrix-grad);
    color: var(--zyrix-user-text);
    border-bottom-right-radius: 5px;
    box-shadow: 0 2px 12px rgba(85,110,245,0.35);
}

.zyrix-message.bot .zyrix-message-content {
    background: var(--zyrix-bot-bg);
    color: var(--zyrix-bot-text);
    border-bottom-left-radius: 5px;
    border: 1px solid var(--zyrix-bot-border);
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

/* =========================================
   Date / Time divider
   ========================================= */

.zyrix-divider {
    text-align: center;
    font-size: 10.5px;
    color: var(--zyrix-muted);
    margin: 6px 0 10px;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

/* =========================================
   Input Area
   ========================================= */

.zyrix-input-area {
    padding: 12px 14px;
    border-top: 1px solid var(--zyrix-border);
    background: var(--zyrix-surface);
    display: flex;
    align-items: center;
    gap: 10px;
}

.zyrix-input {
    flex: 1;
    min-width: 0;
    border: 1px solid var(--zyrix-border);
    border-radius: 14px;
    padding: 11px 14px;
    background: var(--zyrix-surface2);
    color: var(--zyrix-text);
    outline: none;
    font-size: 13.5px;
    font-family: inherit;
    resize: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    line-height: 1.4;
}

.zyrix-input::placeholder {
    color: var(--zyrix-muted);
}

.zyrix-input:focus {
    border-color: var(--zyrix-primary);
    box-shadow: 0 0 0 3px rgba(85,110,245,0.18);
}

.zyrix-send-button {
    width: 42px;
    height: 42px;
    flex-shrink: 0;
    border: none;
    border-radius: 12px;
    background: var(--zyrix-grad);
    color: #ffffff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    transition: transform 0.2s cubic-bezier(0.34,1.56,0.64,1),
                box-shadow 0.2s ease,
                opacity 0.2s ease;
    box-shadow: 0 2px 12px rgba(85,110,245,0.4);
}

.zyrix-send-button:hover {
    transform: scale(1.08);
    box-shadow: 0 4px 18px rgba(85,110,245,0.6);
}

.zyrix-send-button:active {
    transform: scale(0.95);
}

.zyrix-send-button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* =========================================
   Typing Indicator
   ========================================= */

.zyrix-typing {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 6px 4px;
}

.zyrix-typing span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--zyrix-primary);
    opacity: 0.3;
    animation: zyrixBounce 1.4s ease-in-out infinite;
}

.zyrix-typing span:nth-child(2) { animation-delay: 0.18s; }
.zyrix-typing span:nth-child(3) { animation-delay: 0.36s; }

@keyframes zyrixBounce {
    0%, 60%, 100% {
        opacity: 0.3;
        transform: translateY(0);
    }
    30% {
        opacity: 1;
        transform: translateY(-4px);
    }
}



/* =========================================
   Mobile
   ========================================= */

@media (max-width: 600px) {

    #zyrix-chatbot {
        right: 16px;
        bottom: 16px;
    }

    .zyrix-chat-window {
        position: fixed;
        right: 10px;
        left: 10px;
        bottom: 88px;
        width: auto;
        height: calc(100dvh - 110px);
        max-height: 700px;
        border-radius: 18px;
    }

    .zyrix-chat-button {
        width: 50px;
        height: 50px;
        transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }
    
    .zyrix-chat-button svg {
        width: 24px;
        height: 24px;
        transition: opacity 0.3s ease, transform 0.3s ease;
    }
}