/**
 * SinAI Orb Text System v4.0
 * Revolutionary Digital Font & Compact Response Design
 * 
 * DESIGN PHILOSOPHY:
 * - Digital, futuristic aesthetic matching the Orb's graphics
 * - Ultra-compact responses (max 2-3 lines)
 * - Instant text appearance (no slow letter-by-letter)
 * - Custom Orb typeface with glow effects
 * - Glassmorphic message bubbles that float
 * 
 * Last Updated: November 30, 2025
 */

/* ============================================
   ORB DIGITAL FONT - Custom Typeface
   ============================================ */
@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@300;400;500&family=Space+Grotesk:wght@300;400;500;600&display=swap');

:root {
    /* Orb Typography */
    --orb-font-primary: 'Space Grotesk', 'SF Pro Display', -apple-system, system-ui, sans-serif;
    --orb-font-mono: 'JetBrains Mono', 'SF Mono', 'Consolas', monospace;
    
    /* Orb Text Colors */
    --orb-text-glow: rgba(102, 126, 234, 0.6);
    --orb-text-primary: #e2e8f0;
    --orb-text-secondary: rgba(226, 232, 240, 0.8);
    --orb-text-accent: #a5b4fc;
    
    /* Orb Message Bubble */
    --orb-bubble-bg: rgba(30, 41, 59, 0.75);
    --orb-bubble-border: rgba(102, 126, 234, 0.25);
    --orb-bubble-glow: 0 4px 24px rgba(102, 126, 234, 0.2);
}

/* ============================================
   ORB MESSAGE CONTAINER - Compact Layout
   ============================================ */
.ai-chat-messages {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 16px;
}

/* ============================================
   ORB MESSAGE GROUP - Digital Style
   ============================================ */
.orb-message-group {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    animation: orbMessageEnter 0.4s cubic-bezier(0.23, 1, 0.32, 1) forwards;
    opacity: 0;
    transform: translateY(12px);
}

@keyframes orbMessageEnter {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ============================================
   ORB AVATAR - Compact Version
   ============================================ */
.orb-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 2px 12px rgba(102, 126, 234, 0.4);
}

.orb-avatar svg {
    width: 16px;
    height: 16px;
}

/* ============================================
   ORB MESSAGE CONTENT - Digital Typography
   ============================================ */
.orb-message-content {
    flex: 1;
    max-width: calc(100% - 44px);
}

.orb-message-text {
    font-family: var(--orb-font-primary);
    font-size: 14px;
    font-weight: 400;
    line-height: 1.5;
    letter-spacing: 0.01em;
    color: var(--orb-text-primary);
    
    /* Digital text styling */
    padding: 12px 16px;
    border-radius: 16px 16px 16px 4px;
    background: var(--orb-bubble-bg);
    border: 1px solid var(--orb-bubble-border);
    box-shadow: var(--orb-bubble-glow);
    
    /* Glassmorphic effect */
    backdrop-filter: blur(16px) saturate(150%);
    -webkit-backdrop-filter: blur(16px) saturate(150%);
    
    /* Subtle text glow */
    text-shadow: 0 0 20px rgba(102, 126, 234, 0.1);
    
    /* Prevent long text overflow */
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* Thinking/Processing state */
.orb-message-text.thinking {
    position: relative;
    overflow: hidden;
}

.orb-message-text.thinking::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(
        90deg,
        transparent 0%,
        rgba(102, 126, 234, 0.1) 50%,
        transparent 100%
    );
    animation: orbThinkingShimmer 1.5s ease-in-out infinite;
}

@keyframes orbThinkingShimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

/* ============================================
   ORB TEXT EMPHASIS - Digital Highlights
   ============================================ */
.orb-message-text strong,
.orb-message-text b {
    color: var(--orb-text-accent);
    font-weight: 500;
    text-shadow: 0 0 12px rgba(165, 180, 252, 0.4);
}

.orb-message-text em,
.orb-message-text i {
    color: var(--orb-text-secondary);
    font-style: normal;
    opacity: 0.9;
}

/* Product mentions - subtle highlight */
.orb-message-text .orb-product {
    color: #a5b4fc;
    font-weight: 500;
    padding: 2px 6px;
    border-radius: 4px;
    background: rgba(102, 126, 234, 0.15);
    border: 1px solid rgba(102, 126, 234, 0.2);
    font-size: 13px;
}

/* ============================================
   ORB QUICK RESPONSES - Chip Style
   ============================================ */
