/* /the-perfection-paradox/chatbot-styles.css - V2 REWORK */
/* --- NEW: Prevent Layout Shift on Scrollbar Toggle --- */
html {
    scrollbar-gutter: stable;
}
/* --- 1. NEXUS AI PULL TAB (V4 - SIMPLIFIED) --- */
@keyframes subtlePulse {
    0% { border-color: rgba(74, 144, 226, 0.4); }
    50% { border-color: rgba(74, 144, 226, 0.8); }
    100% { border-color: rgba(74, 144, 226, 0.4); }
}

.nexus-ai-pull-tab-side {
    position: fixed;
    bottom: 40px;
    /* This is the full width of the tab when hovered */
    /* 10px pad + 22px icon + 10px margin + 80px text + 10px pad = 132px */
    width: 132px;
    z-index: 9990;

    display: flex;
    align-items: center;

    background: rgba(15, 17, 26, 0.7);
    border: 1px solid rgba(74, 144, 226, 0.4);
    border-right: none;
    padding: 10px;
    border-radius: 10px 0 0 10px;

    cursor: pointer;
    backdrop-filter: blur(5px);
    color: rgba(74, 144, 226, 0.8);
    box-sizing: border-box; /* Ensures padding is included in width */

    /* --- PERFORMANCE IMPROVEMENT --- */

    /* 1. Pin the tab to the right edge */
    right: 0;

    /* 2. This is the resting "peek" state. */
    /* We push it 90px off-screen, leaving 42px visible. */
    /* Animating 'transform' is much smoother for browsers than animating 'right'. */
    transform: translateX(90px);

    /* 3. Your pulse animation */
    animation: subtlePulse 3s infinite 2s;

   /* 4. MERGED & CORRECTED Transitions: */
    /* This is the single, corrected transition rule */
    transition: transform 0.4s cubic-bezier(0.25, 1, 0.5, 1),
                box-shadow 0.3s ease,
                color 0.3s ease,
                opacity 0.4s ease; /* <-- FIX: Added this line */
}

/* This is the new rule that makes the hover animation work */
.nexus-ai-pull-tab-side:hover {
    /* This pulls the tab fully into view */
    transform: translateX(0);

    /* Optional: Enhanced hover state from your original transition */
    color: #fff;
    box-shadow: 0 0 15px rgba(74, 144, 226, 0.6);
    /* Pauses the pulse animation on hover */
    animation-play-state: paused;
}

.nexus-ai-pull-tab-side .tab-icon {
    width: 22px;
    height: 22px;
    flex-shrink: 0;
    /* Icon transition (but no transform) */
    transition: transform 0.4s cubic-bezier(0.25, 1, 0.5, 1);
}

.nexus-ai-pull-tab-side .tab-text {
    font-family: 'Oxanium', sans-serif;
    font-weight: 600;
    letter-spacing: 1px;
    font-size: 0.9rem;
    white-space: nowrap;
    /* Text is now always visible, just positioned off-screen */
    opacity: 1;
    width: 80px;
    margin-left: 10px;
}

/* --- STATES --- */

body.terminal-active .nexus-ai-pull-tab-side {
    /* 5. Hide the tab when the terminal is open */
    /* This needs to match the transform property */
    transform: translateX(150px); /* Fully off-screen */
    opacity: 0;
    pointer-events: none;
}
/* --- HIDE AI TAB DURING LIVE RESET --- */
/* This rule slides the AI tab off-screen when the
   'ai-tab-hidden' class is added to the body tag. */
body.ai-tab-hidden .nexus-ai-pull-tab-side {
    transform: translateX(150px) !important;
    opacity: 0;
    pointer-events: none;
}


/* --- 2. FULL-SCREEN TERMINAL OVERLAY --- */
.nexus-ai-terminal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9998;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(9, 10, 15, 0.5);
    backdrop-filter: blur(8px);

    /* Hidden by default */
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.4s ease, visibility 0.4s ease;
}

