/* ==========================================================================
   Ragionex — Custom Styles
   Beyond Tailwind: animations, gradients, code highlighting, effects
   ========================================================================== */

/* --------------------------------------------------------------------------
   CSS Custom Properties
   -------------------------------------------------------------------------- */
:root {
    --bg-primary: #0a0a0a;
    --bg-secondary: #111111;
    --bg-card: #1a1a1a;
    --bg-card-hover: #222222;
    --border-primary: #262626;
    --border-hover: #404040;
    --text-primary: #fafafa;
    --text-secondary: #a1a1aa;
    --text-muted: #71717a;
    --accent: #6366f1;
    --accent-hover: #818cf8;
    --accent-glow: rgba(99, 102, 241, 0.15);
    --success: #22c55e;
    --error: #ef4444;
    --code-bg: #000000;
    --code-text: #e4e0d4;
}

/* --------------------------------------------------------------------------
   Base
   -------------------------------------------------------------------------- */
::selection {
    background: var(--accent);
    color: var(--text-primary);
}

html {
    scroll-behavior: smooth;
    scroll-padding-top: 67px;
}

/* --------------------------------------------------------------------------
   Scrollbar
   -------------------------------------------------------------------------- */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
    background: var(--border-primary);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--border-hover);
}

/* Firefox */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--border-primary) var(--bg-primary);
}

/* --------------------------------------------------------------------------
   Glass Navigation
   -------------------------------------------------------------------------- */
.glass-nav {
    background: rgba(10, 10, 10, 0.8);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid transparent;
    transition: border-color 0.3s ease;
}

.glass-nav.scrolled {
    border-bottom-color: var(--border-primary);
}

/* --------------------------------------------------------------------------
   Hero Gradient Background
   -------------------------------------------------------------------------- */
.hero-gradient {
    background: radial-gradient(ellipse 80% 50% at 50% -20%, var(--accent-glow), transparent);
}

/* --------------------------------------------------------------------------
   Hero Entrance Animations
   -------------------------------------------------------------------------- */


/* --------------------------------------------------------------------------
   Scroll Reveal
   -------------------------------------------------------------------------- */
.fade-in-section {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.6s ease-out, transform 0.6s ease-out;
}

.fade-in-section.visible {
    opacity: 1;
    transform: translateY(0);
}

/* --------------------------------------------------------------------------
   Code Syntax Highlighting — Vesper Purple theme
   -------------------------------------------------------------------------- */
.code-block-wrapper pre code {
    color: #e4e0d4;
}

.code-keyword {
    color: #d4d4d4;
}

.code-control {
    color: #a855f7;
    font-style: italic;
}

.code-async {
    color: #22d3ee;
    font-style: italic;
}

.code-string {
    color: #a8a8a8;
}

.code-number {
    color: #fbbf24;
}

.code-comment {
    color: #6b7280;
    font-style: italic;
}

.code-method {
    color: #c084fc;
}

.code-key {
    color: #f472b6;
}

.code-url {
    color: #a8a8a8;
}

.code-tag {
    color: #737373;
}

.code-variable {
    color: #f472b6;
}

.code-constant {
    color: #fbbf24;
    font-style: italic;
}

.code-parameter {
    color: #e4e0d4;
    font-style: italic;
}

/* --------------------------------------------------------------------------
   Card Hover Effects
   -------------------------------------------------------------------------- */
.card-hover {
    transition: background-color 0.2s ease, border-color 0.2s ease;
}

.card-hover:hover {
    background-color: var(--bg-card-hover);
    border-color: var(--border-hover);
}

/* --------------------------------------------------------------------------
   Accent Glow Effect (behind elements)
   -------------------------------------------------------------------------- */
.accent-glow {
    box-shadow: 0 0 60px var(--accent-glow);
}

/* --------------------------------------------------------------------------
   Input Focus Glow
   -------------------------------------------------------------------------- */
.search-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}



/* --------------------------------------------------------------------------
   Code Tab Active State
   -------------------------------------------------------------------------- */
.code-tab {
    color: var(--text-muted);
    border-bottom: 2px solid transparent;
    transition: color 0.2s ease, border-color 0.2s ease;
    cursor: pointer;
    padding-bottom: 8px;
}

.code-tab:hover {
    color: var(--text-secondary);
}

.code-tab.active {
    color: var(--text-primary);
    border-bottom-color: var(--accent);
}

/* --------------------------------------------------------------------------
   Copy Button
   -------------------------------------------------------------------------- */
.copy-btn {
    transition: color 0.2s ease, background-color 0.2s ease;
}

