/**
 * ASTRA JARVIS Theme v1.0
 * Palette: #0060ff (Blu Elettrico)
 * Animazioni cerchi concentrici + Glow effects + Claude-style chat
 */

:root {
    /* JARVIS Color Palette */
    --jarvis-primary: #0060ff;
    --jarvis-primary-light: #3d8bff;
    --jarvis-primary-dark: #0047cc;
    --jarvis-glow: rgba(0, 96, 255, 0.5);
    --jarvis-glow-intense: rgba(0, 96, 255, 0.8);
    --jarvis-accent: #00d4ff;
    --jarvis-purple: #9d4edd;
    --jarvis-gold: #ffd700;
}

/* ============================================
   JARVIS CORE ANIMATION
   ============================================ */

.jarvis-container {
    position: relative;
    width: 200px;
    height: 200px;
    margin: 0 auto;
}

.jarvis-core {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 60px;
    height: 60px;
    background: radial-gradient(circle, var(--jarvis-primary) 0%, var(--jarvis-primary-dark) 50%, transparent 70%);
    border-radius: 50%;
    box-shadow:
        0 0 30px var(--jarvis-primary),
        0 0 60px var(--jarvis-primary),
        0 0 90px var(--jarvis-glow);
    animation: jarvis-pulse 2s ease-in-out infinite;
}

/* Cerchi concentrici */
.jarvis-ring {
    position: absolute;
    top: 50%;
    left: 50%;
    border: 2px solid rgba(0, 96, 255, 0.3);
    border-radius: 50%;
    transform: translate(-50%, -50%);
}

.jarvis-ring-1 {
    width: 80px;
    height: 80px;
    animation: jarvis-rotate 8s linear infinite;
    border-color: rgba(0, 96, 255, 0.6);
    border-style: dashed;
}

.jarvis-ring-2 {
    width: 120px;
    height: 120px;
    animation: jarvis-rotate-reverse 12s linear infinite;
    border-color: rgba(0, 96, 255, 0.4);
}

.jarvis-ring-3 {
    width: 160px;
    height: 160px;
    animation: jarvis-rotate 16s linear infinite;
    border-color: rgba(0, 96, 255, 0.2);
    border-style: dotted;
}

.jarvis-ring-4 {
    width: 200px;
    height: 200px;
    animation: jarvis-rotate-reverse 20s linear infinite;
    border-color: rgba(61, 139, 255, 0.3);
}

/* Segmenti decorativi sui cerchi */
.jarvis-ring::before,
.jarvis-ring::after {
    content: '';
    position: absolute;
    width: 8px;
    height: 8px;
    background: var(--jarvis-primary);
    border-radius: 50%;
    box-shadow: 0 0 10px var(--jarvis-primary);
}

.jarvis-ring-1::before { top: -4px; left: 50%; transform: translateX(-50%); }
.jarvis-ring-1::after { bottom: -4px; left: 50%; transform: translateX(-50%); }

.jarvis-ring-2::before { top: 50%; left: -4px; transform: translateY(-50%); }
.jarvis-ring-2::after { top: 50%; right: -4px; transform: translateY(-50%); }

.jarvis-ring-3::before { top: 10%; left: 10%; }
.jarvis-ring-3::after { bottom: 10%; right: 10%; }

/* ============================================
   THINKING STATE (quando ASTRA elabora)
   ============================================ */

.jarvis-container.thinking .jarvis-core {
    animation: jarvis-thinking 0.5s ease-in-out infinite;
    box-shadow:
        0 0 40px var(--jarvis-primary),
        0 0 80px var(--jarvis-primary),
        0 0 120px var(--jarvis-glow-intense);
}

.jarvis-container.thinking .jarvis-ring {
    animation-duration: 2s !important;
}

.jarvis-container.thinking .jarvis-ring-1 {
    border-color: var(--jarvis-primary);
    box-shadow: 0 0 20px var(--jarvis-glow);
}

/* ============================================
   KEYFRAMES ANIMATIONS
   ============================================ */

@keyframes jarvis-pulse {
    0%, 100% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
    }
    50% {
        transform: translate(-50%, -50%) scale(1.1);
        opacity: 0.8;
    }
}

@keyframes jarvis-thinking {
    0%, 100% {
        transform: translate(-50%, -50%) scale(1);
    }
    25% {
        transform: translate(-50%, -50%) scale(1.2);
    }
    50% {
        transform: translate(-50%, -50%) scale(0.9);
    }
    75% {
        transform: translate(-50%, -50%) scale(1.15);
    }
}

