/* public/assets/css/social_office/virtual-gamepad.css */
:root {
    --primary: #6366f1; --secondary: #a855f7; --success: #10b981; --warning: #f59e0b; --danger: #ef4444;
    --bg: #ffffff; --card: #f8fafc; --text-main: #0f172a; --text-sub: #64748b;
    --border: #e2e8f0; --shadow: 0 10px 25px -5px rgba(0,0,0,0.05);
    
    /* 掌机专属配色与材质 */
    --pad-bg-grad: radial-gradient(circle at center, #1e293b 0%, #020617 100%);
    --pad-dpad-base: #1e293b;
    --pad-dpad-shadow: inset -3px -3px 8px rgba(0,0,0,0.8), inset 3px 3px 8px rgba(255,255,255,0.1), 0 8px 15px rgba(0,0,0,0.6);
    --pad-dpad-pressed: inset 3px 3px 8px rgba(0,0,0,0.9), inset -2px -2px 5px rgba(255,255,255,0.05);
}

.chat-wrapper { 
    width: 100%; max-width: 1100px; margin: 0 auto;
    background: var(--bg); border-radius: 20px; overflow: hidden; 
    border: 1px solid var(--border); box-shadow: var(--shadow);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; color: var(--text-main);
    display: flex; flex-direction: column;
}
.chat-wrapper *, .chat-wrapper *::before, .chat-wrapper *::after { box-sizing: border-box; }

.chat-header { padding: 24px; text-align: center; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.chat-title { margin: 0 0 10px 0; font-size: 1.7rem; font-weight: 800; color: var(--text-main); }
.chat-subtitle { margin: 0 auto; max-width: 800px; font-size: 0.95rem; color: var(--text-sub); line-height: 1.6; }
.chat-workspace { padding: 24px; flex: 1; display: flex; flex-direction: column; min-height: 0; }

.chat-layout { display: flex; gap: 24px; align-items: stretch; height: 65vh; min-height: 550px; max-height: 800px; flex: 1; transition: 0.3s; }

/* 左侧控制台 */
.chat-sys-panel { width: 340px; flex-shrink: 0; background: #0f172a; border-radius: 16px; border: 2px solid #1e293b; padding: 24px; display: flex; flex-direction: column; gap: 16px; box-shadow: inset 0 5px 20px rgba(0,0,0,0.5); overflow-y: auto; transition: 0.3s; }
.id-display-card { background: #1e293b; border-radius: 12px; padding: 20px; text-align: center; border: 1px solid #334155; margin-bottom: 15px;}
.id-label { font-size: 12px; color: #94a3b8; letter-spacing: 1px; margin-bottom: 12px; font-weight: bold; }
.id-number { font-size: 42px; font-weight: 900; color: var(--primary); font-family: 'Consolas', monospace; letter-spacing: 8px; text-shadow: 0 2px 10px rgba(99, 102, 241, 0.3); line-height: 1;}
.pc-qr-box { display: flex; justify-content: center; background: white; padding: 10px; border-radius: 12px; margin: 0 auto 15px; width: fit-content; min-height: 130px; align-items: center; }
.mobile-qr-btn { display: none !important; }
.id-actions { display: flex; gap: 10px; margin-top: 15px; }
.id-actions .btn { flex: 1; border-radius: 8px; }

.dial-card { background: #1e293b; border-radius: 12px; padding: 20px; border: 1px solid #334155; }
.qr-label { font-size: 13px; color: #cbd5e1; margin-bottom: 15px; font-weight: 600; text-align: center;}
.input-group { position: relative; width: 100%; display: flex; align-items: center; margin-bottom: 10px;}
.input-group i { position: absolute; left: 15px; color: #64748b; font-size: 16px; }
.clean-input { width: 100%; padding: 14px 14px 14px 45px; border-radius: 8px; border: 2px solid #334155; font-size: 16px; font-weight: 700; color: #f8fafc; background: #0f172a; outline: none; transition: 0.2s; letter-spacing: 2px;}
.btn-connect-action { width: 100%; margin-top: 15px; font-size: 16px; padding: 14px; border-radius: 8px; }

.connection-status-card { display: flex; align-items: center; gap: 10px; background: #1e293b; border-radius: 8px; padding: 12px 16px; border: 1px solid #334155; font-size: 13px; color: #cbd5e1; font-weight: 600; margin-top: auto; flex-wrap: wrap; }
.status-dot { width: 10px; height: 10px; border-radius: 50%; background: #64748b; flex-shrink: 0; }
.status-dot.active { background: var(--success); box-shadow: 0 0 8px var(--success); animation: pulse 2s infinite; }

/* 工作区大面板 */
.chat-msg-panel { flex: 1; border-radius: 16px; border: 1px solid #334155; display: flex; flex-direction: column; min-width: 0; overflow: hidden; position: relative; background: #0f172a; color: #f8fafc; }

/* =========================================================
   模式 1: Host 电脑游戏机模拟展示区
   ========================================================= */
.host-view { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; padding: 20px; }

.arcade-machine {
    width: 100%; max-width: 600px; height: 100%; background: #1e293b; border-radius: 24px;
    border: 4px solid #334155; display: flex; flex-direction: column; overflow: hidden;
    box-shadow: 0 20px 50px rgba(0,0,0,0.5), inset 0 0 20px rgba(0,0,0,0.5);
}
.arcade-machine:fullscreen { max-width: none; border-radius: 0; border: none; }
.arcade-machine:-webkit-full-screen { max-width: none; border-radius: 0; border: none; }

.arcade-cartridge-slot { background: #0f172a; padding: 10px 15px; border-bottom: 2px solid #334155; display: flex; justify-content: space-between; align-items: center; }
.game-selector { background: #1e293b; color: var(--success); font-family: monospace; font-size: 14px; border: 1px solid var(--primary); padding: 6px 12px; border-radius: 8px; outline: none; font-weight: bold; cursor: pointer; }
.btn-fullscreen-arcade { background: rgba(255,255,255,0.1); border: none; color: white; width: 32px; height: 32px; border-radius: 6px; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: 0.2s; }
.btn-fullscreen-arcade:hover { background: var(--primary); }

.arcade-screen {
    flex: 1; background: #000; margin: 20px; border-radius: 16px; border: 2px solid #475569;
    position: relative; overflow: hidden; display: flex; align-items: center; justify-content: center;
    box-shadow: inset 0 0 50px rgba(0,0,0,0.8);
}
.arcade-overlay { position: absolute; z-index: 10; display: flex; align-items: center; justify-content: center; width: 100%; height: 100%; background: #000;}
.insert-coin { color: var(--warning); font-family: 'Consolas', monospace; font-size: 24px; font-weight: bold; letter-spacing: 2px; }
.pulse-anim { animation: blinkText 1.5s infinite step-start; }
@keyframes blinkText { 0%, 100% { opacity: 1; } 50% { opacity: 0; } }

.game-module { width: 100%; height: 100%; position: relative; }
.test-arena { background: repeating-linear-gradient(45deg, #0f172a, #0f172a 20px, #1e293b 20px, #1e293b 40px); }
.player-block { width: 40px; height: 40px; background: var(--primary); position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); border-radius: 8px; box-shadow: 0 0 15px var(--primary); transition: background 0.1s, transform 0.1s, box-shadow 0.1s; }

.snake-arena { display: flex; align-items: center; justify-content: center; background: #000;}
#snakeCanvas { background: #111; border: 2px solid #333; max-width: 100%; max-height: 100%; aspect-ratio: 1/1;}
.snake-ui { position: absolute; top: 0; left: 0; width: 100%; height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; background: rgba(0,0,0,0.7); pointer-events: none;}
.snake-title { color: #4ade80; font-family: 'Consolas', monospace; font-size: 32px; font-weight: bold; text-shadow: 0 0 10px #4ade80; margin-bottom: 10px; letter-spacing: 4px;}
.snake-hint { color: #fff; font-family: monospace; margin-bottom: 20px;}
.snake-score { position: absolute; top: 10px; left: 15px; color: #fff; font-family: monospace; font-size: 16px; font-weight: bold; z-index: 5;}

.arcade-panel { height: 100px; background: #0f172a; border-top: 4px solid #334155; display: flex; justify-content: space-around; align-items: center; padding: 0 10px; flex-shrink: 0; }
.signal-lights { display: flex; gap: 6px; align-items: center;}
.signal-light { 
    width: 34px; height: 34px; border-radius: 50%; background: #1e293b; border: 2px solid #334155;
    display: flex; align-items: center; justify-content: center; color: #64748b; font-weight: bold;
    transition: 0.1s; font-family: monospace; font-size: 10px;
}
.signal-light.shoulder { width: 45px; border-radius: 10px; }
.signal-light.active { background: var(--text-main); color: var(--term-green); border-color: var(--term-green); box-shadow: 0 0 15px var(--term-green); transform: scale(0.9); }
.signal-light.action.active { background: var(--primary); color: #fff; border-color: var(--primary); box-shadow: 0 0 15px var(--primary); }

/* =========================================================
   【绝对核心】：手机全屏 DOM 旋转引擎
   ========================================================= */

/* 进入手柄模式后，外层霸占全屏。使用 dvh 规避网址栏 */
.chat-wrapper.is-remote { 
    position: fixed !important; top: 0; left: 0; right: 0; bottom: 0;
    width: 100vw !important; height: 100dvh !important; z-index: 999999;
    border-radius: 0; border: none; margin: 0; background: #000;
    max-width: none !important; 
}
.chat-wrapper.is-remote .chat-header,
.chat-wrapper.is-remote .chat-sys-panel { display: none !important; }
.chat-wrapper.is-remote .chat-workspace { padding: 0 !important; height: 100%; display: flex; }
.chat-wrapper.is-remote .chat-layout { height: 100%; width: 100%; min-height: 100%; gap: 0; flex: 1; }
.chat-wrapper.is-remote .chat-msg-panel { height: 100%; width: 100%; border-radius: 0; flex: 1; border: none; padding: 0; background: transparent; position: relative;}

/* 核心旋转视窗：包含手柄的所有 UI，防误触 */
.pad-view {
    background: var(--pad-bg-grad);
    user-select: none; -webkit-user-select: none; touch-action: none; -webkit-touch-callout: none;
    display: flex; flex-direction: column; overflow: hidden;
}

/* 场景 A：手机本身处于横屏 (Landscape) -> 自然铺满 */
@media screen and (orientation: landscape) {
    .chat-wrapper.is-remote .pad-view {
        position: absolute; top: 0; left: 0;
        width: 100vw; height: 100dvh;
    }
}

/* 场景 B：手机本身处于竖屏 (Portrait) -> 触发引擎：宽变高、高变宽，并旋转 90 度 */
@media screen and (orientation: portrait) {
    .chat-wrapper.is-remote .pad-view {
        position: absolute; top: 50%; left: 50%;
        width: 100dvh !important; height: 100vw !important;
        transform: translate(-50%, -50%) rotate(90deg);
        transform-origin: center center;
    }
}

/* =========================================================
   掌机布局：内部 UI 元素
   ========================================================= */
.pad-top-bar { 
    display: flex; justify-content: space-between; align-items: flex-start; 
    width: 100%; padding: 20px 40px 0 40px; 
}

.shoulder-btn {
    width: 120px; height: 45px; background: linear-gradient(180deg, #475569 0%, #334155 100%);
    border-radius: 8px; box-shadow: 0 4px 10px rgba(0,0,0,0.6), inset 0 2px 2px rgba(255,255,255,0.2);
    display: flex; align-items: center; justify-content: center;
    color: #94a3b8; font-weight: 900; font-size: 16px; letter-spacing: 2px;
    border-bottom: 4px solid #1e293b; transition: 0.05s;
}
.shoulder-btn.left { border-top-left-radius: 20px; }
.shoulder-btn.right { border-top-right-radius: 20px; }
.shoulder-btn.pressed { transform: translateY(4px); border-bottom-width: 0px; background: linear-gradient(180deg, #334155 0%, #1e293b 100%); box-shadow: 0 1px 2px rgba(0,0,0,0.8), inset 0 2px 5px rgba(0,0,0,0.5); color: #fff;}

.top-sys-actions { display: flex; gap: 20px; }
.sys-icon-btn {
    width: 50px; height: 50px; background: rgba(30,41,59,0.5); border: 2px solid #334155; border-radius: 50%;
    color: #cbd5e1; font-size: 18px; display: flex; align-items: center; justify-content: center;
    box-shadow: inset 0 2px 5px rgba(0,0,0,0.5); cursor: pointer; transition: 0.2s; backdrop-filter: blur(4px);
}
.sys-icon-btn:active { background: #000; transform: scale(0.9); }
.sys-icon-btn.danger { color: #f87171; border-color: rgba(239,68,68,0.3); }

/* 主控区 */
.pad-main-area {
    flex: 1; display: flex; align-items: center; justify-content: space-between;
    width: 100%; padding: 20px 60px;
}

/* 巨无霸 3D 十字键 (200x200 容器，按键 60x60，精准数学坐标计算) */
.dpad-zone { display: flex; justify-content: center; align-items: center; }
.dpad-cross-3d {
    position: relative; width: 200px; height: 200px; background: #0f172a; border-radius: 50%;
    box-shadow: inset 0 0 25px rgba(0,0,0,1), 0 5px 15px rgba(0,0,0,0.5);
}
.dpad-btn {
    position: absolute; width: 60px; height: 60px; background: var(--pad-dpad-base);
    display: flex; align-items: center; justify-content: center; font-size: 32px; color: #64748b;
    box-shadow: var(--pad-dpad-shadow); transition: 0.05s; z-index: 5;
}
/* 中心在 100，按钮宽 60，半径为 30。所以 Left = 100-30 = 70px */
.dpad-btn.up { top: 10px; left: 70px; border-radius: 12px 12px 0 0; }
.dpad-btn.down { bottom: 10px; left: 70px; border-radius: 0 0 12px 12px; }
.dpad-btn.left { top: 70px; left: 10px; border-radius: 12px 0 0 12px; }
.dpad-btn.right { top: 70px; right: 10px; border-radius: 0 12px 12px 0; }
.dpad-center { position: absolute; top: 70px; left: 70px; width: 60px; height: 60px; background: var(--pad-dpad-base); box-shadow: var(--pad-dpad-shadow); z-index: 4;}
.dpad-btn.pressed { background: #334155; color: #fff; box-shadow: var(--pad-dpad-pressed); z-index: 10;}

/* 中央系统按键 */
.center-zone { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 30px; }
.sys-btn-wrapper { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.sys-btn.pill { width: 60px; height: 18px; background: #334155; border-radius: 10px; box-shadow: 0 4px 5px rgba(0,0,0,0.6), inset 0 2px 2px rgba(255,255,255,0.1); border-bottom: 2px solid #0f172a; transform: rotate(-20deg); }
.sys-btn.pill.pressed { transform: rotate(-20deg) translateY(2px); box-shadow: 0 1px 2px rgba(0,0,0,0.8), inset 0 2px 5px rgba(0,0,0,0.5); border-bottom-width: 0; }
.sys-btn-wrapper label { font-size: 13px; font-weight: 900; color: #94a3b8; letter-spacing: 1px; text-shadow: 0 1px 2px rgba(0,0,0,0.8); }

/* 右侧 3D ABXY 动作键 (200x200 容器，按钮 60x60) */
.action-zone { display: flex; justify-content: center; align-items: center; }
.action-diamond-3d { position: relative; width: 200px; height: 200px; background: #0f172a; border-radius: 50%; box-shadow: inset 0 0 25px rgba(0,0,0,1), 0 5px 15px rgba(0,0,0,0.5); }
.action-btn { 
    position: absolute; width: 60px; height: 60px; border-radius: 50%; 
    display: flex; align-items: center; justify-content: center; font-size: 26px; font-weight: 900; color: #fff;
    text-shadow: 0 2px 2px rgba(0,0,0,0.5); border: 2px solid rgba(0,0,0,0.8); transition: 0.05s; z-index: 10;
}
/* 完美菱形布局 (Xbox 标准色) */
.action-btn.y-btn { top: 10px; left: 70px; background: linear-gradient(135deg, #f59e0b, #b45309); box-shadow: inset -2px -2px 5px rgba(0,0,0,0.5), inset 2px 2px 5px rgba(255,255,255,0.4), 0 6px 0 #78350f, 0 8px 10px rgba(0,0,0,0.8); }
.action-btn.a-btn { bottom: 10px; left: 70px; background: linear-gradient(135deg, #10b981, #047857); box-shadow: inset -2px -2px 5px rgba(0,0,0,0.5), inset 2px 2px 5px rgba(255,255,255,0.4), 0 6px 0 #064e3b, 0 8px 10px rgba(0,0,0,0.8); }
.action-btn.x-btn { top: 70px; left: 10px; background: linear-gradient(135deg, #3b82f6, #1d4ed8); box-shadow: inset -2px -2px 5px rgba(0,0,0,0.5), inset 2px 2px 5px rgba(255,255,255,0.4), 0 6px 0 #1e3a8a, 0 8px 10px rgba(0,0,0,0.8); }
.action-btn.b-btn { top: 70px; right: 10px; background: linear-gradient(135deg, #ef4444, #b91c1c); box-shadow: inset -2px -2px 5px rgba(0,0,0,0.5), inset 2px 2px 5px rgba(255,255,255,0.4), 0 6px 0 #7f1d1d, 0 8px 10px rgba(0,0,0,0.8); }
.action-btn.pressed { transform: translateY(6px); box-shadow: inset 0px 0px 10px rgba(0,0,0,0.8), 0 0px 0 #000, 0 2px 4px rgba(0,0,0,0.8); }


/* =========================================================
   非手柄模式（正常桌面端展示）的响应式排版流
   ========================================================= */
@media (max-width: 850px) { 
    .chat-wrapper:not(.is-remote) { height: auto; min-height: calc(100vh - 80px); display: flex; flex-direction: column; }
    .chat-wrapper:not(.is-remote) .chat-header { padding: 16px 12px; flex-shrink: 0; }
    .chat-wrapper:not(.is-remote) .chat-title { font-size: 1.4rem; }
    .chat-wrapper:not(.is-remote) .chat-workspace { padding: 10px; display: flex; flex-direction: column; flex: none; height: auto; }
    .chat-wrapper:not(.is-remote) .chat-layout { flex-direction: column; height: auto; min-height: 0; gap: 10px; display: flex; } 
    .chat-wrapper:not(.is-remote) .chat-sys-panel { width: 100%; padding: 12px; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; overflow: hidden; border-radius: 12px; flex-shrink: 0; height: auto; }
    .chat-wrapper:not(.is-remote) .chat-panel-title { display: none; }
    .id-display-card, .dial-card { padding: 10px; margin: 0; display: flex; flex-direction: column; justify-content: center; }
    .id-label, .qr-label { font-size: 10px; margin-bottom: 4px; }
    .id-number { font-size: 22px; letter-spacing: 2px; }
    .id-actions { margin-top: 8px; gap: 6px; }
    .id-actions .btn { font-size: 12px; padding: 6px; }
    .id-actions .btn span, .btn-connect-action span { display: none; }
    .input-group { margin-bottom: 10px; }
    .clean-input { font-size: 14px; padding: 10px 10px 10px 35px;}
    .input-group i { left: 12px; font-size: 14px;}
    .btn-connect-action { font-size: 13px; padding: 8px; margin-top: 5px; }
    .connection-status-card { grid-column: 1 / 3; margin-top: 0; padding: 8px 12px; }
    
    .chat-wrapper:not(.is-remote) .chat-msg-panel { padding: 0; flex: none; height: 320px; display: flex; flex-direction: column; border-radius: 12px; border: none; margin-bottom: 10px;}
}

.overlay { position: fixed; top: 0; left: 0; width: 100vw; height: 100vh; background: rgba(0,0,0,0.8); z-index: 99999; display: none; align-items: center; justify-content: center; backdrop-filter: blur(8px); }
.modal-box { background: var(--card); padding: 30px; border-radius: 24px; text-align: center; width: 85%; max-width: 340px; box-shadow: 0 20px 40px rgba(0,0,0,0.5); border: 1px solid var(--border); }
.ringing-animation { font-size: 40px; margin-bottom: 15px; animation: bounce 1s infinite alternate; }
@keyframes bounce { from { transform: translateY(0); } to { transform: translateY(-10px); } }

.btn { border: none; padding: 10px 16px; border-radius: 8px; font-weight: 800; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 8px; transition: 0.2s; font-size: 14px; color: white; }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-primary { background: var(--primary); }
.btn-primary:hover { filter: brightness(1.1); }
.btn-secondary { background: #e2e8f0; color: #0f172a; }
.btn-secondary:hover { background: #cbd5e1; }
.btn-success { background: var(--success); }
.btn-success:hover { filter: brightness(1.1); }
.btn-danger { background: var(--danger); }
.btn-danger:hover { filter: brightness(1.1); }

#toast-container { position: fixed; top: 20px; left: 50%; transform: translateX(-50%); z-index: 100000; pointer-events: none; }
.toast { background: rgba(0,0,0,0.85); color: white; padding: 10px 24px; border-radius: 25px; font-size: 13px; margin-bottom: 10px; box-shadow: var(--shadow); }

[data-theme="dark"]:root { --bg: #1e293b; --card: #0f172a; --text-main: #f8fafc; --text-sub: #94a3b8; --border: #334155; }
[data-theme="dark"] .chat-msg-panel { border-color: #334155; }
[data-theme="dark"] .btn-secondary { background: #334155; color: #f8fafc; border: 1px solid #475569; }
[data-theme="dark"] .btn-secondary:hover { background: #475569; }