/* Sprite Sprite (小精灵) Styles */
#sprite-container {
    position: fixed;
    top: 20px;
    right: 20px;
    width: 180px;
    height: 180px;
    z-index: 10000;
    pointer-events: auto;
    cursor: pointer;
    filter: drop-shadow(0 0 20px rgba(255, 255, 255, 0.2));
}

.sprite-greeting {
    position: absolute;
    top: 0;
    right: 110%; /* Place it to the left of the sprite */
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 10px 20px;
    border-radius: 40px;
    color: #ffffff;
    font-family: var(--font-display);
    font-size: 0.75rem;
    letter-spacing: 1px;
    text-transform: uppercase;
    pointer-events: none;
    opacity: 0;
    transform: scale(0.8) translateX(20px);
    transition: all 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 101;
    white-space: nowrap;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.sprite-greeting.show {
    opacity: 1;
    transform: scale(1) translateX(0);
}

/* Chat Dialog Styles - Organic Floating Shape */
.chat-dialog {
    position: fixed;
    top: 50%;
    right: 30px;
    transform: translateY(-50%) scale(0.8) rotate(-1deg);
    width: 420px;
    max-height: 75vh;
    /* Organic floating shape with asymmetric design */
    background: rgba(255, 255, 255, 0.03);
    backdrop-filter: blur(60px) saturate(200%);
    -webkit-backdrop-filter: blur(60px) saturate(200%);
    border: 1px solid rgba(255, 255, 255, 0.1);
    /* Asymmetric organic border-radius */
    border-radius: 32px 20px 32px 28px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25),
                0 4px 12px rgba(0, 0, 0, 0.15),
                0 1px 0 rgba(255, 255, 255, 0.1) inset;
    z-index: 10001;
    opacity: 0;
    pointer-events: none;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    display: flex;
    flex-direction: column;
    overflow: visible;
}

.chat-dialog::before {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    background: linear-gradient(135deg, 
        rgba(255, 255, 255, 0.1) 0%, 
        rgba(255, 255, 255, 0.05) 50%, 
        rgba(255, 255, 255, 0.1) 100%);
    border-radius: 32px 20px 32px 28px;
    z-index: -1;
    opacity: 0.5;
}

.chat-dialog.show {
    opacity: 1;
    transform: translateY(-50%) scale(1) rotate(0deg);
    pointer-events: auto;
}

.chat-dialog-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: transparent;
    /* Organic curved top */
    border-radius: 32px 20px 0 0;
    backdrop-filter: blur(20px);
    position: relative;
}

.chat-dialog-header::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 10%;
    right: 10%;
    height: 1px;
    background: linear-gradient(90deg, 
        transparent 0%, 
        rgba(255, 255, 255, 0.2) 20%, 
        rgba(255, 255, 255, 0.2) 80%, 
        transparent 100%);
}

.chat-dialog-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: #ffffff;
    font-family: var(--font-display);
    font-size: 0.9rem;
    font-weight: 600;
}

.chat-dialog-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 4px;
    transition: all 0.3s ease;
    line-height: 1;
}

.chat-dialog-close:hover {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(10px);
}

.chat-dialog-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    min-height: 220px;
    max-height: calc(70vh - 180px);
    background: transparent;
    position: relative;
}

.chat-dialog-messages::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 60px;
    height: 2px;
    background: radial-gradient(ellipse, rgba(255, 255, 255, 0.2), transparent);
}

/* Custom scrollbar for glass effect */
.chat-dialog-messages::-webkit-scrollbar {
    width: 6px;
}

.chat-dialog-messages::-webkit-scrollbar-track {
    background: transparent;
}

.chat-dialog-messages::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
}

.chat-dialog-messages::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

.chat-message {
    display: flex;
    gap: 0.5rem;
    animation: messageSlideIn 0.3s ease-out;
}

@keyframes messageSlideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.chat-message.user {
    flex-direction: row-reverse;
}

.chat-message-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    flex-shrink: 0;
    background: #ffffff;
    color: #000000;
}

.chat-message-content {
    max-width: 75%;
    padding: 0.875rem 1.125rem;
    border-radius: 16px 20px 16px 4px;
    word-wrap: break-word;
    font-size: 0.85rem;
    line-height: 1.5;
    position: relative;
}

.chat-message.user .chat-message-content {
    border-radius: 20px 16px 4px 16px;
}

.chat-message.user .chat-message-content {
    background: rgba(255, 255, 255, 0.25);
    color: #ffffff;
    border-bottom-right-radius: 4px;
    backdrop-filter: blur(20px) saturate(150%);
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.15);
}

.chat-message.assistant .chat-message-content {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    border-bottom-left-radius: 4px;
    backdrop-filter: blur(20px) saturate(150%);
    box-shadow: 0 1px 6px rgba(0, 0, 0, 0.1);
}

.chat-dialog-input-container {
    padding: 1.25rem 1.5rem 1.5rem;
    border-top: none;
    background: transparent;
    /* Organic curved bottom with floating effect */
    border-radius: 0 0 32px 28px;
    backdrop-filter: blur(20px);
    position: relative;
    margin-top: auto;
}