/* --- 3. THE MAIN TERMINAL CONTAINER --- */
.nexus-ai-terminal .terminal-container {
    width: 90%;
    max-width: 800px;
    height: 80vh;
    max-height: 700px;
    background-color: rgba(15, 17, 26, 0.85);
    border: 1px solid rgba(74, 144, 226, 0.3);
    box-shadow: 0 0 40px rgba(74, 144, 226, 0.15);
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: scale(0.95);
    transition: transform 0.4s ease;
    /* Subtle grid background */
    background-image:
        linear-gradient(rgba(74, 144, 226, 0.05) 1px, transparent 1px),
        linear-gradient(90deg, rgba(74, 144, 226, 0.05) 1px, transparent 1px);
    background-size: 20px 20px;
}

/* --- 4. VISIBILITY & ACTIVE STATES --- */
body.terminal-active .nexus-ai-terminal {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}
body.terminal-active .nexus-ai-terminal .terminal-container {
    transform: scale(1);
}
body.terminal-active {
    overflow: hidden;
}

/* --- 5. TERMINAL HEADER --- */
.terminal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    border-bottom: 1px solid rgba(74, 144, 226, 0.2);
    flex-shrink: 0;
}
.system-status {
    display: flex;
    align-items: center;
    gap: 10px;
    font-family: 'monospace', 'Courier New', Courier;
    font-size: 0.9rem;
    color: #66ffbe;
    text-shadow: 0 0 5px #66ffbe;
    animation: text-flicker 15s linear infinite;
}
.status-light {
    width: 10px;
    height: 10px;
    background-color: #66ffbe;
    border-radius: 50%;
    box-shadow: 0 0 8px #66ffbe;
    animation: light-pulse 2s infinite;
}
.disconnect-btn {
    background: transparent;
    border: 1px solid rgba(220, 53, 69, 0.7);
    color: rgba(220, 53, 69, 1);
    padding: 5px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
    font-size: 0.8rem;
    transition: background-color 0.2s, color 0.2s;
}
.disconnect-btn:hover {
    background-color: rgba(220, 53, 69, 1);
    color: #fff;
}

/* --- 6. CHATBOX & MESSAGES --- */
.terminal-chatbox {
    flex-grow: 1;
    overflow-y: auto;
    padding: 20px;
    list-style-type: none;
    margin: 0;
}
/* Custom Scrollbar */
.terminal-chatbox::-webkit-scrollbar { width: 6px; }
.terminal-chatbox::-webkit-scrollbar-track { background: transparent; }
.terminal-chatbox::-webkit-scrollbar-thumb { background: rgba(74, 144, 226, 0.3); border-radius: 3px; }

.terminal-chatbox .chat {
    margin-bottom: 15px;
    animation: fade-in-up 0.5s ease-out forwards;
}
.terminal-chatbox .chat p {
    margin: 0;
    padding: 12px 15px;
    font-size: 0.95rem;
    line-height: 1.5;
    white-space: pre-wrap;
    word-wrap: break-word;
    max-width: 90%;
    color: #ddd;
    background: rgba(0,0,0,0.1);
}
.terminal-chatbox .chat.incoming p {
    border-left: 3px solid #66ffbe;
    background: linear-gradient(90deg, rgba(102, 255, 190, 0.1), transparent);
}
.terminal-chatbox .chat.outgoing {
    display: flex;
    justify-content: flex-end;
}
.terminal-chatbox .chat.outgoing p {
    border-right: 3px solid #4a90e2;
    text-align: right;
    background: linear-gradient(-90deg, rgba(74, 144, 226, 0.1), transparent);
}

/* Nexus AI spoiler: button + hidden content until user reveals */
.nexus-ai-spoiler-wrap {
    display: block;
    margin-top: 10px;
}
.nexus-ai-spoiler-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    font-size: 0.85rem;
    font-family: inherit;
    color: #66ffbe;
    background: rgba(102, 255, 190, 0.12);
    border: 1px solid rgba(102, 255, 190, 0.4);
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s, color 0.2s;
}
.nexus-ai-spoiler-btn:hover {
    background: rgba(102, 255, 190, 0.2);
    border-color: #66ffbe;
}
.nexus-ai-spoiler {
    display: none;
    margin-top: 10px;
    padding: 10px 0 0;
    border-top: 1px dashed rgba(102, 255, 190, 0.3);
    white-space: pre-wrap;
    word-wrap: break-word;
}
.nexus-ai-spoiler.revealed {
    display: block;
}