@keyframes jarvis-rotate {
    from { transform: translate(-50%, -50%) rotate(0deg); }
    to { transform: translate(-50%, -50%) rotate(360deg); }
}

@keyframes jarvis-rotate-reverse {
    from { transform: translate(-50%, -50%) rotate(360deg); }
    to { transform: translate(-50%, -50%) rotate(0deg); }
}

/* ============================================
   CLAUDE-STYLE CHAT BUBBLES
   ============================================ */

.chat-container {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 20px;
    max-height: 500px;
    overflow-y: auto;
}

.chat-message {
    display: flex;
    gap: 12px;
    max-width: 85%;
    animation: message-fade-in 0.3s ease-out;
}

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

.chat-message.assistant {
    align-self: flex-start;
}

.chat-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 14px;
}

.chat-message.user .chat-avatar {
    background: linear-gradient(135deg, var(--jarvis-purple) 0%, #7b2cbf 100%);
    color: white;
}

.chat-message.assistant .chat-avatar {
    background: linear-gradient(135deg, var(--jarvis-primary) 0%, var(--jarvis-primary-dark) 100%);
    color: white;
    box-shadow: 0 0 15px var(--jarvis-glow);
}

.chat-bubble {
    padding: 12px 16px;
    border-radius: 18px;
    line-height: 1.5;
    position: relative;
}

.chat-message.user .chat-bubble {
    background: linear-gradient(135deg, var(--jarvis-purple) 0%, #7b2cbf 100%);
    color: white;
    border-bottom-right-radius: 4px;
}

.chat-message.assistant .chat-bubble {
    background: rgba(30, 30, 36, 0.95);
    border: 1px solid rgba(0, 96, 255, 0.3);
    color: #e0e0e0;
    border-bottom-left-radius: 4px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

/* Typing indicator */
.chat-typing {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 12px 16px;
}

.chat-typing-dot {
    width: 8px;
    height: 8px;
    background: var(--jarvis-primary);
    border-radius: 50%;
    animation: typing-bounce 1.4s ease-in-out infinite;
}

.chat-typing-dot:nth-child(2) { animation-delay: 0.2s; }
.chat-typing-dot:nth-child(3) { animation-delay: 0.4s; }

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

@keyframes message-fade-in {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ============================================
   ENHANCED INPUT AREA
   ============================================ */

.query-input-enhanced {
    background: rgba(20, 20, 26, 0.95);
    border: 2px solid rgba(0, 96, 255, 0.2);
    border-radius: 24px;
    padding: 16px 20px;
    color: #fff;
    font-size: 15px;
    transition: all 0.3s ease;
    resize: none;
}

.query-input-enhanced:focus {
    outline: none;
    border-color: var(--jarvis-primary);
    box-shadow:
        0 0 0 3px rgba(0, 96, 255, 0.1),
        0 0 20px rgba(0, 96, 255, 0.2);
}

.query-input-enhanced::placeholder {
    color: rgba(255, 255, 255, 0.4);
}

/* Send button glow */
.send-btn-enhanced {
    background: linear-gradient(135deg, var(--jarvis-primary) 0%, var(--jarvis-primary-dark) 100%);
    border: none;
    border-radius: 50%;
    width: 48px;
    height: 48px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 20px var(--jarvis-glow);
}

.send-btn-enhanced:hover {
    transform: scale(1.1);
    box-shadow: 0 0 30px rgba(0, 96, 255, 0.6);
}

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

.send-btn-enhanced svg {
    width: 20px;
    height: 20px;
    fill: white;
}

/* ============================================
   STATUS BADGES ENHANCED
   ============================================ */

.status-badge-jarvis {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    transition: all 0.3s ease;
}

.status-badge-jarvis.online {
    background: rgba(0, 96, 255, 0.15);
    border: 1px solid rgba(0, 96, 255, 0.4);
    color: var(--jarvis-primary);
    box-shadow: 0 0 15px rgba(0, 96, 255, 0.2);
}

.status-badge-jarvis.processing {
    background: rgba(255, 171, 0, 0.15);
    border: 1px solid rgba(255, 171, 0, 0.4);
    color: #ffab00;
    animation: badge-pulse 1s ease-in-out infinite;
}

.status-badge-jarvis.offline {
    background: rgba(255, 82, 82, 0.15);
    border: 1px solid rgba(255, 82, 82, 0.4);
    color: #ff5252;
}

@keyframes badge-pulse {
    0%, 100% { box-shadow: 0 0 15px rgba(255, 171, 0, 0.2); }
    50% { box-shadow: 0 0 25px rgba(255, 171, 0, 0.5); }
}

/* ============================================
   GLOW EFFECTS
   ============================================ */

.glow-blue {
    box-shadow: 0 0 20px var(--jarvis-glow);
}

.glow-purple {
    box-shadow: 0 0 20px rgba(157, 78, 221, 0.4);
}

.glow-gold {
    box-shadow: 0 0 20px rgba(255, 215, 0, 0.4);
}

/* Text glow */
.text-glow-blue {
    text-shadow: 0 0 10px rgba(0, 96, 255, 0.6);
}

/* Border glow animation */
.border-glow {
    position: relative;
}

.border-glow::after {
    content: '';
    position: absolute;
    inset: -2px;
    border-radius: inherit;
    background: linear-gradient(45deg, var(--jarvis-primary), var(--jarvis-purple), var(--jarvis-primary));
    background-size: 300% 300%;
    animation: border-glow-move 3s linear infinite;
    z-index: -1;
    opacity: 0.5;
}

@keyframes border-glow-move {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

/* ============================================
   PANEL CARDS (Stile dashboard)
   ============================================ */

.panel-jarvis {
    background: rgba(20, 20, 26, 0.95);
    border: 1px solid rgba(0, 96, 255, 0.2);
    border-radius: 12px;
    padding: 20px;
    transition: all 0.3s ease;
}

.panel-jarvis:hover {
    border-color: rgba(0, 96, 255, 0.4);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3), 0 0 30px rgba(0, 96, 255, 0.1);
}

.panel-jarvis .panel-title {
    color: var(--jarvis-primary);
    font-weight: 600;
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.panel-jarvis .panel-title::before {
    content: '';
    width: 4px;
    height: 16px;
    background: var(--jarvis-primary);
    border-radius: 2px;
    box-shadow: 0 0 10px var(--jarvis-primary);
}

/* ============================================
   SMOOTH TRANSITIONS
   ============================================ */

.fade-in {
    animation: fade-in 0.3s ease-out;
}

.slide-up {
    animation: slide-up 0.4s ease-out;
}

.scale-in {
    animation: scale-in 0.3s ease-out;
}

@keyframes fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slide-up {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes scale-in {
    from { opacity: 0; transform: scale(0.9); }
    to { opacity: 1; transform: scale(1); }
}

/* ============================================
   JARVIS WAVEFORM (Audio Visualizer)
   ============================================ */

.jarvis-waveform {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 3px;
    height: 32px;
    padding: 0 8px;
}

.jarvis-waveform .wave-bar {
    width: 4px;
    height: 8px;
    background: var(--jarvis-primary);
    border-radius: 2px;
    transition: height 0.1s ease;
}

.jarvis-waveform.active .wave-bar {
    animation: waveform-pulse 0.8s ease-in-out infinite;
    box-shadow: 0 0 8px var(--jarvis-glow);
}

.jarvis-waveform .wave-bar:nth-child(1) { animation-delay: 0s; }
.jarvis-waveform .wave-bar:nth-child(2) { animation-delay: 0.1s; }
.jarvis-waveform .wave-bar:nth-child(3) { animation-delay: 0.2s; }
.jarvis-waveform .wave-bar:nth-child(4) { animation-delay: 0.3s; }
.jarvis-waveform .wave-bar:nth-child(5) { animation-delay: 0.4s; }
.jarvis-waveform .wave-bar:nth-child(6) { animation-delay: 0.3s; }
.jarvis-waveform .wave-bar:nth-child(7) { animation-delay: 0.2s; }

@keyframes waveform-pulse {
    0%, 100% {
        height: 8px;
        opacity: 0.5;
    }
    50% {
        height: 24px;
        opacity: 1;
    }
}

/* Waveform variante circolare */
.jarvis-waveform-circle {
    position: relative;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.jarvis-waveform-circle .circle-core {
    width: 16px;
    height: 16px;
    background: var(--jarvis-primary);
    border-radius: 50%;
    box-shadow: 0 0 15px var(--jarvis-glow);
}

.jarvis-waveform-circle .circle-wave {
    position: absolute;
    border: 2px solid var(--jarvis-primary);
    border-radius: 50%;
    opacity: 0;
}

.jarvis-waveform-circle.active .circle-wave {
    animation: circle-wave-expand 1.5s ease-out infinite;
}

.jarvis-waveform-circle .circle-wave:nth-child(2) { animation-delay: 0s; }
.jarvis-waveform-circle .circle-wave:nth-child(3) { animation-delay: 0.5s; }
.jarvis-waveform-circle .circle-wave:nth-child(4) { animation-delay: 1s; }

@keyframes circle-wave-expand {
    0% {
        width: 16px;
        height: 16px;
        opacity: 0.8;
    }
    100% {
        width: 48px;
        height: 48px;
        opacity: 0;
    }
}

/* Waveform compatto per header */
.jarvis-waveform-mini {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    height: 20px;
    padding: 0 4px;
}

.jarvis-waveform-mini .wave-bar {
    width: 3px;
    height: 6px;
    background: var(--jarvis-primary);
    border-radius: 1px;
}

.jarvis-waveform-mini.active .wave-bar {
    animation: waveform-mini-pulse 0.6s ease-in-out infinite;
}

.jarvis-waveform-mini .wave-bar:nth-child(1) { animation-delay: 0s; }
.jarvis-waveform-mini .wave-bar:nth-child(2) { animation-delay: 0.1s; }
.jarvis-waveform-mini .wave-bar:nth-child(3) { animation-delay: 0.2s; }
.jarvis-waveform-mini .wave-bar:nth-child(4) { animation-delay: 0.1s; }
.jarvis-waveform-mini .wave-bar:nth-child(5) { animation-delay: 0s; }

@keyframes waveform-mini-pulse {
    0%, 100% { height: 6px; }
    50% { height: 16px; }
}

/* ============================================
   RESPONSIVE JARVIS
   ============================================ */

@media (max-width: 768px) {
    .jarvis-container {
        width: 150px;
        height: 150px;
    }

    .jarvis-core { width: 40px; height: 40px; }
    .jarvis-ring-1 { width: 60px; height: 60px; }
    .jarvis-ring-2 { width: 90px; height: 90px; }
    .jarvis-ring-3 { width: 120px; height: 120px; }
    .jarvis-ring-4 { width: 150px; height: 150px; }
}

/* ============================================
   CODE BLOCKS — Claude.ai style
   ============================================ */

.code-block-wrapper {
    margin: 12px 0;
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: #1e1e2e;
}

.code-block-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 14px;
    background: rgba(255, 255, 255, 0.04);
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.code-block-lang {
    font-family: 'JetBrains Mono', 'Consolas', monospace;
    font-size: 0.72rem;
    color: rgba(255, 255, 255, 0.45);
    text-transform: lowercase;
    font-weight: 500;
}

.code-copy-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    color: rgba(255, 255, 255, 0.5);
    font-size: 0.72rem;
    font-family: 'Space Grotesk', sans-serif;
    cursor: pointer;
    transition: all 0.2s ease;
}

.code-copy-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.8);
    border-color: rgba(255, 255, 255, 0.2);
}

.code-copy-btn svg {
    stroke: currentColor;
}

.code-block-wrapper pre {
    margin: 0;
    padding: 14px 16px;
    overflow-x: auto;
    background: transparent;
}

.code-block-wrapper pre code {
    font-family: 'JetBrains Mono', 'Consolas', 'Monaco', monospace;
    font-size: 0.85rem;
    line-height: 1.6;
    color: #e0e0e0;
    tab-size: 4;
}

/* Inline code */
.inline-code {
    background: rgba(0, 96, 255, 0.12);
    color: #7dd3fc;
    padding: 2px 7px;
    border-radius: 5px;
    font-family: 'JetBrains Mono', 'Consolas', monospace;
    font-size: 0.88em;
    border: 1px solid rgba(0, 96, 255, 0.15);
}

/* ============================================
   TYPEWRITER EFFECT
   ============================================ */

.typewriter-cursor {
    display: inline-block;
    color: var(--jarvis-primary, #0060ff);
    font-weight: 300;
    animation: cursor-blink 0.8s step-end infinite;
    margin-left: 1px;
}

@keyframes cursor-blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

/* Smooth response rendering */
.response-content {
    font-family: 'Space Grotesk', 'Segoe UI', sans-serif;
}

.response-content strong {
    color: #ffffff;
    font-weight: 600;
}

.response-content em {
    color: #a0a0b0;
    font-style: italic;
}

/* ============================================
   JARVIS 3D — Container Styles
   ============================================ */

#jarvis-3d-container {
    background: #0f0f14;
    border: none;
    box-shadow: none;
    outline: none;
    overflow: visible;
}

#jarvis-3d-container canvas {
    display: block;
    border: none;
}

/* ============================================
   DARK MODE ENHANCEMENTS
   ============================================ */

* {
    color-scheme: dark;
}

input, textarea, select {
    background: #12122a !important;
    color: #e0e0f0 !important;
    border: 1px solid rgba(0, 120, 255, 0.3) !important;
}

::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: #0a0a14;
}

::-webkit-scrollbar-thumb {
    background: rgba(0, 120, 255, 0.3);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 120, 255, 0.5);
}
