/* ===================================================================
   Vertex AI Chat Panel — Wildanet Global Settings
   A premium, branded chat UI for the Google Vertex AI / Gemini backend
   =================================================================== */

/* ─── Chat Panel Container ─── */
#wgs-vertex-chat-panel {
    position: fixed;
    bottom: 100px;
    right: 24px;
    width: 400px;
    max-height: 560px;
    background: #ffffff;
    border-radius: 20px;
    box-shadow:
        0 12px 48px rgba(0, 0, 0, 0.15),
        0 4px 16px rgba(0, 0, 0, 0.08);
    display: flex;
    flex-direction: column;
    z-index: 99998;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px) scale(0.95);
    transition: opacity 0.3s ease, transform 0.3s ease, visibility 0.3s ease;
    overflow: hidden;
    font-family: 'Work Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

#wgs-vertex-chat-panel.wgs-chat-open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

/* ─── Chat Header ─── */
.wgs-chat-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 18px 20px;
    background: linear-gradient(135deg, #1A4560 0%, #123549 100%);
    color: #fff;
    flex-shrink: 0;
}

.wgs-chat-header-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.4);
    object-fit: cover;
    flex-shrink: 0;
}

.wgs-chat-header-info {
    flex: 1;
    min-width: 0;
}

.wgs-chat-header-name {
    font-size: 16px;
    font-weight: 600;
    line-height: 1.2;
}

.wgs-chat-header-status {
    font-size: 12px;
    opacity: 0.85;
    display: flex;
    align-items: center;
    gap: 5px;
}

.wgs-chat-header-status::before {
    content: '';
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #5fe8a0;
    display: inline-block;
}

.wgs-chat-close-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease;
    flex-shrink: 0;
    font-size: 18px;
    line-height: 1;
}

.wgs-chat-close-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* ─── Messages Container ─── */
.wgs-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px 16px 8px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-height: 280px;
    max-height: 380px;
    background: #f8fafb;
    scroll-behavior: smooth;
}

.wgs-chat-messages::-webkit-scrollbar {
    width: 5px;
}

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

.wgs-chat-messages::-webkit-scrollbar-thumb {
    background: #c5d0da;
    border-radius: 10px;
}

/* ─── Message Bubbles ─── */
.wgs-chat-msg {
    max-width: 82%;
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
    animation: wgs-msg-in 0.3s ease forwards;
}

@keyframes wgs-msg-in {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* User message */
.wgs-chat-msg.wgs-msg-user {
    align-self: flex-end;
    background: linear-gradient(135deg, #F58220, #E06B12);
    color: #fff;
    border-bottom-right-radius: 6px;
}

/* AI message */
.wgs-chat-msg.wgs-msg-ai {
    align-self: flex-start;
    background: #ffffff;
    color: #2d3748;
    border: 1px solid #e8edf2;
    border-bottom-left-radius: 6px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

/* Welcome message */
.wgs-chat-msg.wgs-msg-welcome {
    align-self: center;
    text-align: center;
    max-width: 90%;
    background: transparent;
    border: none;
    color: #718096;
    font-size: 13px;
    padding: 8px 0;
    box-shadow: none;
}

/* AI message markdown content */
.wgs-chat-msg.wgs-msg-ai p {
    margin: 0 0 8px;
}

.wgs-chat-msg.wgs-msg-ai p:last-child {
    margin-bottom: 0;
}

.wgs-chat-msg.wgs-msg-ai strong {
    font-weight: 600;
}

.wgs-chat-msg.wgs-msg-ai a {
    color: #F58220;
    text-decoration: underline;
}

.wgs-chat-msg.wgs-msg-ai ul,
.wgs-chat-msg.wgs-msg-ai ol {
    margin: 4px 0 8px 16px;
    padding: 0;
}

.wgs-chat-msg.wgs-msg-ai li {
    margin-bottom: 2px;
}

/* ─── Typing Indicator ─── */
.wgs-chat-typing {
    align-self: flex-start;
    display: none;
    align-items: center;
    gap: 4px;
    padding: 14px 18px;
    background: #ffffff;
    border: 1px solid #e8edf2;
    border-radius: 18px;
    border-bottom-left-radius: 6px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.wgs-chat-typing.wgs-typing-active {
    display: flex;
}

.wgs-typing-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #a0aec0;
    animation: wgs-typing-bounce 1.4s ease-in-out infinite;
}

.wgs-typing-dot:nth-child(2) {
    animation-delay: 0.16s;
}

.wgs-typing-dot:nth-child(3) {
    animation-delay: 0.32s;
}

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

/* ─── Input Area ─── */
.wgs-chat-input-area {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    border-top: 1px solid #e8edf2;
    background: #fff;
    flex-shrink: 0;
}

.wgs-chat-input {
    flex: 1;
    border: 1px solid #dde3ea;
    border-radius: 24px;
    padding: 10px 16px;
    font-size: 14px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    resize: none;
    max-height: 80px;
    min-height: 40px;
    line-height: 1.4;
    background: #f8fafb;
}

.wgs-chat-input:focus {
    border-color: #F58220;
    box-shadow: 0 0 0 3px rgba(245, 130, 32, 0.15);
    background: #fff;
}

.wgs-chat-input::placeholder {
    color: #a0aec0;
}

.wgs-chat-send-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, #F58220, #E06B12);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    flex-shrink: 0;
}

.wgs-chat-send-btn:hover {
    transform: scale(1.08);
    box-shadow: 0 3px 12px rgba(245, 130, 32, 0.4);
}

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

.wgs-chat-send-btn svg {
    width: 18px;
    height: 18px;
}

/* ─── Powered-by Footer ─── */
.wgs-chat-footer {
    text-align: center;
    padding: 6px 16px 10px;
    font-size: 11px;
    color: #a0aec0;
    background: #fff;
    border-top: 1px solid #f0f3f5;
}

/* ─── Error State ─── */
.wgs-chat-error {
    align-self: center;
    text-align: center;
    padding: 10px 16px;
    background: #fff5f5;
    color: #c53030;
    border-radius: 12px;
    font-size: 13px;
    border: 1px solid #feb2b2;
}

/* ─── Responsive: Mobile ─── */
@media (max-width: 480px) {
    #wgs-vertex-chat-panel {
        right: 0;
        bottom: 0;
        left: 0;
        width: 100%;
        max-height: 100vh;
        max-height: 100dvh;
        border-radius: 0;
    }

    .wgs-chat-messages {
        max-height: calc(100vh - 180px);
        max-height: calc(100dvh - 180px);
    }
}

@media (max-width: 768px) and (min-width: 481px) {
    #wgs-vertex-chat-panel {
        right: 12px;
        bottom: 90px;
        width: calc(100vw - 24px);
        max-width: 400px;
    }
}