/* --- 7. INPUT AREA --- */
.terminal-input-area {
    display: flex;
    gap: 10px;
    padding: 15px;
    border-top: 1px solid rgba(74, 144, 226, 0.2);
    flex-shrink: 0;
}
.terminal-input-area textarea {
    flex-grow: 1;
    background: transparent;
    border: none;
    border-bottom: 1px solid rgba(74, 144, 226, 0.3);
    color: #fff;
    font-size: 1rem;
    padding: 8px 5px;
    resize: none;
    height: 55px; /* Default height */
    max-height: 120px;
    outline: none;
    transition: border-color 0.3s;
}
.terminal-input-area textarea:focus {
    border-bottom-color: #66ffbe;
}
.transmit-btn {
    width: 55px;
    height: 55px;
    flex-shrink: 0;
    border: 1px solid rgba(74, 144, 226, 0.7);
    background: rgba(74, 144, 226, 0.2);
    color: #4a90e2;
    border-radius: 6px;
    cursor: pointer;
    transition: background-color 0.2s, color 0.2s, border-color 0.2s;
}
.transmit-btn:hover {
    background: #4a90e2;
    color: #fff;
    border-color: #4a90e2;
}

/* --- 8. ANIMATIONS --- */
@keyframes text-flicker {
    0%, 19%, 21%, 59%, 61%, 100% { text-shadow: 0 0 5px #66ffbe; color: #66ffbe; }
    20%, 60% { text-shadow: none; color: #8affd3; }
}
@keyframes light-pulse {
    0% { box-shadow: 0 0 8px #66ffbe; }
    50% { box-shadow: 0 0 15px 5px #66ffbe; }
    100% { box-shadow: 0 0 8px #66ffbe; }
}
@keyframes fade-in-up {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* New Typing Animation */

@keyframes blink {
    from, to { opacity: 1; }
    50% { opacity: 0; }
}
/* --- NEW: Typing Caret Animation --- */
.typing-caret::after {
    content: '▋';
    display: inline-block;
    animation: blink 1s step-end infinite;
    color: #66ffbe;
    margin-left: 8px;
}
/* --- NEW: 9. LOGGED-OUT STATE STYLING --- */

/* By default, the static message is hidden */
.static-auth-message {
    display: none;
}

/* When in logged-out mode, HIDE the chat input area */
.nexus-ai-terminal.logged-out-mode .terminal-input-area {
    display: none;
}

/* When in logged-out mode, HIDE all normal chat messages */
.nexus-ai-terminal.logged-out-mode .chat {
    display: none;
}

/* When in logged-out mode, SHOW the static message */
.nexus-ai-terminal.logged-out-mode .static-auth-message {
    display: block;
    color: #ccc;
    padding: 20px;
    border: 1px dashed rgba(220, 53, 69, 0.4);
    background: rgba(220, 53, 69, 0.05);
    border-radius: 4px;
}

.static-auth-message h3 {
    margin-top: 0;
    color: #f56c6c;
    text-shadow: 0 0 5px rgba(220, 53, 69, 0.7);
    font-family: 'monospace', 'Courier New', Courier;
}

.static-auth-message a {
    color: #4a90e2;
    text-decoration: none;
    font-weight: bold;
}
.static-auth-message a:hover {
    text-decoration: underline;
}

.static-auth-message ul {
    list-style-type: '» ';
    padding-left: 20px;
}

/* --- Nexus Notification System (V4 - Interactive Toasts) --- */

/* 1. Container */
#nexus-notification-container {
    position: fixed;
    bottom: 30px;
    left: 35px;
    z-index: 9999;
    width: 340px;
    display: flex;
    flex-direction: column-reverse;
    align-items: flex-start;
}

/* 2. Toast Base */
.nexus-notification {
    background: rgba(15, 17, 26, 0.9);
    backdrop-filter: blur(10px);
    color: #f1f1f1;
    padding: 14px 18px;
    border-radius: 8px;
    border: 1px solid rgba(74, 144, 226, 0.3);
    border-left: 4px solid rgba(74, 144, 226, 0.5);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    font-size: 0.9rem;
    margin-top: 12px;
    width: 100%;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    position: relative;
    overflow: hidden;
    transition: transform 0.4s ease-in-out;
    box-sizing: border-box;
}

/* 3. Toast Icon */
.nexus-notif-icon {
    font-size: 1.15rem !important;
    flex-shrink: 0;
    margin-top: 1px;
    color: rgba(255, 255, 255, 0.6);
}

.nexus-notif-body {
    flex: 1;
    line-height: 1.4;
    min-width: 0;
}

/* 4. Type-Specific Styles */
.nexus-notification.success        { border-left-color: #67c23a; }
.nexus-notification.error          { border-left-color: #f56c6c; }
.nexus-notification.dm             { border-left-color: #4a90e2; }
.nexus-notification.nakama_request { border-left-color: #a78bfa; }
.nexus-notification.like           { border-left-color: #f87171; }
.nexus-notification.announcement   { border-left-color: #22c55e; }
.nexus-notification.review         { border-left-color: #a78bfa; }
.nexus-notification.system         { border-left-color: #f59e0b; }
.nexus-notification.info           { border-left-color: #4a90e2; }
.nexus-notification.warning        { border-left-color: #f59e0b; }

/* Type-specific icon colors */
.nexus-notification.dm .nexus-notif-icon             { color: #4a90e2; }
.nexus-notification.nakama_request .nexus-notif-icon  { color: #a78bfa; }
.nexus-notification.like .nexus-notif-icon           { color: #f87171; }
.nexus-notification.success .nexus-notif-icon        { color: #67c23a; }
.nexus-notification.error .nexus-notif-icon          { color: #f56c6c; }
.nexus-notification.announcement .nexus-notif-icon   { color: #22c55e; }
.nexus-notification.review .nexus-notif-icon         { color: #a78bfa; }
.nexus-notification.system .nexus-notif-icon         { color: #f59e0b; }
.nexus-notification.info .nexus-notif-icon           { color: #4a90e2; }
.nexus-notification.warning .nexus-notif-icon        { color: #f59e0b; }

/* 5. Clickable Toasts */
.nexus-notification.is-clickable-toast {
    cursor: pointer;
}
.nexus-notification.is-clickable-toast:hover {
    background: rgba(20, 23, 36, 0.95);
    border-color: rgba(74, 144, 226, 0.5);
}

/* 6. Progress Bar */
.nexus-notif-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 2px;
    background: rgba(74, 144, 226, 0.5);
    width: 100%;
    animation: notifProgressShrink linear forwards;
}

@keyframes notifProgressShrink {
    from { width: 100%; }
    to   { width: 0; }
}

/* Match progress bar color to notification type */
.nexus-notification.success .nexus-notif-progress        { background: rgba(103, 194, 58, 0.5); }
.nexus-notification.error .nexus-notif-progress          { background: rgba(245, 108, 108, 0.5); }
.nexus-notification.dm .nexus-notif-progress             { background: rgba(74, 144, 226, 0.5); }
.nexus-notification.like .nexus-notif-progress           { background: rgba(248, 113, 113, 0.5); }
.nexus-notification.nakama_request .nexus-notif-progress { background: rgba(167, 139, 250, 0.5); }
.nexus-notification.announcement .nexus-notif-progress   { background: rgba(34, 197, 94, 0.5); }

/* 7. Animations */
@keyframes slideInFromLeft {
    from { transform: translateX(-120%); opacity: 0; }
    to   { transform: translateX(0); opacity: 1; }
}
@keyframes slideOutToLeft {
    from { transform: translateX(0); opacity: 1; }
    to   { transform: translateX(-120%); opacity: 0; }
}
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-5px); }
    40%, 80% { transform: translateX(5px); }
}

.nexus-notification.is-entering {
    animation: slideInFromLeft 0.5s ease-out forwards;
}
.nexus-notification.is-leaving {
    animation: slideOutToLeft 0.5s ease-in forwards;
}
.nexus-notification.is-shaking {
    animation: shake 0.4s ease-in-out;
}
/* --- Custom Confirmation Modal System --- */

/* 1. The Overlay: Covers the screen with a blur effect */
.custom-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(9, 10, 15, 0.5);
    backdrop-filter: blur(8px);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;

    /* Animation properties */
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.custom-modal-overlay.is-visible {
    opacity: 1;
    visibility: visible;
}

/* 2. The Modal Content Box: Holds the text and buttons */
.custom-modal-content {
    background: #0f111a;
    border: 1px solid rgba(74, 144, 226, 0.2);
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    width: 90%;
    max-width: 450px;

    /* Animation properties */
    transform: scale(0.95);
    transition: transform 0.3s ease;
}

.custom-modal-overlay.is-visible .custom-modal-content {
    transform: scale(1);
}

/* 3. Header, Body, and Footer Styling */
.custom-modal-header {
    padding: 20px 25px;
    border-bottom: 1px solid rgba(74, 144, 226, 0.2);
}

.custom-modal-header h3 {
    margin: 0;
    font-size: 1.3rem;
    color: #fff;
}

.custom-modal-body {
    padding: 25px;
    font-size: 1rem;
    line-height: 1.6;
    color: #a9b3c1;
}

.custom-modal-body p {
    margin: 0;
}

.custom-modal-footer {
    padding: 20px 25px;
    background: rgba(0, 0, 0, 0.2);
    display: flex;
    justify-content: flex-end;
    gap: 15px;
    border-top: 1px solid rgba(74, 144, 226, 0.2);
    border-radius: 0 0 8px 8px;
}

/* 4. Button Styles */
.modal-btn {
    padding: 10px 20px;
    border: none;
    border-radius: 5px;
    font-weight: bold;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background-color 0.2s, transform 0.2s;
}
.modal-btn:hover {
    transform: translateY(-2px);
}

.modal-btn-secondary {
    background-color: #4a5568;
    color: #e2e8f0;
}
.modal-btn-secondary:hover {
    background-color: #64748b;
}

.modal-btn-primary {
    background-color: #d9534f; /* Red for destructive actions */
    color: #fff;
}
.modal-btn-primary:hover {
    background-color: #e16a66;
}
/* Add this to a global CSS file like chatbot-styles.css */
body.custom-modal-open {
    overflow: hidden;
    padding-right: var(--scrollbar-width);
}

/* --- HOTFIX: Force Nexus AI Tab to Bottom Right --- */
/* This rule corrects an override from another stylesheet 
   that incorrectly positions the tab at the top of the screen. */
.nexus-ai-pull-tab-side {
    position: fixed !important;
    bottom: 40px !important;
    top: auto !important; /* Explicitly unset any 'top' property */
    transform: translateX(90px) !important; 
}

.nexus-ai-pull-tab-side:hover {
    transform: translateX(0) !important;
}

/* ═══════════════════════════════════════════════════════════════
   NEXUS TERMINAL — MULTI-MODE SHELL (Phase 1)
   Tab bar, panel switching, pull-tab badge
═══════════════════════════════════════════════════════════════ */

/* ── Mode Tab Bar ──────────────────────────────────────────── */
.terminal-mode-tabs {
    display: flex;
    align-items: stretch;
    border-bottom: 1px solid rgba(255, 255, 255, 0.07);
    background: rgba(0, 0, 0, 0.22);
    flex-shrink: 0;
}

.terminal-mode-tab {
    position: relative;
    flex: 1;
    padding: 9px 6px;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    color: rgba(255, 255, 255, 0.4);
    font-family: inherit;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    transition: color 0.18s ease, border-color 0.18s ease, background 0.18s ease;
    white-space: nowrap;
    margin-bottom: -1px; /* overlap parent border-bottom */
}

.terminal-mode-tab .tab-label {
    pointer-events: none;
}

.terminal-mode-tab:hover {
    color: rgba(255, 255, 255, 0.72);
    background: rgba(255, 255, 255, 0.03);
}

.terminal-mode-tab.is-active {
    color: #66ffbe;
    border-bottom-color: #66ffbe;
    background: rgba(102, 255, 190, 0.04);
}

/* ── Badge on tabs ─────────────────────────────────────────── */
.terminal-tab-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 17px;
    height: 17px;
    padding: 0 4px;
    border-radius: 999px;
    background: #ef4444;
    color: #fff;
    font-size: 0.65rem;
    font-weight: 700;
    line-height: 1;
    letter-spacing: 0;
    transform: scale(0);
    transition: transform 0.15s cubic-bezier(0.34, 1.5, 0.64, 1);
    pointer-events: none;
}

.terminal-tab-badge:not(:empty) {
    transform: scale(1);
}

/* ── Pull-tab unread badge ─────────────────────────────────── */
.nexus-terminal-pull-badge {
    position: absolute;
    top: -8px;
    left: 4px;
    min-width: 17px;
    height: 17px;
    padding: 0 4px;
    border-radius: 999px;
    background: #ef4444;
    color: #fff;
    font-size: 0.65rem;
    font-weight: 700;
    line-height: 17px;
    text-align: center;
    transform: scale(0);
    transition: transform 0.15s cubic-bezier(0.34, 1.5, 0.64, 1);
    pointer-events: none;
}

.nexus-terminal-pull-badge:not(:empty) {
    transform: scale(1);
}

/* ── Pull-tab avatar preview bubbles ──────────────────────── */
.nexus-pull-avatars {
    position: fixed;
    right: 6px;
    bottom: 94px;
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 0;
    z-index: 9991;
    pointer-events: none;
}

.npa-bubble {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 2px solid rgba(74, 144, 226, 0.7);
    background: rgba(15, 17, 26, 0.95);
    overflow: hidden;
    box-shadow: -2px 0 8px rgba(0, 0, 0, 0.5);
    flex-shrink: 0;
    margin-left: -10px;
    opacity: 0;
    transform: translateY(12px) translateX(8px) scale(0.85);
    transition: opacity 0.22s ease, transform 0.22s cubic-bezier(0.34, 1.4, 0.64, 1);
}

.npa-bubble:first-child { margin-left: 0; z-index: 3; }
.npa-bubble:nth-child(2) { z-index: 2; }
.npa-bubble:nth-child(3) { z-index: 1; }

.npa-bubble.is-visible {
    opacity: 1;
    transform: translateY(0) translateX(0) scale(1);
}

.npa-bubble img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.npa-stack-count {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.6rem;
    font-weight: 700;
    color: #4a90e2;
    background: rgba(74, 144, 226, 0.15);
    letter-spacing: 0.5px;
}

body.terminal-active .nexus-pull-avatars,
body.ai-tab-hidden .nexus-pull-avatars {
    display: none;
}

/* ── AI Panel wrapper ──────────────────────────────────────── */
#terminal-ai-panel {
    display: flex;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
    min-height: 0; /* critical: lets flex children scroll */
}

/* ── Split Panel (Messages / Support) ─────────────────────── */
#terminal-split-panel {
    /* display: none set in HTML; JS toggles to flex */
    flex: 1;
    flex-direction: row;
    overflow: hidden;
    min-height: 0;
}

/* Restricted overlay for logged-out users — prevents bypass via devtools */
.split-panel-restricted {
    display: none;
    flex: 1;
    align-items: center;
    justify-content: center;
    padding: 20px;
    min-width: 0;
}
/* Hide real panels for logged-out users unless they are on guest reference Support (class set by nexus-messenger). */
.nexus-ai-terminal.logged-out-mode #terminal-split-panel:not(.guest-reference-support) .split-panel-restricted {
    display: flex !important;
}
.nexus-ai-terminal.logged-out-mode #terminal-split-panel:not(.guest-reference-support) .split-left-panel,
.nexus-ai-terminal.logged-out-mode #terminal-split-panel:not(.guest-reference-support) .split-right-panel {
    display: none !important;
}
.nexus-ai-terminal.logged-out-mode #terminal-split-panel.guest-reference-support .split-panel-restricted {
    display: none !important;
}
.nexus-ai-terminal.logged-out-mode #terminal-split-panel.guest-reference-support .split-left-panel,
.nexus-ai-terminal.logged-out-mode #terminal-split-panel.guest-reference-support .split-right-panel {
    display: flex !important;
}

.split-left-panel {
    width: 240px;
    flex-shrink: 0;
    border-right: 1px solid rgba(255, 255, 255, 0.07);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    background: rgba(0, 0, 0, 0.15);
}

.split-right-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
}

/* ── Responsive: stack vertically on small screens ─────────── */
@media (max-width: 640px) {
    #terminal-split-panel {
        flex-direction: column;
    }

    .split-left-panel {
        width: 100%;
        max-height: 180px;
        border-right: none;
        border-bottom: 1px solid rgba(255, 255, 255, 0.07);
    }

    .terminal-mode-tab {
        font-size: 0.65rem;
        padding: 8px 4px;
    }
}