.orb-quick-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

.orb-chip {
    font-family: var(--orb-font-primary);
    font-size: 12px;
    font-weight: 500;
    padding: 6px 12px;
    border-radius: 20px;
    background: rgba(102, 126, 234, 0.12);
    border: 1px solid rgba(102, 126, 234, 0.25);
    color: #a5b4fc;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.23, 1, 0.32, 1);
}

.orb-chip:hover {
    background: rgba(102, 126, 234, 0.25);
    border-color: rgba(102, 126, 234, 0.4);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.2);
}

/* ============================================
   ORB TIMESTAMP - Minimal
   ============================================ */
.orb-message-time {
    font-family: var(--orb-font-mono);
    font-size: 10px;
    font-weight: 400;
    color: rgba(148, 163, 184, 0.6);
    margin-top: 6px;
    letter-spacing: 0.05em;
}

/* ============================================
   USER MESSAGE - Compact Pink Style
   ============================================ */
.orb-message-group.user {
    flex-direction: row-reverse;
}

.orb-message-group.user .orb-avatar {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
}

.orb-message-group.user .orb-message-text {
    background: linear-gradient(135deg, rgba(240, 147, 251, 0.2) 0%, rgba(245, 87, 108, 0.15) 100%);
    border: 1px solid rgba(240, 147, 251, 0.3);
    border-radius: 16px 16px 4px 16px;
    color: #fff;
}

.orb-message-group.user .orb-message-content {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

/* ============================================
   STREAMING TEXT - Instant Append
   ============================================ */
.orb-streaming {
    position: relative;
}

.orb-streaming::after {
    content: '▌';
    display: inline;
    color: var(--orb-text-accent);
    animation: orbCursorBlink 0.8s steps(1) infinite;
    margin-left: 2px;
}

@keyframes orbCursorBlink {
    50% { opacity: 0; }
}

/* ============================================
   ORB THINKING INDICATOR - Compact
   ============================================ */
.orb-thinking {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    font-family: var(--orb-font-primary);
    font-size: 12px;
    color: var(--orb-text-secondary);
    background: var(--orb-bubble-bg);
    border: 1px solid var(--orb-bubble-border);
    border-radius: 16px;
    backdrop-filter: blur(16px);
}

.orb-thinking-dots {
    display: flex;
    gap: 3px;
}

.orb-thinking-dots span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--orb-text-accent);
    animation: orbDotPulse 1.4s ease-in-out infinite;
}

.orb-thinking-dots span:nth-child(2) { animation-delay: 0.2s; }
.orb-thinking-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes orbDotPulse {
    0%, 80%, 100% { 
        opacity: 0.3;
        transform: scale(0.8);
    }
    40% { 
        opacity: 1;
        transform: scale(1);
    }
}

/* ============================================
   LIGHT MODE ADJUSTMENTS
   ============================================ */
[data-theme="light"] .orb-message-text,
:root:not([data-theme="dark"]) .orb-message-text {
    --orb-bubble-bg: rgba(255, 255, 255, 0.85);
    --orb-text-primary: #1a202c;
    --orb-text-secondary: #4a5568;
    --orb-text-accent: #667eea;
    color: var(--orb-text-primary);
    border-color: rgba(102, 126, 234, 0.2);
}

[data-theme="light"] .orb-message-text strong,
:root:not([data-theme="dark"]) .orb-message-text strong {
    color: #667eea;
}

/* ============================================
   MOBILE RESPONSIVE - Compact
   ============================================ */
@media (max-width: 480px) {
    .orb-message-text {
        font-size: 13px;
        padding: 10px 14px;
    }
    
    .orb-avatar {
        width: 24px;
        height: 24px;
    }
    
    .orb-chip {
        font-size: 11px;
        padding: 5px 10px;
    }
}

/* ============================================
   DISABLE OLD LETTER ANIMATION
   Override legacy letter-by-letter system
   ============================================ */
.ai-message .letter,
.message-text .letter {
    display: inline !important;
    animation: none !important;
    opacity: 1 !important;
    transform: none !important;
    filter: none !important;
}

/* Override slow bubble animations */
.message-group.ai-message-group,
.chat-message.ai .message-bubble::before,
.bot-message .message-content p::before {
    animation: none !important;
}

/* Fast entrance only */
.message-group {
    animation: orbMessageEnter 0.35s cubic-bezier(0.23, 1, 0.32, 1) forwards !important;
}