.chat-dialog-input-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 15%;
    right: 15%;
    height: 1px;
    background: linear-gradient(90deg, 
        transparent 0%, 
        rgba(255, 255, 255, 0.15) 30%, 
        rgba(255, 255, 255, 0.15) 70%, 
        transparent 100%);
}

/* Floating input wrapper - independent shape */
.chat-dialog-input-wrapper {
    display: flex;
    gap: 0.75rem;
    align-items: flex-end;
    padding: 0.5rem;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 24px 18px 24px 20px;
    backdrop-filter: blur(30px) saturate(180%);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15),
                0 1px 4px rgba(255, 255, 255, 0.1) inset;
    transition: all 0.3s ease;
}

.chat-dialog-input-wrapper:focus-within {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.2);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2),
                0 2px 8px rgba(255, 255, 255, 0.15) inset;
    transform: translateY(-2px);
}


.chat-dialog-input {
    flex: 1;
    background: transparent;
    border: none;
    border-radius: 12px;
    padding: 0.75rem 1rem;
    color: var(--text-primary);
    font-family: var(--font-primary);
    font-size: 0.85rem;
    resize: none;
    min-height: 40px;
    max-height: 100px;
    transition: all 0.3s ease;
}

.chat-dialog-input:focus {
    outline: none;
}

.chat-dialog-input::placeholder {
    color: rgba(255, 255, 255, 0.5);
}

.chat-dialog-send {
    background: rgba(255, 255, 255, 0.25);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 16px 12px 16px 14px;
    padding: 0.75rem 1.25rem;
    color: #ffffff;
    font-family: var(--font-primary);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    font-size: 0.85rem;
    backdrop-filter: blur(20px) saturate(150%);
    flex-shrink: 0;
    position: relative;
    overflow: hidden;
}

.chat-dialog-send::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.chat-dialog-send:hover:not(:disabled)::before {
    width: 200px;
    height: 200px;
}

.chat-dialog-send:hover:not(:disabled) {
    transform: translateY(-2px) scale(1.02);
    background: rgba(255, 255, 255, 0.35);
    color: #ffffff;
    border-color: rgba(255, 255, 255, 0.45);
    box-shadow: 0 6px 20px rgba(255, 255, 255, 0.25),
                0 3px 10px rgba(0, 0, 0, 0.2);
}

.chat-dialog-send:active:not(:disabled) {
    transform: translateY(0) scale(0.98);
}

.chat-dialog-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.typing-indicator {
    display: none;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    color: var(--text-secondary);
    font-size: 0.8rem;
}

.typing-dots {
    display: flex;
    gap: 0.25rem;
}

.typing-dot {
    width: 5px;
    height: 5px;
    background: #ffffff;
    border-radius: 50%;
    animation: typingDot 1.4s infinite ease-in-out;
}

.typing-dot:nth-child(1) {
    animation-delay: -0.32s;
}

.typing-dot:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes typingDot {
    0%, 80%, 100% {
        transform: scale(0.8);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

.chat-message.streaming .chat-message-content {
    position: relative;
    border-left: 2px solid #ffffff;
}

/* Subtle animation on show */
@keyframes floatIn {
    0% {
        opacity: 0;
        transform: translateY(-50%) scale(0.9) rotate(-2deg);
    }
    60% {
        transform: translateY(-50%) scale(1.02) rotate(0.5deg);
    }
    100% {
        opacity: 1;
        transform: translateY(-50%) scale(1) rotate(0deg);
    }
}

.chat-dialog.show {
    animation: floatIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* Message bubbles with organic shapes */
.chat-message.assistant .chat-message-content::before {
    content: '';
    position: absolute;
    bottom: -4px;
    left: 12px;
    width: 12px;
    height: 12px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(20px) saturate(150%);
    border-radius: 0 0 0 12px;
    clip-path: polygon(0 0, 100% 0, 0 100%);
    opacity: 0.8;
}

.chat-message.user .chat-message-content::before {
    content: '';
    position: absolute;
    bottom: -4px;
    right: 12px;
    width: 12px;
    height: 12px;
    background: rgba(255, 255, 255, 0.25);
    border: 1px solid rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(20px) saturate(150%);
    border-radius: 0 0 12px 0;
    clip-path: polygon(0 0, 100% 0, 100% 100%);
    opacity: 0.8;
}

@media (max-width: 480px) {
    .chat-dialog {
        width: 100%;
        right: 0;
        bottom: 0;
        top: auto;
        transform: translateY(100%);
        border-radius: 32px 32px 0 0;
    }
    
    .chat-dialog.show {
        transform: translateY(0);
    }
}

/* As's Inner Thoughts (Status Block) */
.chat-message-status {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px dotted rgba(255, 255, 255, 0.1);
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.4);
    font-style: italic;
    display: block;
}

.chat-message-status::before {
    content: '💭 As的心声: ';
    font-weight: bold;
    color: rgba(255, 255, 255, 0.6);
    font-style: normal;
}

/* Paragraph spacing in messages */
.chat-message-content p {
    margin-bottom: 0.8em;
}

.chat-message-content p:last-child {
    margin-bottom: 0;
}
