/**
 * DogeFetch AI Assistant Widget - Dune.io + ChatGPT Style
 * Dark theme with purple/pink accents matching NarTools
 */

:root {
    --widget-primary: #8b5cf6;
    --widget-secondary: #fc72ff;
    --widget-dark: #0d111c;
    --widget-darker: #080b14;
    --widget-card: #1a1f35;
    --widget-border: rgba(139, 92, 246, 0.2);
    --widget-glow: rgba(139, 92, 246, 0.6);
}

/* ========================================
   Floating Orb Button (Circular PNG with Glow)
   ======================================== */

.dogefetch-orb {
    position: fixed;
    bottom: 32px;
    right: 32px;
    width: 64px;
    height: 64px;
    cursor: pointer;
    z-index: 9998;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.dogefetch-orb::before {
    content: '';
    position: absolute;
    inset: -8px;
    background: radial-gradient(circle, var(--widget-glow) 0%, transparent 70%);
    border-radius: 50%;
    opacity: 0.6;
    animation: orbGlow 3s ease-in-out infinite;
    z-index: -1;
}

@keyframes orbGlow {
    0%, 100% {
        transform: scale(1);
        opacity: 0.6;
    }
    50% {
        transform: scale(1.2);
        opacity: 0.8;
    }
}

.dogefetch-orb:hover {
    transform: scale(1.1);
}

.dogefetch-orb:hover::before {
    opacity: 1;
    animation: orbGlow 1.5s ease-in-out infinite;
}

.dogefetch-orb:active {
    transform: scale(0.95);
}

.orb-image {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    background: linear-gradient(135deg, var(--widget-primary) 0%, var(--widget-secondary) 100%);
    padding: 2px;
    box-shadow:
        0 0 20px rgba(139, 92, 246, 0.4),
        0 0 40px rgba(252, 114, 255, 0.2),
        inset 0 0 10px rgba(139, 92, 246, 0.1);
}

.orb-pulse {
    position: absolute;
    inset: -4px;
    border: 2px solid var(--widget-primary);
    border-radius: 50%;
    opacity: 0;
    animation: pulse 2s cubic-bezier(0, 0, 0.2, 1) infinite;
}

@keyframes pulse {
    0% {
        transform: scale(0.95);
        opacity: 0.7;
    }
    70% {
        transform: scale(1.3);
        opacity: 0;
    }
    100% {
        transform: scale(0.95);
        opacity: 0;
    }
}

/* ========================================
   Chat Window (ChatGPT + Helpdesk Style)
   ======================================== */

.dogefetch-chat {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 440px;
    height: 680px;
    background: var(--widget-dark);
    border: 1px solid var(--widget-border);
    border-radius: 16px;
    box-shadow:
        0 24px 48px rgba(0, 0, 0, 0.7),
        0 0 0 1px rgba(139, 92, 246, 0.1),
        0 0 60px rgba(139, 92, 246, 0.15);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 9999;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    backdrop-filter: blur(20px);
}

.dogefetch-chat.hidden {
    opacity: 0;
    pointer-events: none;
    transform: translateY(20px) scale(0.95);
}

.dogefetch-chat.minimized {
    height: 72px;
    overflow: hidden;
}

/* ========================================
   Chat Header (Dune.io Style)
   ======================================== */

.chat-header {
    background: linear-gradient(135deg,
        var(--widget-darker) 0%,
        #1a1340 50%,
        var(--widget-darker) 100%);
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--widget-border);
    position: relative;
    overflow: hidden;
}

.chat-header::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at 80% 50%, rgba(139, 92, 246, 0.1) 0%, transparent 60%);
    pointer-events: none;
}

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

.chat-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 2px solid var(--widget-primary);
    box-shadow: 0 0 12px rgba(139, 92, 246, 0.4);
    background: linear-gradient(135deg, var(--widget-primary) 0%, var(--widget-secondary) 100%);
    padding: 2px;
}

.chat-title h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    background: linear-gradient(135deg, #ffffff 0%, #d8b4fe 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.chat-status {
    font-size: 12px;
    color: #9ca3af;
    display: flex;
    align-items: center;
    gap: 6px;
}

.chat-status::before {
    content: '';
    width: 6px;
    height: 6px;
    background: #4ade80;
    border-radius: 50%;
    box-shadow: 0 0 8px rgba(74, 222, 128, 0.6);
    animation: statusBlink 2s ease-in-out infinite;
}

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

.chat-controls {
    display: flex;
    gap: 6px;
    position: relative;
    z-index: 1;
}

.chat-btn {
    background: rgba(139, 92, 246, 0.1);
    border: 1px solid rgba(139, 92, 246, 0.2);
    color: #d8b4fe;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    font-weight: 300;
}

.chat-btn:hover {
    background: rgba(139, 92, 246, 0.2);
    border-color: rgba(139, 92, 246, 0.4);
    box-shadow: 0 0 12px rgba(139, 92, 246, 0.3);
}

.chat-btn:active {
    transform: scale(0.95);
}

/* ========================================
   Chat Messages (ChatGPT Style)
   ======================================== */

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 24px 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    background: var(--widget-darker);
    position: relative;
}

/* Subtle grid background like Dune.io */
.chat-messages::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(rgba(139, 92, 246, 0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(139, 92, 246, 0.03) 1px, transparent 1px);
    background-size: 20px 20px;
    pointer-events: none;
}

.chat-message {
    display: flex;
    gap: 12px;
    animation: messageSlide 0.3s ease-out;
    position: relative;
}

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

.chat-message.user {
    flex-direction: row-reverse;
}

