/* ============================================
   GILEAD ADVISORY — AI Chatbot Widget Styles
   ============================================ */

/* === Chat Widget Container === */
.chat-widget {
    position: fixed;
    bottom: 30px;
    right: 30px;
    z-index: 1000;
    font-family: var(--font-he);
}

html.ltr .chat-widget {
    font-family: var(--font-en);
}

/* === Chat Bubble (Toggle Button) === */
.chat-bubble {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: var(--gradient-1);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 20px rgba(0, 212, 255, 0.3);
    transition: var(--transition);
    position: relative;
}

.chat-bubble:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 30px rgba(0, 212, 255, 0.5);
}

.chat-bubble-icon,
.chat-bubble-close {
    position: absolute;
    color: white;
    font-size: 1.5rem;
    transition: var(--transition);
}

.chat-bubble-close {
    opacity: 0;
    transform: rotate(-90deg) scale(0.5);
}

.chat-widget.open .chat-bubble-icon {
    opacity: 0;
    transform: rotate(90deg) scale(0.5);
}

.chat-widget.open .chat-bubble-close {
    opacity: 1;
    transform: rotate(0) scale(1);
}

/* Notification Badge */
.chat-bubble-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #EF4444;
    color: white;
    font-size: 0.7rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transform: scale(0);
    transition: var(--transition);
}

.chat-bubble-badge.visible {
    opacity: 1;
    transform: scale(1);
}

/* === Chat Window === */
.chat-window {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 380px;
    max-height: 520px;
    background: rgba(17, 24, 39, 0.97);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    overflow: hidden;

    /* Animation */
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px) scale(0.95);
    transform-origin: bottom right;
    transition: opacity 0.3s ease, visibility 0.3s ease, transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.chat-widget.open .chat-window {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

/* === Chat Header === */
.chat-header {
    padding: 16px 20px;
    background: linear-gradient(135deg, rgba(0, 212, 255, 0.08), rgba(124, 58, 237, 0.08));
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

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

.chat-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--gradient-1);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.1rem;
    position: relative;
    flex-shrink: 0;
}

.chat-status-dot {
    position: absolute;
    bottom: 1px;
    right: 1px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #22C55E;
    border: 2px solid rgba(17, 24, 39, 0.97);
}

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

.chat-header-text strong {
    color: var(--text);
    font-size: 0.95rem;
    font-weight: 600;
}

.chat-header-text span {
    font-size: 0.78rem;
    color: var(--text-secondary);
}

.chat-close-btn {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    flex-shrink: 0;
}

.chat-close-btn:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text);
}

/* === Messages Area === */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-height: 280px;
    max-height: 350px;
}

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

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

.chat-messages::-webkit-scrollbar-thumb {
    background: var(--surface-3);
    border-radius: 4px;
}

/* === Message Bubbles === */
.chat-msg {
    max-width: 85%;
    padding: 12px 16px;
    border-radius: var(--radius-md);
    font-size: 0.9rem;
    line-height: 1.6;
    animation: msg-appear 0.3s ease;
    word-wrap: break-word;
}

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

/* Assistant messages */
.chat-msg.assistant {
    align-self: flex-start;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    color: var(--text);
    border-bottom-right-radius: 4px;
}

html.ltr .chat-msg.assistant {
    border-bottom-right-radius: var(--radius-md);
    border-bottom-left-radius: 4px;
}

/* User messages */
.chat-msg.user {
    align-self: flex-end;
    background: var(--gradient-1);
    color: white;
    border-bottom-left-radius: 4px;
}

html.ltr .chat-msg.user {
    border-bottom-left-radius: var(--radius-md);
    border-bottom-right-radius: 4px;
}

/* System confirmation messages */
.chat-msg.system {
    align-self: center;
    max-width: 90%;
    background: rgba(34, 197, 94, 0.1);
    border: 1px solid rgba(34, 197, 94, 0.3);
    color: #22C55E;
    font-size: 0.82rem;
    text-align: center;
    padding: 8px 16px;
    border-radius: var(--radius-md);
    animation: msg-appear 0.3s ease;
}

/* === Typing Indicator === */
.chat-typing {
    display: flex;
    gap: 5px;
    padding: 14px 18px;
    align-self: flex-start;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    border-bottom-right-radius: 4px;
    animation: msg-appear 0.3s ease;
}

html.ltr .chat-typing {
    border-bottom-right-radius: var(--radius-md);
    border-bottom-left-radius: 4px;
}

.chat-typing span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--accent);
    animation: typing-bounce 1.4s infinite;
}

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

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

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

/* === Chat Input === */
.chat-input-container {
    padding: 16px;
    border-top: 1px solid var(--border);
    background: rgba(0, 0, 0, 0.2);
    flex-shrink: 0;
}

.chat-input-form {
    display: flex;
    gap: 8px;
    align-items: center;
}

.chat-input {
    flex: 1;
    padding: 12px 16px;
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    color: var(--text);
    font-family: inherit;
    font-size: 0.9rem;
    outline: none;
    transition: var(--transition);
}

.chat-input:focus {
    border-color: var(--accent);
    background: rgba(0, 212, 255, 0.03);
}

.chat-input::placeholder {
    color: var(--text-secondary);
    opacity: 0.5;
}

.chat-send-btn {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-md);
    background: var(--gradient-1);
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    transition: var(--transition);
    flex-shrink: 0;
}

.chat-send-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 0 20px rgba(0, 212, 255, 0.3);
}

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

/* === Powered By Footer === */
.chat-powered {
    padding: 8px 16px;
    text-align: center;
    font-size: 0.7rem;
    color: var(--text-secondary);
    opacity: 0.5;
    border-top: 1px solid var(--border);
    background: rgba(0, 0, 0, 0.1);
    flex-shrink: 0;
}

.chat-powered a {
    color: var(--accent);
    text-decoration: none;
}

/* === Responsive === */
@media (max-width: 480px) {
    .chat-widget {
        bottom: 20px;
        right: 20px;
    }

    .chat-widget.open .chat-window {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        top: auto;
        width: 100%;
        max-height: 50vh;
        border-radius: var(--radius-lg) var(--radius-lg) 0 0;
        z-index: 10000;
    }

    .chat-messages {
        max-height: none;
        min-height: 120px;
        flex: 1;
    }

    .chat-bubble {
        width: 52px;
        height: 52px;
    }

    .chat-bubble-icon,
    .chat-bubble-close {
        font-size: 1.2rem;
    }
}

@media (min-width: 481px) and (max-width: 768px) {
    .chat-bubble {
        width: 56px;
        height: 56px;
    }

    .chat-bubble-icon,
    .chat-bubble-close {
        font-size: 1.3rem;
    }

    .chat-window {
        width: 340px;
        bottom: 72px;
    }
}
