/* ============================================
   ISG AI Platform - Chat Widget Styles
   Epic Floating Chat Interface
   ============================================ */

/* === Chat Widget Container === */
.chat-widget {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
}

/* === Toggle Button === */
.chat-toggle {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: var(--gradient-primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow:
        0 4px 20px rgba(99, 102, 241, 0.4),
        0 0 40px rgba(99, 102, 241, 0.2);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.chat-toggle::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(45deg,
            transparent 40%,
            rgba(255, 255, 255, 0.2) 50%,
            transparent 60%);
    transform: translateX(-100%);
    transition: transform 0.6s ease;
}

.chat-toggle:hover::before {
    transform: translateX(100%);
}

.chat-toggle:hover {
    transform: scale(1.1);
    box-shadow:
        0 6px 30px rgba(99, 102, 241, 0.5),
        0 0 60px rgba(99, 102, 241, 0.3);
}

.chat-toggle:active {
    transform: scale(0.95);
}

.chat-icon-open,
.chat-icon-close {
    transition: all 0.3s ease;
}

.chat-icon-close {
    position: absolute;
    opacity: 0;
    transform: rotate(-90deg) scale(0);
}

.chat-widget.open .chat-icon-open {
    opacity: 0;
    transform: rotate(90deg) scale(0);
}

.chat-widget.open .chat-icon-close {
    opacity: 1;
    transform: rotate(0) scale(1);
}

.chat-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: var(--accent);
    color: white;
    font-size: 0.625rem;
    font-weight: 700;
    padding: 4px 6px;
    border-radius: 100px;
    animation: badgePulse 2s ease-in-out infinite;
}

@keyframes badgePulse {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.1);
    }
}

/* === Chat Window === */
.chat-window {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 400px;
    height: 560px;
    background: var(--dark-card);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px) scale(0.95);
    transform-origin: bottom right;
    transition: all 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 {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    color: white;
}

.chat-header-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.chat-avatar {
    width: 44px;
    height: 44px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.chat-header-text {
    display: flex;
    flex-direction: column;
}

.chat-name {
    font-weight: 600;
    font-size: 1rem;
}

.chat-status {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.75rem;
    opacity: 0.9;
}

.status-dot {
    width: 8px;
    height: 8px;
    background: #4ade80;
    border-radius: 50%;
    animation: pulse 2s ease-in-out infinite;
}

.chat-close {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    transition: var(--transition);
}

.chat-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* === Chat Body === */
.chat-body {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    background: var(--dark);
}

.chat-body::-webkit-scrollbar {
    width: 6px;
}

.chat-body::-webkit-scrollbar-track {
    background: transparent;
}

.chat-body::-webkit-scrollbar-thumb {
    background: var(--glass-border);
    border-radius: 3px;
}

/* === Welcome Message === */
.chat-welcome {
    text-align: center;
    padding: 2rem 1rem;
}

.welcome-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.chat-welcome h3 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.chat-welcome p {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 1.5rem;
}

.welcome-suggestions {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.welcome-suggestions button {
    background: var(--glass);
    border: 1px solid var(--glass-border);
    color: var(--text);
    padding: 0.75rem 1rem;
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    text-align: left;
    transition: var(--transition);
}

.welcome-suggestions button:hover {
    background: rgba(99, 102, 241, 0.1);
    border-color: var(--primary);
}

/* === Chat Messages === */
.chat-msg {
    display: flex;
    gap: 0.75rem;
    animation: messageIn 0.3s ease-out;
}

@keyframes messageIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.chat-msg.bot {
    align-self: flex-start;
}

.chat-msg.user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.msg-avatar {
    width: 32px;
    height: 32px;
    background: var(--glass);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    flex-shrink: 0;
}

.chat-msg.user .msg-avatar {
    background: var(--primary);
}

.msg-bubble {
    max-width: 280px;
    background: var(--glass);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    padding: 0.875rem 1rem;
}

.chat-msg.user .msg-bubble {
    background: var(--primary);
    border-color: var(--primary);
}

.msg-text {
    font-size: 0.9rem;
    line-height: 1.5;
    color: var(--text);
}

.msg-text p {
    margin-bottom: 0.5rem;
}

.msg-text p:last-child {
    margin-bottom: 0;
}

.msg-text ul {
    margin: 0.5rem 0;
    padding-left: 1.25rem;
}

.msg-text li {
    margin-bottom: 0.25rem;
}

.msg-text strong {
    color: var(--primary-light);
}

.chat-msg.user .msg-text strong {
    color: white;
}

.msg-time {
    font-size: 0.7rem;
    color: var(--text-dim);
    margin-top: 0.375rem;
}

.chat-msg.user .msg-time {
    color: rgba(255, 255, 255, 0.7);
}

/* === References === */
.msg-refs {
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--glass-border);
}

.msg-refs-title {
    font-size: 0.7rem;
    color: var(--text-dim);
    margin-bottom: 0.375rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.msg-ref {
    display: inline-block;
    background: rgba(99, 102, 241, 0.2);
    color: var(--primary-light);
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    margin-right: 0.25rem;
    margin-bottom: 0.25rem;
}

/* === Typing Indicator === */
.typing-indicator {
    display: flex;
    gap: 0.75rem;
    align-items: flex-start;
}

.typing-dots {
    background: var(--glass);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    padding: 1rem;
    display: flex;
    gap: 4px;
}

.typing-dots span {
    width: 8px;
    height: 8px;
    background: var(--text-muted);
    border-radius: 50%;
    animation: typingBounce 1.4s ease-in-out infinite;
}

.typing-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typingBounce {

    0%,
    60%,
    100% {
        transform: translateY(0);
    }

    30% {
        transform: translateY(-8px);
    }
}

/* === Chat Footer === */
.chat-footer {
    display: flex;
    gap: 0.5rem;
    padding: 1rem;
    background: var(--dark-card);
    border-top: 1px solid var(--glass-border);
}

.chat-footer input {
    flex: 1;
    background: var(--glass);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    padding: 0.875rem 1rem;
    color: var(--text);
    font-size: 0.9rem;
    transition: var(--transition);
}

.chat-footer input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

.chat-footer input::placeholder {
    color: var(--text-dim);
}

.chat-send-btn {
    width: 48px;
    height: 48px;
    background: var(--primary);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    transition: var(--transition);
}

.chat-send-btn:hover {
    background: var(--primary-dark);
    transform: scale(1.05);
}

.chat-send-btn:active {
    transform: scale(0.95);
}

.chat-send-btn.loading {
    pointer-events: none;
}

.chat-send-btn .loading-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* === Responsive === */
@media (max-width: 480px) {
    .chat-widget {
        bottom: 16px;
        right: 16px;
    }

    .chat-toggle {
        width: 56px;
        height: 56px;
    }

    .chat-window {
        width: calc(100vw - 32px);
        height: calc(100vh - 120px);
        right: -8px;
        bottom: 72px;
    }
}