.message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    flex-shrink: 0;
    border: 2px solid var(--widget-primary);
    box-shadow: 0 0 8px rgba(139, 92, 246, 0.3);
}

.message-content {
    max-width: 80%;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.message-text {
    padding: 14px 18px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.6;
    color: #e5e7eb;
    background: var(--widget-card);
    border: 1px solid rgba(139, 92, 246, 0.1);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    position: relative;
}

/* Assistant message style */
.chat-message.assistant .message-text {
    border-left: 3px solid var(--widget-primary);
}

/* User message style (ChatGPT-like) */
.chat-message.user .message-text {
    background: linear-gradient(135deg,
        rgba(139, 92, 246, 0.15) 0%,
        rgba(252, 114, 255, 0.15) 100%);
    border: 1px solid rgba(139, 92, 246, 0.3);
    border-left: 3px solid var(--widget-secondary);
}

.message-text strong {
    color: var(--widget-secondary);
    font-weight: 600;
}

.message-time {
    font-size: 11px;
    color: #6b7280;
    padding: 0 4px;
}

.chat-message.user .message-time {
    text-align: right;
}

/* Typing indicator (Dune.io style) */
.chat-message.typing .message-text {
    padding: 12px 18px;
    background: var(--widget-card);
}

.typing-dots {
    display: flex;
    gap: 5px;
    align-items: center;
}

.typing-dots span {
    width: 8px;
    height: 8px;
    background: var(--widget-primary);
    border-radius: 50%;
    animation: typingDot 1.4s infinite;
    box-shadow: 0 0 8px rgba(139, 92, 246, 0.4);
}

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

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

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

/* ========================================
   Chat Input (Modern Helpdesk Style)
   ======================================== */

.chat-input-container {
    padding: 20px;
    background: var(--widget-dark);
    border-top: 1px solid var(--widget-border);
    display: flex;
    gap: 12px;
    align-items: flex-end;
}

.chat-input {
    flex: 1;
    background: var(--widget-card);
    border: 1px solid var(--widget-border);
    border-radius: 12px;
    padding: 12px 16px;
    font-size: 14px;
    color: #ffffff;
    outline: none;
    resize: none;
    max-height: 120px;
    min-height: 44px;
    font-family: inherit;
    transition: all 0.2s;
}

.chat-input::placeholder {
    color: #6b7280;
}

.chat-input:focus {
    border-color: var(--widget-primary);
    background: rgba(26, 31, 53, 0.8);
    box-shadow:
        0 0 0 3px rgba(139, 92, 246, 0.1),
        0 0 20px rgba(139, 92, 246, 0.15);
}

.send-btn {
    background: linear-gradient(135deg, var(--widget-primary) 0%, var(--widget-secondary) 100%);
    border: none;
    color: white;
    width: 44px;
    height: 44px;
    border-radius: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.3);
}

.send-btn:hover {
    transform: translateY(-2px);
    box-shadow:
        0 6px 20px rgba(139, 92, 246, 0.4),
        0 0 30px rgba(252, 114, 255, 0.2);
}

.send-btn:active {
    transform: translateY(0);
}

.send-btn svg {
    transition: transform 0.2s;
}

.send-btn:hover svg {
    transform: translateX(2px);
}

/* ========================================
   Chat Footer
   ======================================== */

.chat-footer {
    padding: 12px 20px;
    background: var(--widget-darker);
    border-top: 1px solid rgba(139, 92, 246, 0.05);
    text-align: center;
}

.chat-footer span {
    font-size: 11px;
    color: #6b7280;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.chat-footer span::before {
    content: '⚡';
    font-size: 12px;
}

/* ========================================
   Scrollbar (Dune.io Style)
   ======================================== */

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

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

.chat-messages::-webkit-scrollbar-thumb {
    background: rgba(139, 92, 246, 0.3);
    border-radius: 3px;
    transition: background 0.2s;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: rgba(139, 92, 246, 0.5);
}

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

@media (max-width: 768px) {
    .dogefetch-chat {
        width: calc(100vw - 32px);
        height: calc(100vh - 100px);
        max-height: 600px;
        bottom: 16px;
        right: 16px;
    }

    .dogefetch-orb {
        bottom: 24px;
        right: 24px;
        width: 56px;
        height: 56px;
    }
}

@media (max-width: 480px) {
    .dogefetch-chat {
        width: 100vw;
        height: 100vh;
        bottom: 0;
        right: 0;
        border-radius: 0;
        max-height: none;
    }

    .chat-header {
        border-radius: 0;
    }

    .dogefetch-orb {
        bottom: 20px;
        right: 20px;
    }
}

/* ========================================
   Animations & Effects
   ======================================== */

@keyframes shimmer {
    0% {
        background-position: -1000px 0;
    }
    100% {
        background-position: 1000px 0;
    }
}

/* Loading state */
.chat-message.loading .message-text {
    background: linear-gradient(
        90deg,
        var(--widget-card) 0%,
        rgba(139, 92, 246, 0.1) 50%,
        var(--widget-card) 100%
    );
    background-size: 1000px 100%;
    animation: shimmer 2s infinite;
}

/* ========================================
   Embedded Crypto Widgets
   ======================================== */

.crypto-widget {
    margin: 12px 0;
    padding: 16px;
    background: var(--widget-card);
    border: 1px solid var(--widget-border);
    border-radius: 12px;
    overflow: hidden;
}

.crypto-widget gecko-coin-price-chart-widget {
    display: block;
    width: 100%;
    border-radius: 8px;
}