/* --------------------------------------------------------------------------
   CTA Button Hover Glow
   -------------------------------------------------------------------------- */
.btn-primary {
    transition: background-color 0.2s ease, box-shadow 0.2s ease;
}

.btn-primary:hover {
    box-shadow: 0 0 20px var(--accent-glow);
}

/* --------------------------------------------------------------------------
   Mobile Menu
   -------------------------------------------------------------------------- */
.mobile-menu {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.mobile-menu.open {
    max-height: 300px;
}


/* --------------------------------------------------------------------------
   Comparison Card Tints
   -------------------------------------------------------------------------- */
.card-problem {
    border-color: rgba(239, 68, 68, 0.2);
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.03), transparent);
}

.card-solution {
    border-color: rgba(34, 197, 94, 0.2);
    background: linear-gradient(135deg, rgba(34, 197, 94, 0.03), transparent);
}

/* --------------------------------------------------------------------------
   Step Connector Lines (How It Works)
   -------------------------------------------------------------------------- */
.step-connector {
    position: relative;
}

.step-connector::after {
    content: '';
    position: absolute;
    top: 24px;
    left: calc(50% + 24px);
    width: calc(100% + 2rem - 48px);
    height: 2px;
    background: var(--border-primary);
}

/* --------------------------------------------------------------------------
   Reduced Motion
   -------------------------------------------------------------------------- */
/* --------------------------------------------------------------------------
   Chat Demo — OpenWebUI Style
   -------------------------------------------------------------------------- */

.chat-demo {
    border: 1px solid rgba(255, 255, 255, 0.06);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    background: #171717;
}

/* Header — minimal, gradient fade into messages */
.chat-demo .chat-header {
    background: linear-gradient(to bottom, rgba(23, 23, 23, 0.95), rgba(23, 23, 23, 0.6));
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.chat-pause-btn {
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: #ffffff;
    background: none;
    border: none;
    cursor: pointer;
    width: 12px;
    height: 12px;
    padding: 0;
    border-radius: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s, background 0.2s;
}
.chat-pause-btn:hover {
    color: #d4d4d8;
    background: rgba(255, 255, 255, 0.06);
}

/* Messages area */
.chat-messages {
    padding: 1.5rem 0 0.5rem;
}

/* Message row — centered column like OpenWebUI */
.chat-msg {
    display: flex;
    gap: 0.75rem;
    max-width: 48rem;
    margin: 0 auto 1.25rem;
    padding: 0 1.25rem;
    animation: chatMsgAppear 0.3s ease-out;
}

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

/* AI message — flat, no bubble, avatar left */
.chat-msg-ai {
    align-items: flex-start;
}

/* AI text content — flat on background */
.chat-msg-ai .chat-content {
    flex: 1 1 auto;
    min-width: 0;
    color: #eee;
    font-size: 0.9375rem;
    line-height: 1.75;
    word-break: break-word;
}

.chat-msg-ai .chat-content img {
    max-width: 100%;
    border-radius: 0.75rem;
    margin: 0.5rem 0;
}

.chat-msg-ai .chat-content video {
    max-width: 100%;
    border-radius: 0.75rem;
    margin: 0.5rem 0;
}

/* Inline code in AI response */
.chat-inline-code {
    background: rgba(255, 255, 255, 0.06);
    padding: 0.125rem 0.375rem;
    border-radius: 0.25rem;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.8125rem;
    color: #e5e7eb;
}

/* User message — right-aligned, subtle bubble */
.chat-msg-user {
    justify-content: flex-end;
}

.chat-msg-user .chat-bubble {
    background: rgba(255, 255, 255, 0.04);
    border-radius: 1.5rem;
    padding: 0.625rem 1.125rem;
    max-width: 85%;
    color: #eee;
    font-size: 0.9375rem;
    line-height: 1.6;
    word-break: break-word;
}

/* Avatar — 28px circle, neutral */
.chat-avatar {
    width: 1.75rem;
    height: 1.75rem;
    border-radius: 50%;
    background: #2a2a2a;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-top: 2px;
}

.chat-avatar svg {
    width: 1rem;
    height: 1rem;
    color: #a1a1aa;
}

/* Typing cursor — used in input bar */
.typing-cursor {
    display: inline-block;
    width: 2px;
    height: 1em;
    background: #d4d4d8;
    margin-left: 1px;
    vertical-align: text-bottom;
    animation: cursorBlink 0.6s step-end infinite;
}

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

/* Input wrapper */
.chat-input-wrapper {
    padding: 0.25rem 1rem 1rem;
}

/* Pill-shaped input bar */
.chat-input-bar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(255, 255, 255, 0.03);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 1.5rem;
    padding: 0.5rem 0.5rem 0.5rem 1.125rem;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.3);
    transition: border-color 0.2s ease;
}

