/* 
   🚀 CAPTAIN JIMMY: CORE PRODUCT DESIGN (v4.0 - 2026)
   Concept: The Neural Link / Centered Console
   Philosophy: Product, not Widget.
   Performance: GPU Layer Promotion, zero-jank.
*/

:root {
    /* --- 🎨 PALETTE: MIDNIGHT NEURAL 2026 --- */
    --j-void-deep: #010204;
    --j-navy-deep: #050a1b;
    --j-accent: #38bdf8;

    /* --- 💎 ADVANCED CRYSTALLINE PHYSICS --- */
    --j-glass-bg: rgba(6, 8, 15, 0.85);
    --j-glass-border: rgba(255, 255, 255, 0.1);
    --j-glass-highlight: rgba(255, 255, 255, 0.15);
    --j-glass-blur: 24px; 
    --j-shadow-deep: 0 40px 100px -20px rgba(0, 0, 0, 0.9), 0 0 0 1px rgba(255, 255, 255, 0.05);

    /* --- 📏 DIMENSIONS (CINEMA-WIDE 2026) --- */
    --j-desktop-w: 880px;
    --j-desktop-h: 620px;
    --j-mobile-z: 10000;

    /* --- 🎭 MOTION: 2026 ELASTIC PROTOCOL --- */
    --j-ease-snap: cubic-bezier(0.16, 1, 0.3, 1);
    --j-ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
    --j-ease-fluid: cubic-bezier(0.19, 1, 0.22, 1);
}

/* --- 🧊 CONTAINER & RESET --- */
#jimmy-root {
    font-family: 'Cairo', 'Outfit', sans-serif;
    color: #e2e8f0;
    -webkit-font-smoothing: antialiased;
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: var(--j-mobile-z);
    isolation: isolate;
}

#jimmy-root * {
    box-sizing: border-box;
}

/* --- 👁️ THE LAUNCHER ("THE SUMMONER") --- */
.j-launcher {
    position: fixed;
    bottom: 32px;
    right: 32px;
    width: 64px;
    height: 64px;
    pointer-events: auto;
    cursor: pointer;
    z-index: 10001;
    background: transparent;
    border: none;
    transition: transform 0.5s var(--j-ease-spring), opacity 0.3s ease;
    will-change: transform;
    display: flex;
    align-items: center;
    justify-content: center;
}

.j-launcher:hover {
    transform: translateY(-6px) scale(1.1);
}

.j-launcher.active {
    opacity: 0;
    transform: scale(0.8);
    pointer-events: none;
}

.j-launcher img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    filter: drop-shadow(0 0 15px rgba(56, 189, 248, 0.4));
}

/* --- 🖥️ CONSOLE BACKDROP --- */
.j-console-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 2, 5, 0.6);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.5s var(--j-ease-fluid), visibility 0.5s;
    pointer-events: auto;
    z-index: 10001;
}

#jimmy-root.is-open .j-console-backdrop {
    opacity: 1;
    visibility: visible;
}

/* --- 🖥️ CONSOLE MAIN --- */
.j-console {
    position: fixed;
    top: 50%;
    left: 50%;
    width: var(--j-desktop-w);
    height: var(--j-desktop-h);
    z-index: 10002;
    background: var(--j-glass-bg);
    backdrop-filter: blur(var(--j-glass-blur));
    -webkit-backdrop-filter: blur(var(--j-glass-blur));
    border: 1px solid var(--j-glass-border);
    box-shadow: var(--j-shadow-deep);
    border-radius: 32px;
    background-image:
        radial-gradient(circle at 50% -10%, rgba(56, 189, 248, 0.15), transparent 60%);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: translate(-50%, -45%) scale(0.95);
    opacity: 0;
    visibility: hidden;
    transition: transform 0.6s var(--j-ease-spring), opacity 0.4s ease, visibility 0.4s;
    pointer-events: none;
    will-change: transform, opacity;
}

#jimmy-root.is-open .j-console {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, -50%) scale(1);
    pointer-events: auto;
}

/* --- 🧱 CONSOLE LAYOUT --- */
.j-header {
    height: 80px;
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    background: linear-gradient(to bottom, rgba(255, 255, 255, 0.03), transparent);
    z-index: 20;
    cursor: grab;
}

.j-header:active { cursor: grabbing; }

.j-identity {
    display: flex;
    align-items: center;
    gap: 14px;
}

