/* Responsive Visibility Helpers */
.desktop-only { display: block; }

/* public/css/style.css */
body { margin: 0; overflow: hidden; font-family: 'Noto Sans SC', -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'Segoe UI', Roboto, Helvetica, Arial, sans-serif; background: #000; color: white; }

html::-webkit-scrollbar,
body::-webkit-scrollbar,
div::-webkit-scrollbar,
textarea::-webkit-scrollbar,
ul::-webkit-scrollbar,
ol::-webkit-scrollbar,
.scrollable-container::-webkit-scrollbar { width: 6px; height: 6px; }

html::-webkit-scrollbar-thumb,
body::-webkit-scrollbar-thumb,
div::-webkit-scrollbar-thumb,
textarea::-webkit-scrollbar-thumb,
ul::-webkit-scrollbar-thumb,
ol::-webkit-scrollbar-thumb,
.scrollable-container::-webkit-scrollbar-thumb { background: #475569; border-radius: 3px; }

html::-webkit-scrollbar-track,
body::-webkit-scrollbar-track,
div::-webkit-scrollbar-track,
textarea::-webkit-scrollbar-track,
ul::-webkit-scrollbar-track,
ol::-webkit-scrollbar-track,
.scrollable-container::-webkit-scrollbar-track { background: rgba(0,0,0,0.08); }

input, button, select, textarea { font-family: inherit; }

/* Hide Edge's default password reveal and clear buttons */
input[type="password"]::-ms-reveal,
input[type="password"]::-ms-clear {
    display: none;
}

/* HUD Common */
.hud-panel {
    position: absolute;
    background: rgba(15, 23, 42, 0.82);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 14px;
    padding: 12px;
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.5);
    color: #e2e8f0;
    z-index: 10;
}

/* Specific Panels */
#profile-hud { top: 20px; left: 20px; width: fit-content; min-width: 200px; max-width: 450px; }
#notif-hud { top: 20px; right: 20px; width: 280px; max-height: 300px; overflow-y: auto; display: none; }
#inspector-panel { top: 50%; right: 20px; transform: translateY(-50%); width: 300px; display: none; border-left: 4px solid #6366f1; }
#search-hud { top: 20px; left: 50%; transform: translateX(-50%); width: auto; background: none; border: none; box-shadow: none; padding: 0; backdrop-filter: none; -webkit-backdrop-filter: none; display: flex; justify-content: center; align-items: center; }
#connection-panel { top: 50%; left: 20px; transform: translateY(-50%); width: 250px; max-height: 60vh; display: flex; flex-direction: column; transition: width 0.3s ease, padding 0.3s ease; overflow: hidden; }
#connection-panel.collapsed { width: 40px; padding: 12px 6px; }
#connection-panel.collapsed .panel-title, #connection-panel.collapsed #connection-list { display: none; }
#connection-panel.collapsed .panel-header { justify-content: center; margin-bottom: 0; }


/* Components */
.user-header { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.avatar-circle { width: 48px; height: 48px; border-radius: 50%; object-fit: cover; border: 2px solid #6366f1; }
.command-bar { padding: 10px 12px; }
.command-bar-inner { display: flex; align-items: center; gap: 10px; }
.search-bar-wrapper { background: rgba(255,255,255,0.04); border-radius: 24px; border: 1px solid rgba(255,255,255,0.08); padding: 10px 12px; backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); width: auto; min-width: 300px; display: flex; align-items: center; gap: 10px; }
.command-icon { padding-left: 8px; opacity: 0.8; }
.command-input-wrap { flex:1; position: relative; display:flex; align-items:center; gap:8px; }
.badge { background: rgba(99,102,241,0.18); color: #c7d2fe; font-size: 0.8em; padding: 6px 10px; border-radius: 14px; margin-left: auto; }
.command-input-wrap .badge { position: relative; right: 6px; }
.identity-card { display: flex; flex-direction: column; gap: 12px; }
.identity-header { display: flex; justify-content: space-between; gap: 12px; align-items: center; }
.profile-header { display: flex; align-items: center; gap: 12px; }
.identity-main { display: flex; align-items: center; gap: 12px; }
.identity-meta { display: flex; flex-direction: column; gap: 2px; }
.username-label { white-space: nowrap; }
.user-handle, .user-id-label { font-size: 0.85em; color: #94a3b8; }
.identity-actions { display: flex; gap: 8px; align-items: center; }
.pill-btn { border: 1px solid rgba(255,255,255,0.14); background: rgba(255,255,255,0.06); color: #e2e8f0; padding: 8px 12px; border-radius: 999px; cursor: pointer; transition: transform 0.2s ease, background 0.2s ease, box-shadow 0.2s; }
.pill-btn.primary { background: linear-gradient(135deg, #6366f1, #4f46e5); color: #fff; border: none; }
.pill-btn.secondary { background: rgba(239,68,68,0.15); color: #fecdd3; border: 1px solid rgba(239,68,68,0.3); }
.pill-btn:hover, .icon-btn-compact:hover { transform: scale(1.05); box-shadow: 0 0 10px rgba(99, 102, 241, 0.3); filter: brightness(1.2); }
.icon-btn-compact { padding: 0; width: 38px; height: 38px; display: flex; align-items: center; justify-content: center; line-height: 1; transition: transform 0.2s ease, background 0.2s ease, box-shadow 0.2s; }
.identity-signature-row { display: flex; flex-direction: column; gap: 10px; }
.signature-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.hidden-form { display:none; }
.panel-header { display:flex; justify-content:space-between; align-items:center; margin-bottom:10px; }
.panel-toggle { background:none; border:none; color:white; cursor:pointer; }
.search-box { width: 100%; background: transparent; border: none; padding: 10px 12px; border-radius: 24px; color: white; outline:none; }
.action-btn { width: 100%; padding: 10px; margin-top: 16px; background: linear-gradient(135deg, #6366f1, #4f46e5); border: none; border-radius: 6px; color: white; font-weight: bold; cursor: pointer; }
#search-hud.command-bar { padding: 0; border-radius: 0; }
#search-input { width: 100%; box-sizing: border-box; flex: 1; background: transparent; border: none; }
#search-results { margin-top: 8px; background: #1e293b; border-radius: 12px; max-height: 200px; overflow-y: auto; display: none; }
.search-box::placeholder { color: #94a3b8; }
.search-bar-wrapper .search-box { padding: 8px 0; }
#node-count-display { background: rgba(255,255,255,0.08); border: 1px solid rgba(255,255,255,0.12); border-radius: 12px; padding: 4px 8px; margin-left: 8px; font-size: 0.75em; color: #e2e8f0; line-height: 1; }
.search-result-item { padding: 8px; cursor: pointer; border-bottom: 1px solid #475569; }
.search-result-item:hover { background: #334155; }
.search-result-item:last-child { border-bottom: none; }
.signature-container { margin-top: 10px; }
#signature-input { width: 100%; background: #1e293b; border: 1px solid #475569; color: white; padding: 6px; border-radius: 4px; box-sizing: border-box; font-family: inherit; resize: vertical; }
#signature-update-btn { width: 100%; background: #6366f1; color: white; border: none; padding: 6px; border-radius: 4px; margin-top: 6px; cursor: pointer; }
#my-signature { margin-bottom: 6px; font-style: italic; color: #cbd5e1; font-size: 0.9em; }
.signature-display {
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 100px;
    overflow-y: auto;
}
/* Scrollbar for signature display */
.signature-display::-webkit-scrollbar { width: 6px; }
.signature-display::-webkit-scrollbar-thumb { background: #475569; border-radius: 3px; }
.signature-display::-webkit-scrollbar-track { background: rgba(0,0,0,0.1); }

.rel-badge {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    margin-bottom: 8px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid transparent;
    gap: 8px;
}

.rel-badge.outgoing {
    background: rgba(248, 113, 113, 0.08);
}

.rel-badge.incoming {
    background: rgba(52, 211, 153, 0.08);
}

.rel-badge.mutual {
    justify-content: center;
    gap: 10px;
    background: rgba(236, 72, 153, 0.15);
    border: 1px solid #ec4899;
}

.rel-label {
    font-weight: 600;
}

.rel-icon {
    font-size: 1.1em;
}

.rel-tag {
    font-size: 0.75em;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #94a3b8;
    background: rgba(0, 0, 0, 0.3);
    padding: 2px 6px;
    border-radius: 4px;
}
.status-block { color: #cbd5e1; margin-top: 8px; }
.chip-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 8px; margin-top: 12px; }
.chip { background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.08); border-radius: 10px; padding: 8px 10px; display: flex; justify-content: space-between; align-items: center; font-size: 0.9em; }
.inspector-avatar { width:80px; height:80px; border-radius:50%; margin:0 auto 10px; display:block; border:3px solid #6366f1; }
.inspector-title { text-align:center; font-weight:bold; font-size:1.2em; }
.inspector-subtitle { text-align:center; color:#94a3b8; font-size:0.9em; margin-bottom: 8px; }
.inspector-content { background: rgba(0,0,0,0.3); padding:10px; border-radius:8px; margin-top:10px; color:#cbd5e1; font-style:italic; text-align: center; }
.inspector-actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(90px, 1fr)); gap: 8px; margin-top: 12px; }
.icon-btn { background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.1); color: #e2e8f0; padding: 8px 10px; border-radius: 10px; display: flex; gap: 6px; align-items: center; justify-content: center; cursor: pointer; }
.icon-btn span { font-size: 0.9em; }
.icon-btn.danger { border-color: rgba(239,68,68,0.3); color: #fecdd3; }
.action-form { display: flex; gap: 8px; margin-top: 10px; align-items: center; }
.select-compact { flex:1; background: #0f172a; border: 1px solid #334155; color: #e2e8f0; padding: 8px; border-radius: 10px; }

.unread-messages-container { margin-top: 10px; }
.unread-messages-header { font-weight: bold; margin-bottom: 8px; color: #38bdf8; }
.unread-item { cursor: pointer; background: rgba(56,189,248,0.1); padding: 8px; margin-bottom: 8px; border-radius: 6px; font-size: 0.9em; }
.requests-header { font-weight: bold; margin-bottom: 8px; color: #facc15; }
.logout-container { display: flex; justify-content: space-between; gap: 8px; margin-top: 10px; }
.logout-container .action-btn,
.logout-container .btn-secondary {
    margin-top: 0;
    flex: 1;
    padding: 6px 10px;
    font-size: 0.85rem;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.logout-container .btn-secondary { background: #ef4444; }

#zoom-btn {
    background: rgba(255, 255, 255, 0.1) !important;
    border: 1px solid rgba(255, 255, 255, 0.2) !important;
    color: #e2e8f0 !important;
}

#zoom-btn:hover {
    background: rgba(255, 255, 255, 0.2) !important;
    border-color: rgba(255, 255, 255, 0.4) !important;
}

/* Connection Panel */
#connection-list { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; }
#connection-list::-webkit-scrollbar { width: 6px; }
#connection-list::-webkit-scrollbar-thumb { background: #475569; border-radius: 3px; }
#connection-list::-webkit-scrollbar-track { background: rgba(0,0,0,0.1); }

/* Toast Notification (Unified in HUD) */
.toast { cursor: pointer; background: rgba(30, 41, 59, 0.95); backdrop-filter: blur(10px); border: 1px solid rgba(255, 255, 255, 0.1); padding: 12px 16px; border-radius: 8px; color: white; font-size: 0.9em; box-shadow: 0 2px 10px rgba(0,0,0,0.3); opacity: 0; transform: translateY(-10px); transition: all 0.3s ease; display: block; width: 100%; box-sizing: border-box; }
.toast.show { opacity: 1; transform: translateY(0); }
.toast.success { border-left: 4px solid #10b981; }
.toast.error { border-left: 4px solid #ef4444; }
.toast.info { border-left: 4px solid #3b82f6; }

/* Chat */
#chat-hud { position: fixed; bottom: 20px; right: 20px; width: 320px; display: flex; flex-direction: column; gap: 10px; z-index: 15; pointer-events: none; }
.chat-window { pointer-events: auto; height: 350px; background: rgba(15, 23, 42, 0.95); border-radius: 8px; display: flex; flex-direction: column; border: 1px solid #334155; }
.chat-header { padding: 8px; background: rgba(255,255,255,0.05); display: flex; justify-content: space-between; align-items: center; gap: 10px; border-bottom: 1px solid #334155; }
.chat-header-title { flex: 1; font-weight: 600; }
.chat-header-actions { display: inline-flex; align-items: center; gap: 8px; }
.chat-close-btn { background: none; border: none; color: #ef4444; font-size: 1.2rem; cursor: pointer; padding: 6px 10px; }
.chat-msgs { flex: 1; overflow-y: auto; padding: 8px; font-size: 0.9em; }
.chat-input-area { display: flex; padding: 8px; gap: 4px; border-top: 1px solid #334155; }

/* Custom Scrollbar for Chat */
.chat-msgs::-webkit-scrollbar {
    width: 6px;
}

.chat-msgs::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.1);
}

.chat-msgs::-webkit-scrollbar-thumb {
    background: #475569;
    border-radius: 3px;
}

.chat-msgs::-webkit-scrollbar-thumb:hover {
    background: #64748b;
}

/* Loader */
#loader { position: fixed; inset: 0; background: #000; display: flex; justify-content: center; align-items: center; z-index: 9999; transition: opacity 0.5s; }
.hidden { opacity: 0; pointer-events: none; }
/* Login Page Specific Styles */
.login-body {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: radial-gradient(circle at center, #1e293b 0%, #0f172a 100%);
    margin: 0;
    overflow-y: auto;
    padding: 20px;
}

.login-container {
    width: 100%;
    max-width: 400px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.login-header {
    text-align: center;
    margin-bottom: 10px;
}

.login-header h1 {
    margin: 0;
    color: #6366f1;
    font-size: 2.5rem;
    text-shadow: 0 0 10px rgba(99, 102, 241, 0.5);
}

.login-header p {
    color: #94a3b8;
    margin: 5px 0 0;
}

.login-box {
    background: rgba(30, 41, 59, 0.6);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 2rem;
    border-radius: 16px;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.3);
}

.login-box h2, .login-box h3 {
    margin-top: 0;
    margin-bottom: 1.5rem;
    color: #e2e8f0;
    text-align: center;
}

.form-group {
    margin-bottom: 1.2rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    color: #cbd5e1;
    font-size: 0.9rem;
}

.form-group input[type="text"],
.form-group input[type="password"],
.form-group input[type="date"] {
    width: 100%;
    padding: 0.75rem;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid #475569;
    border-radius: 8px;
    color: white;
    font-size: 1rem;
    box-sizing: border-box;
    transition: border-color 0.2s;
}

.password-wrapper {
    position: relative;
    width: 100%;
}

.password-wrapper input[type="password"],
.password-wrapper input[type="text"] {
    padding-right: 40px;
}

.password-toggle-icon {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    cursor: pointer;
    user-select: none;
    background: transparent;
    border: none;
    color: #94a3b8;
    font-size: 1rem;
    padding: 0;
}

.form-group input:focus {
    border-color: #6366f1;
    outline: none;
    background: rgba(0, 0, 0, 0.3);
}

.btn-primary, .btn-secondary {
    width: 100%;
    padding: 0.75rem;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.1s, opacity 0.2s;
}

.btn-primary {
    background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
    color: white;
}

.btn-secondary {
    background: #10b981;
    color: white;
}

.btn-primary:hover, .btn-secondary:hover {
    opacity: 0.9;
}

.btn-primary:active, .btn-secondary:active {
    transform: scale(0.98);
}

.divider {
    display: flex;
    align-items: center;
    text-align: center;
    color: #64748b;
    font-size: 0.8rem;
}

.divider::before, .divider::after {
    content: '';
    flex: 1;
    border-bottom: 1px solid #334155;
}

.divider span {
    padding: 0 10px;
}

.avatar-selection {
    display: flex;
    justify-content: center;
    gap: 15px;
}

.avatar-option {
    cursor: pointer;
    position: relative;
}

.avatar-option input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.avatar-option img {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    border: 3px solid transparent;
    transition: all 0.2s;
    object-fit: cover;
}

.avatar-option input:checked + img {
    border-color: #10b981;
    transform: scale(1.1);
    box-shadow: 0 0 10px rgba(16, 185, 129, 0.5);
}

.alert {
    padding: 0.75rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    font-size: 0.9rem;
    text-align: center;
}

.alert.error {
    background: rgba(239, 68, 68, 0.15);
    color: #fca5a5;
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.alert.success {
    background: rgba(16, 185, 129, 0.15);
    color: #6ee7b7;
    border: 1px solid rgba(16, 185, 129, 0.2);
}

/* TOOLTIP FIXES */

/* 1. Target the library's container to control positioning */
.scene-tooltip {
    z-index: 10000 !important;
    pointer-events: none !important;
    /* Force offset away from mouse pointer */
    transform: translate(20px, 20px) !important; 
    
    /* Reset generic container styles */
    background: transparent !important;
    border: none !important;
    padding: 0 !important;
}

/* 2. Style our custom inner content */
.tooltip-content {
    font-family: 'Noto Sans SC', sans-serif !important;
    font-size: 16px !important;
    font-weight: 500;
    line-height: 1.5 !important;
    padding: 12px 18px !important;
    
    background: rgba(15, 23, 42, 0.95) !important;
    border: 1px solid rgba(148, 163, 184, 0.3) !important;
    border-radius: 8px !important;
    color: #f8fafc !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5) !important;
    
    white-space: nowrap !important;
}

/* --- Restored Connection Panel Styles --- */
.conn-item { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px; border-radius: 8px; cursor: default; background: rgba(255,255,255,0.05); transition: background 0.2s; white-space: nowrap; }
.conn-item:hover { background: rgba(99, 102, 241, 0.15); }
.conn-profile { display: flex; align-items: center; gap: 10px; flex: 1; overflow: hidden; }
.conn-avatar { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; border: 2px solid #6366f1; }
.conn-info { display: flex; flex-direction: column; }
.conn-name { font-weight: 600; color: #e2e8f0; }
.conn-empty { color: #94a3b8; font-size: 0.9em; }
.conn-actions { display: flex; gap: 4px; }
.conn-btn { background: rgba(255,255,255,0.1); border: none; color: #e2e8f0; width: 32px; height: 32px; border-radius: 6px; cursor: pointer; display: flex; align-items: center; justify-content: center; font-size: 1.1em; transition: background 0.2s, transform 0.1s; }
.conn-btn:hover { background: rgba(99, 102, 241, 0.5); transform: scale(1.05); }
.conn-btn:active { transform: scale(0.95); }