.chat-input-bar.active {
    border-color: rgba(255, 255, 255, 0.12);
}

/* Input text area */
.chat-input-text {
    flex: 1;
    font-size: 0.875rem;
    color: #757575;
    line-height: 1.5;
    padding: 0.25rem 0;
    min-height: 1.5rem;
    transition: color 0.15s ease;
}

.chat-input-text.active {
    color: #eee;
}

/* Circular send button */
.chat-send-btn {
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    background: #3a3a3a;
    color: #6b6b6b;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    cursor: default;
    border: none;
    transition: background-color 0.15s ease, transform 0.15s ease, color 0.15s ease;
}

.chat-send-btn.active {
    background: #fff;
    color: #000;
    transform: scale(1.08);
}

/* Thinking indicator — pulsing dot + shimmer text */
.chat-thinking-indicator {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.25rem 0;
}

.chat-thinking-dot {
    width: 12px;
    height: 12px;
    position: relative;
}

.chat-thinking-dot .outer {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: #d4d4d8;
    opacity: 0.5;
    animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

.chat-thinking-dot .inner {
    position: absolute;
    inset: 3px;
    border-radius: 50%;
    background: #fff;
    animation: thinkDotScale 1.5s ease-in-out infinite;
}

@keyframes thinkDotScale {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.25); }
}

/* Shimmer text animation */
.chat-shimmer {
    background: linear-gradient(90deg, #818286 25%, #eae5e5 50%, #818286 75%);
    background-size: 200% 100%;
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: shimmer 3s linear infinite;
}

@keyframes shimmer {
    0% { background-position: 200% 50%; }
    100% { background-position: -200% 50%; }
}

/* Tool call — timeline with dots and lines */
.chat-tool-timeline {
    margin: 0.25rem 0;
    padding-left: 0.125rem;
}

.chat-tool-step {
    display: flex;
    align-items: stretch;
    gap: 0.5rem;
}

.chat-tool-step-indicator {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 12px;
    padding-top: 7px;
}

.chat-tool-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #6b7280;
    flex-shrink: 0;
}

.chat-tool-line {
    width: 1px;
    flex: 1;
    background: #374151;
    margin-top: 3px;
}

.chat-tool-content {
    font-size: 0.8125rem;
    color: #9ca3af;
    padding: 2px 0 8px;
}

.chat-tool-query {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 0.5rem;
    padding: 0.3rem 0.625rem;
    font-size: 0.75rem;
    color: #9ca3af;
    margin-top: 0.25rem;
}

.chat-tool-query svg {
    flex-shrink: 0;
    color: #6b7280;
}

/* Messages fade for loop restart */
.chat-messages-fade-out {
    animation: chatMsgsFadeOut 0.8s ease-in forwards;
}

@keyframes chatMsgsFadeOut {
    0% { opacity: 1; }
    100% { opacity: 0; }
}

.chat-messages-fade-in {
    animation: chatMsgsFadeIn 0.5s ease-out forwards;
}

@keyframes chatMsgsFadeIn {
    0% { opacity: 0; }
    100% { opacity: 1; }
}

/* Mobile */
@media (max-width: 640px) {
    #chat-messages {
        height: clamp(300px, calc(100vh - 360px), 480px) !important;
    }

    .chat-msg {
        padding: 0 0.75rem;
    }

    .chat-msg-user .chat-bubble {
        max-width: 92%;
        font-size: 0.8125rem;
    }

    .chat-msg-ai .chat-content {
        font-size: 0.8125rem;
    }

    .chat-avatar {
        width: 1.5rem;
        height: 1.5rem;
    }

    .chat-avatar svg {
        width: 0.875rem;
        height: 0.875rem;
    }

    .chat-input-wrapper {
        padding: 0.25rem 0.75rem 0.75rem;
    }
}

/* --------------------------------------------------------------------------
   Reduced Motion
   -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    .fade-in-section {
        opacity: 1;
        transform: none;
    }

    html {
        scroll-behavior: auto;
    }

    .chat-msg {
        animation: none;
    }

    .chat-shimmer {
        animation: none;
        -webkit-text-fill-color: #9ca3af;
    }

    .chat-thinking-dot .outer,
    .chat-thinking-dot .inner {
        animation: none;
    }

    .typing-cursor {
        animation: none;
        opacity: 1;
    }
}
