/* ═══════════════════════════════════════════════
   DIGIMAGINE — AI Chat Widget (Groq)
   ═══════════════════════════════════════════════ */

/* ── Toggle Button ── */
#digiChatToggle {
    position: fixed;
    bottom: 28px;
    right: 28px;
    width: 58px;
    height: 58px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--blue), var(--purple));
    border: none;
    color: #fff;
    cursor: pointer;
    z-index: 100001;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 32px rgba(26,31,232,0.5);
    transition: transform 0.35s cubic-bezier(0.23,1,0.32,1), box-shadow 0.35s;
    animation: chatPulse 3s ease-in-out infinite;
}
#digiChatToggle:hover {
    transform: scale(1.1);
    box-shadow: 0 12px 44px rgba(155,31,245,0.6);
}
#digiChatToggle.active {
    transform: scale(0.9) rotate(90deg);
    opacity: 0;
    pointer-events: none;
}
@keyframes chatPulse {
    0%, 100% { box-shadow: 0 8px 32px rgba(26,31,232,0.5); }
    50% { box-shadow: 0 8px 32px rgba(26,31,232,0.5), 0 0 0 12px rgba(26,31,232,0.08); }
}

/* ── Chat Widget ── */
.digi-chat-widget {
    position: fixed;
    bottom: 100px;
    right: 28px;
    width: 380px;
    max-height: 560px;
    background: rgba(14,14,40,0.95);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    z-index: 100002;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    backdrop-filter: blur(24px);
    box-shadow: 0 24px 80px rgba(0,0,0,0.5), 0 0 0 1px rgba(155,31,245,0.1);
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px) scale(0.95);
    transition: opacity 0.4s cubic-bezier(0.23,1,0.32,1),
                visibility 0.4s,
                transform 0.4s cubic-bezier(0.23,1,0.32,1);
}
.digi-chat-widget.open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

/* ── Header ── */
.digi-chat-header {
    padding: 18px 20px;
    background: linear-gradient(135deg, rgba(26,31,232,0.15), rgba(155,31,245,0.1));
    border-bottom: 1px solid var(--glass-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}
.digi-chat-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}
.digi-chat-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--blue), var(--purple));
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    flex-shrink: 0;
}
.digi-chat-title {
    font-family: 'Syne', sans-serif;
    font-weight: 700;
    font-size: 0.95rem;
    color: #fff;
}
.digi-chat-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.72rem;
    color: rgba(255,255,255,0.5);
    margin-top: 2px;
}
.digi-chat-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #22c55e;
    box-shadow: 0 0 8px rgba(34,197,94,0.5);
    animation: statusPulse 2s infinite;
}
@keyframes statusPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}
#digiChatClose {
    background: transparent;
    border: none;
    color: rgba(255,255,255,0.5);
    cursor: pointer;
    padding: 6px;
    border-radius: 8px;
    transition: color 0.2s, background 0.2s;
}
#digiChatClose:hover {
    color: #fff;
    background: rgba(255,255,255,0.08);
}

/* ── Messages ── */
.digi-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.1) transparent;
}
.digi-chat-messages::-webkit-scrollbar { width: 4px; }
.digi-chat-messages::-webkit-scrollbar-track { background: transparent; }
.digi-chat-messages::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 4px; }

.digi-chat-msg {
    display: flex;
    gap: 10px;
    max-width: 85%;
    animation: msgSlide 0.4s cubic-bezier(0.23,1,0.32,1);
}
@keyframes msgSlide {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}
.digi-chat-bot {
    align-self: flex-start;
}
.digi-chat-user {
    align-self: flex-end;
    flex-direction: row-reverse;
}
.digi-chat-bubble {
    padding: 14px 18px;
    border-radius: 18px;
    font-size: 0.88rem;
    line-height: 1.6;
    word-break: break-word;
}
.digi-chat-bot .digi-chat-bubble {
    background: var(--glass);
    border: 1px solid var(--glass-border);
    border-bottom-left-radius: 6px;
    color: rgba(255,255,255,0.9);
}
.digi-chat-user .digi-chat-bubble {
    background: linear-gradient(135deg, var(--blue), var(--purple));
    border-bottom-right-radius: 6px;
    color: #fff;
}

/* ── Typing Indicator ── */
.digi-chat-typing {
    display: flex;
    gap: 5px;
    padding: 14px 18px;
    align-items: center;
}
.digi-chat-typing span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: rgba(255,255,255,0.3);
    animation: typingBounce 1.4s ease-in-out infinite;
}
.digi-chat-typing span:nth-child(2) { animation-delay: 0.2s; }
.digi-chat-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes typingBounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.3; }
    30% { transform: translateY(-6px); opacity: 1; }
}

/* ── Input ── */
.digi-chat-input-wrap {
    padding: 16px;
    border-top: 1px solid var(--glass-border);
    flex-shrink: 0;
}
.digi-chat-input-wrap form {
    display: flex;
    gap: 10px;
    align-items: center;
}
.digi-chat-input-wrap input {
    flex: 1;
    background: rgba(255,255,255,0.06);
    border: 1px solid var(--glass-border);
    border-radius: 100px;
    padding: 12px 18px;
    color: #fff;
    font-family: 'DM Sans', sans-serif;
    font-size: 0.88rem;
    outline: none;
    transition: border-color 0.3s, box-shadow 0.3s;
}
.digi-chat-input-wrap input::placeholder {
    color: rgba(255,255,255,0.3);
}
.digi-chat-input-wrap input:focus {
    border-color: var(--blue-light);
    box-shadow: 0 0 0 3px rgba(26,31,232,0.12);
}
#digiChatSend {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--blue), var(--purple));
    border: none;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: transform 0.25s, box-shadow 0.25s;
}
#digiChatSend:hover {
    transform: scale(1.08);
    box-shadow: 0 4px 16px rgba(26,31,232,0.5);
}
#digiChatSend:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
}

/* ── Light Mode ── */
body.light-mode .digi-chat-widget {
    background: rgba(255,255,255,0.95);
    border-color: rgba(0,0,0,0.08);
    box-shadow: 0 24px 80px rgba(0,0,0,0.15);
}
body.light-mode .digi-chat-header {
    background: linear-gradient(135deg, rgba(26,31,232,0.08), rgba(155,31,245,0.06));
    border-color: rgba(0,0,0,0.06);
}
body.light-mode .digi-chat-bot .digi-chat-bubble {
    background: rgba(0,0,0,0.04);
    border-color: rgba(0,0,0,0.06);
    color: rgba(0,0,0,0.8);
}
body.light-mode .digi-chat-input-wrap {
    border-color: rgba(0,0,0,0.06);
}
body.light-mode .digi-chat-input-wrap input {
    background: rgba(0,0,0,0.04);
    border-color: rgba(0,0,0,0.1);
    color: #1a1a2e;
}
body.light-mode .digi-chat-input-wrap input::placeholder {
    color: rgba(0,0,0,0.3);
}
body.light-mode #digiChatClose { color: rgba(0,0,0,0.4); }
body.light-mode #digiChatClose:hover { color: #1a1a2e; background: rgba(0,0,0,0.04); }

/* ── Responsive ── */
@media (max-width: 480px) {
    .digi-chat-widget {
        right: 12px;
        bottom: 90px;
        left: 12px;
        width: auto;
        max-height: 70vh;
        border-radius: 20px;
    }
    #digiChatToggle {
        bottom: 20px;
        right: 20px;
        width: 52px;
        height: 52px;
    }
}