.j-hud-data {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.j-meta-row {
    display: flex;
    gap: 8px;
    align-items: center;
    opacity: 0.5;
}

.j-ping-tag, .j-ver-tag {
    font-family: 'Space Grotesk', monospace;
    font-size: 0.65rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    color: var(--j-accent);
    text-transform: uppercase;
}

.j-avatar-sm {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.j-avatar-sm img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.j-title {
    font-family: 'Outfit', sans-serif;
    font-size: 1rem;
    font-weight: 700;
    color: #fff;
    letter-spacing: 0.02em;
    text-shadow: 0 0 20px rgba(56, 189, 248, 0.5);
}

.j-status-pulse {
    width: 8px;
    height: 8px;
    background: #10b981;
    border-radius: 50%;
    box-shadow: 0 0 10px #10b981;
    margin-left: 4px;
    animation: j-status-blink 2s infinite;
}

@keyframes j-status-blink {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(0.8); }
}

.j-btn-icon {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: rgba(255, 255, 255, 0.05);
    color: rgba(255, 255, 255, 0.6);
    cursor: pointer;
    transition: all 0.3s var(--j-ease-fluid);
}

.j-btn-icon:hover {
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    transform: scale(1.05);
}

/* --- 💬 STREAM (BODY) --- */
.j-stream {
    flex: 1;
    overflow-y: auto;
    padding: 32px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.1) transparent;
}

.j-stream::-webkit-scrollbar { width: 4px; }
.j-stream::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.1); border-radius: 10px; }

.j-msg-row {
    display: flex;
    gap: 12px;
    max-width: 85%;
    align-items: flex-end;
}

.j-msg-row.ai { align-self: flex-start; }
.j-msg-row.user { align-self: flex-end; flex-direction: row-reverse; }

.j-row-icon {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.03);
    padding: 6px;
    color: var(--j-accent);
}

.j-bubble {
    padding: 14px 20px;
    border-radius: 20px;
    font-size: 0.95rem;
    line-height: 1.55;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.05);
    color: #e2e8f0;
}

.j-msg-row.ai .j-bubble { border-bottom-left-radius: 4px; }
.j-msg-row.user .j-bubble {
    background: linear-gradient(135deg, rgba(56, 189, 248, 0.12), rgba(56, 189, 248, 0.05));
    border-color: rgba(56, 189, 248, 0.2);
    border-bottom-right-radius: 4px;
    color: #fff;
}

/* Neural Thinking */
.j-typing {
    display: flex;
    gap: 6px;
    padding: 16px 22px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 18px;
    border-bottom-left-radius: 4px;
    width: fit-content;
}

.j-dot {
    width: 6px;
    height: 6px;
    background: var(--j-accent);
    border-radius: 50%;
    animation: j-neural-pulse 1.4s infinite ease-in-out;
}
.j-dot:nth-child(2) { animation-delay: 0.2s; }
.j-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes j-neural-pulse {
    0%, 100% { transform: scale(0.8); opacity: 0.3; }
    50% { transform: scale(1.2); opacity: 1; box-shadow: 0 0 8px var(--j-accent); }
}

/* --- ⌨️ INPUT AREA --- */
.j-footer {
    padding: 20px 32px 32px;
}

.j-chips-rail {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    overflow-x: auto;
    padding-bottom: 4px;
    scrollbar-width: none;
}
.j-chips-rail::-webkit-scrollbar { display: none; }

.j-chip {
    padding: 8px 16px;
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.6);
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.3s var(--j-ease-fluid);
}
.j-chip:hover {
    background: rgba(56, 189, 248, 0.1);
    border-color: var(--j-accent);
    color: #fff;
}

.j-input-scaffold {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    padding: 6px 10px;
    display: flex;
    align-items: flex-end;
    transition: all 0.3s ease;
}

.j-input-scaffold:focus-within {
    border-color: rgba(56, 189, 248, 0.4);
    background: rgba(255, 255, 255, 0.06);
    box-shadow: 0 0 20px rgba(56, 189, 248, 0.1);
}

.j-textarea {
    flex: 1;
    background: transparent;
    border: none;
    color: #fff;
    font-size: 1rem;
    padding: 10px 12px;
    max-height: 120px;
    min-height: 44px;
    resize: none;
    outline: none;
}

.j-send-btn {
    width: 40px;
    height: 40px;
    background: var(--j-accent);
    color: #000;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    cursor: pointer;
    transition: all 0.3s var(--j-ease-spring);
}
.j-send-btn:hover { transform: scale(1.1); box-shadow: 0 0 15px var(--j-accent); }

/* --- 📱 MOBILE CONSOLE (UP TO 768px) --- */
@media (max-width: 768px) {
    .j-launcher {
        bottom: 20px;
        right: 20px;
        width: 56px;
        height: 56px;
    }

    .j-console {
        width: 100%;
        height: 100%;
        top: 0 !important;
        left: 0 !important;
        transform: translateY(100%) !important;
        border-radius: 0;
        border: none;
        background: #010204;
        background-image: radial-gradient(circle at 50% 10%, #050a1b 0%, #010204 100%);
    }

    #jimmy-root.is-open .j-console {
        transform: translateY(0) !important;
    }

    .j-header {
        height: 72px;
        padding: 0 20px;
        cursor: default;
    }

    .j-stream {
        padding: 20px;
        gap: 16px;
    }

    .j-footer {
        padding: 16px 20px calc(20px + env(safe-area-inset-bottom));
        background: rgba(1, 2, 4, 0.8);
        backdrop-filter: blur(10px);
    }

    .j-msg-row { max-width: 90%; }
    .j-bubble { padding: 12px 16px; font-size: 0.9rem; }
}