/* ========== Base ========== */
* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: "Segoe UI", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* ========== Accessibility (UI/UX Pro Max: focus, skip link, reduced motion) ========== */
.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 99999;
  padding: 0.5rem 1rem;
  background: oklch(var(--p));
  color: oklch(var(--pc));
  font-size: 0.875rem;
  font-weight: 600;
  border-radius: 0.375rem;
  text-decoration: none;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.skip-link:focus {
  left: 0.75rem;
  top: 0.75rem;
  outline: none;
  box-shadow: 0 0 0 3px oklch(var(--b1)), 0 0 0 5px oklch(var(--p));
}

.login-overlay {
  background:
    radial-gradient(120% 80% at 50% -20%, oklch(var(--p) / 0.12), transparent 55%),
    oklch(var(--b1) / 0.92);
  backdrop-filter: blur(10px);
}

.login-card {
  animation: login-card-in 0.35s ease-out both;
}

@keyframes login-card-in {
  from { opacity: 0; transform: translateY(12px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* 键盘焦点可见（勿移除轮廓，仅用更清晰的主题环） */
:focus { outline: none; }
:focus-visible {
  outline: 2px solid oklch(var(--p));
  outline-offset: 2px;
}
.btn:focus-visible,
.input:focus-visible,
.checkbox:focus-visible {
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  .login-card { animation: none; }
}

/* ========== Custom Scrollbar (light theme) ========== */
.custom-scrollbar::-webkit-scrollbar { width: 4px; }
.custom-scrollbar::-webkit-scrollbar-track { background: transparent; }
.custom-scrollbar::-webkit-scrollbar-thumb { background: oklch(var(--bc) / 0.15); border-radius: 4px; }
.custom-scrollbar::-webkit-scrollbar-thumb:hover { background: oklch(var(--bc) / 0.25); }

.no-scrollbar::-webkit-scrollbar { display: none; }
.no-scrollbar { -ms-overflow-style: none; scrollbar-width: none; }

/* ========== SW Column Drag Handles ========== */
.sw-drag-handle {
  position: absolute; right: -2px; top: 0; bottom: 0; width: 5px;
  cursor: col-resize; z-index: 5;
}
.sw-drag-handle:hover, .sw-drag-handle.active { background: oklch(var(--p) / 0.3); }
.sw-tree-indent { display: inline-block; width: 1rem; }
.sw-tree-toggle { cursor: pointer; user-select: none; width: 1rem; display: inline-block; text-align: center; }

/* =============== 全屏观看模式 =============== */
body.viewer-fullscreen > header,
body.viewer-fullscreen > div > nav {
  display: none !important;
}
body.viewer-fullscreen > div {
  position: fixed !important;
  inset: 0 !important;
  z-index: 9999 !important;
}
body.viewer-fullscreen #kiosk {
  display: flex !important;
  position: fixed !important;
  inset: 0 !important;
  z-index: 9999 !important;
}
body.viewer-fullscreen #kiosk > div:first-child {
  display: none !important;
}
body.viewer-fullscreen #kiosk > div:last-child {
  position: fixed !important;
  inset: 0 !important;
}
body.viewer-fullscreen #remoteVideo {
  display: block !important;
  position: fixed !important;
  inset: 0 !important;
  z-index: 9999 !important;
  background: #000 !important;
}
body.viewer-fullscreen #remoteVideo video {
  width: 100% !important;
  height: 100% !important;
  object-fit: contain !important;
}
body.viewer-fullscreen #viewerPlaceholder {
  display: none !important;
}

/* 键鼠锁定遮罩 */
.input-lock-overlay {
  position: absolute;
  inset: 0;
  z-index: 10002;
  pointer-events: none;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 32px;
}
.input-lock-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(220, 38, 38, 0.85);
  color: #fff;
  padding: 8px 20px;
  border-radius: 24px;
  font-size: 13px;
  font-weight: 500;
  backdrop-filter: blur(8px);
  box-shadow: 0 4px 24px rgba(0,0,0,0.4);
  animation: lockBadgePulse 2s ease-in-out infinite;
}
.input-lock-badge small {
  font-size: 11px;
  opacity: 0.8;
  margin-left: 4px;
}
@keyframes lockBadgePulse {
  0%, 100% { opacity: 0.9; }
  50% { opacity: 1; }
}
body.viewer-fullscreen .input-lock-overlay {
  position: fixed !important;
  z-index: 10002 !important;
}
body.viewer-fullscreen .viewer-fullscreen-exit-btn {
  position: fixed !important;
  top: 12px;
  right: 12px;
  z-index: 10001 !important;
  display: flex !important;
  align-items: center;
  gap: 6px;
  background: rgba(0,0,0,0.7);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.2);
  padding: 6px 14px;
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.3s;
}
body.viewer-fullscreen:hover .viewer-fullscreen-exit-btn,
body.viewer-fullscreen .viewer-fullscreen-exit-btn:focus {
  opacity: 1;
}

/* ========== Navigation Items ========== */
.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 12px 6px;
  min-height: 44px;
  cursor: pointer;
  color: oklch(var(--bc) / 0.45);
  transition: color 0.2s ease, background 0.2s ease, border-color 0.2s ease;
  border-left: 2px solid transparent;
  font-size: 10px;
  gap: 6px;
  position: relative;
  user-select: none;
}

.nav-item i {
  font-size: 16px;
  transition: all 0.2s ease;
}

.nav-item span {
  font-size: 10px;
  line-height: 1.25;
  white-space: nowrap;
  letter-spacing: 0.02em;
}

.nav-item:hover {
  color: oklch(var(--bc) / 0.7);
  background: oklch(var(--bc) / 0.05);
}

.nav-item.active {
  color: oklch(var(--p));
  border-left-color: oklch(var(--p));
  background: oklch(var(--p) / 0.08);
}

.nav-item.active i {
  color: oklch(var(--p));
}

/* ========== View Sections ========== */
.view-section {
  display: none !important;
}

.view-section.active {
  display: flex !important;
}

/* ========== Config Buttons (light theme) ========== */
.config-btn {
  flex: 1;
  padding: 6px 12px;
  font-size: 12px;
  border: 1px solid oklch(var(--bc) / 0.15);
  border-radius: 6px;
  background: oklch(var(--b2));
  color: oklch(var(--bc) / 0.6);
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: center;
}

.config-btn:hover {
  border-color: oklch(var(--bc) / 0.25);
  color: oklch(var(--bc) / 0.8);
}

.config-btn.active {
  background: oklch(var(--p));
  border-color: oklch(var(--p));
  color: white;
}

/* ========== Mobile Navigation (light theme) ========== */
.mobile-nav-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: 44px;
  min-width: 44px;
  padding: 6px 10px;
  color: oklch(var(--bc) / 0.45);
  background: none;
  border: none;
  cursor: pointer;
  font-size: 11px;
  transition: color 0.2s ease;
}

.mobile-nav-btn i {
  font-size: 16px;
}

.mobile-nav-btn.active {
  color: oklch(var(--p));
}

/* ========== Activity Log Items (light theme) ========== */
.activity-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 6px;
  background: oklch(var(--b2) / 0.5);
  border: 1px solid transparent;
  transition: all 0.15s ease;
}

.activity-item:hover {
  background: oklch(var(--b2));
  border-color: oklch(var(--bc) / 0.08);
}

.activity-item .icon {
  width: 20px;
  height: 20px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  flex-shrink: 0;
  margin-top: 1px;
}

.activity-item .content {
  flex: 1;
  min-width: 0;
}

.activity-item .text {
  color: oklch(var(--bc) / 0.8);
  font-size: 11px;
  line-height: 1.4;
  word-break: break-all;
}

.activity-item .time {
  color: oklch(var(--bc) / 0.4);
  font-size: 10px;
  margin-top: 2px;
}

/* ========== Clipboard/Keyboard Log Items (light theme) ========== */
.log-item {
  padding: 8px 10px;
  border-radius: 6px;
  background: oklch(var(--b2) / 0.5);
  border: 1px solid transparent;
  transition: all 0.15s ease;
}

.log-item:hover {
  background: oklch(var(--b2));
  border-color: oklch(var(--bc) / 0.08);
}

.log-item .header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.log-item .app-name {
  color: oklch(var(--bc) / 0.6);
  font-size: 10px;
  font-weight: 500;
}

.log-item .log-time {
  color: oklch(var(--bc) / 0.4);
  font-size: 10px;
  font-family: monospace;
}

.log-item .log-content {
  color: oklch(var(--bc) / 0.8);
  font-size: 11px;
  font-family: "Consolas", "Monaco", monospace;
  background: oklch(var(--b2));
  padding: 4px 8px;
  border-radius: 4px;
  word-break: break-all;
}

.log-item .log-content .special-key {
  color: oklch(var(--p));
  background: oklch(var(--p) / 0.1);
  padding: 1px 4px;
  border-radius: 3px;
  font-size: 10px;
}

/* ========== Process Table (light theme) ========== */
#processTableBody tr {
  border-bottom: 1px solid oklch(var(--bc) / 0.06);
  transition: background 0.15s ease;
}

#processTableBody tr:hover {
  background: oklch(var(--b2) / 0.5);
}

#processTableBody td {
  padding: 8px 16px;
}

/* ========== File Drop Zone ========== */
#fileDropZone.drag-over {
  border-color: oklch(var(--p));
  background: oklch(var(--p) / 0.05);
}

/* ========== Screen Share Audio Toggle ========== */
#screenConfigShareAudioBtn.active {
  border-color: oklch(var(--p));
  background: oklch(var(--p) / 0.08);
}

/* ========== Video Container ========== */
#localPreview video,
#remoteVideo video {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

#localPreview div[id],
#remoteVideo div[id] {
  width: 100% !important;
  height: 100% !important;
}

/* ========== Pulse Animation ========== */
@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.pulse-dot {
  animation: pulse-dot 1.5s infinite;
}

/* ========== App Toast（避免与 DaisyUI 组件类名 .toast 冲突导致整页竖条） ========== */
.mdshare-app-toast {
  position: fixed;
  top: 4.5rem;
  right: 1rem;
  z-index: 10050;
  max-width: min(22rem, calc(100vw - 2rem));
  width: max-content;
  min-width: 0;
  padding: 0.75rem 1rem 0.75rem 0.85rem;
  border-radius: 0.75rem;
  font-size: 0.8125rem;
  line-height: 1.45;
  color: #fff;
  word-wrap: break-word;
  white-space: normal;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.22);
  border: 1px solid rgba(255, 255, 255, 0.12);
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  animation: mdshare-toast-in 0.22s ease-out forwards;
}

.mdshare-app-toast::before {
  content: '';
  width: 0.2rem;
  align-self: stretch;
  flex-shrink: 0;
  border-radius: 999px;
  margin-top: 0.1rem;
  margin-bottom: 0.1rem;
  background: rgba(255, 255, 255, 0.85);
}

.mdshare-app-toast.mdshare-app-toast--success {
  background: linear-gradient(135deg, #047857 0%, #059669 100%);
}
.mdshare-app-toast.mdshare-app-toast--success::before {
  background: #6ee7b7;
}

.mdshare-app-toast.mdshare-app-toast--error {
  background: linear-gradient(135deg, #b91c1c 0%, #dc2626 100%);
}
.mdshare-app-toast.mdshare-app-toast--error::before {
  background: #fca5a5;
}

.mdshare-app-toast.mdshare-app-toast--info {
  background: linear-gradient(135deg, #1d4ed8 0%, #2563eb 100%);
}
.mdshare-app-toast.mdshare-app-toast--info::before {
  background: #93c5fd;
}

.mdshare-app-toast.mdshare-app-toast--warning {
  background: linear-gradient(135deg, #b45309 0%, #d97706 100%);
}
.mdshare-app-toast.mdshare-app-toast--warning::before {
  background: #fcd34d;
}

.mdshare-app-toast.mdshare-app-toast--out {
  animation: mdshare-toast-out 0.22s ease-in forwards;
}

@keyframes mdshare-toast-in {
  from { opacity: 0; transform: translateX(12px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes mdshare-toast-out {
  from { opacity: 1; transform: translateX(0); }
  to { opacity: 0; transform: translateX(12px); }
}

/* ========== Native 屏幕分享源选择（分栏 + 缩略图） ========== */
.native-src-overlay {
  position: fixed;
  inset: 0;
  z-index: 10040;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(15, 17, 23, 0.78);
  backdrop-filter: blur(8px);
}

.native-src-panel {
  width: min(720px, 100%);
  max-height: min(88vh, 640px);
  display: flex;
  flex-direction: column;
  background: oklch(22% 0.02 260);
  border: 1px solid oklch(35% 0.02 260);
  border-radius: 14px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
  overflow: hidden;
}

.native-src-header {
  flex-shrink: 0;
  padding: 1rem 1.1rem;
  border-bottom: 1px solid oklch(32% 0.02 260);
  color: #e2e8f0;
  font-size: 1rem;
  font-weight: 600;
}

.native-src-tabs {
  display: flex;
  flex-shrink: 0;
  gap: 4px;
  padding: 0 0.75rem;
  background: oklch(18% 0.02 260);
  border-bottom: 1px solid oklch(30% 0.02 260);
}

.native-src-tab {
  flex: 1;
  min-height: 44px;
  border: none;
  background: transparent;
  color: #94a3b8;
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  border-radius: 8px 8px 0 0;
  margin-bottom: -1px;
  transition: color 0.15s ease, background 0.15s ease;
}

.native-src-tab:hover {
  color: #e2e8f0;
  background: oklch(26% 0.02 260);
}

.native-src-tab--active {
  color: #f8fafc;
  background: oklch(22% 0.02 260);
  border: 1px solid oklch(35% 0.02 260);
  border-bottom-color: oklch(22% 0.02 260);
}

.native-src-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 0.85rem;
}

.native-src-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(148px, 1fr));
  gap: 10px;
}

.native-src-card {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  text-align: left;
  padding: 0;
  border: 1px solid #334155;
  border-radius: 10px;
  background: #1e293b;
  cursor: pointer;
  overflow: hidden;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.12s ease;
}

.native-src-card:hover {
  border-color: #64748b;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
  transform: translateY(-1px);
}

.native-src-card:focus-visible {
  outline: 2px solid #38bdf8;
  outline-offset: 2px;
}

.native-src-thumb-wrap {
  aspect-ratio: 16 / 10;
  background: #0f172a;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.native-src-thumb-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.native-src-thumb-fallback {
  font-size: 1.75rem;
  color: #475569;
}

.native-src-card-title {
  padding: 8px 10px 10px;
  font-size: 11px;
  line-height: 1.35;
  color: #e2e8f0;
  max-height: 3.2em;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  word-break: break-word;
}

.native-src-empty {
  padding: 2rem 1rem;
  text-align: center;
  color: #64748b;
  font-size: 0.8125rem;
}

.native-src-footer {
  flex-shrink: 0;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 0.75rem 1rem;
  border-top: 1px solid oklch(30% 0.02 260);
  background: oklch(18% 0.02 260);
}

.native-src-footer button {
  min-height: 40px;
  padding: 0 1rem;
  border-radius: 8px;
  border: none;
  font-size: 0.875rem;
  cursor: pointer;
  background: #334155;
  color: #e2e8f0;
}

.native-src-footer button:hover {
  background: #475569;
}

/* ========== Remote Control Combo Keys (light theme) ========== */
.rc-combo-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 24px;
  padding: 0 6px;
  background: oklch(var(--b2));
  border: 1px solid oklch(var(--bc) / 0.15);
  border-radius: 4px;
  color: oklch(var(--bc) / 0.7);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  font-family: inherit;
}
.rc-combo-btn:hover {
  background: oklch(var(--bc) / 0.08);
  border-color: oklch(var(--bc) / 0.25);
  color: oklch(var(--bc) / 0.9);
}
.rc-combo-btn:active {
  background: oklch(var(--b3));
}
.rc-combo-btn:focus-visible {
  outline: 2px solid oklch(var(--p));
  outline-offset: 2px;
}

/* ========== Responsive ========== */
@media (max-width: 768px) {
  body {
    padding-bottom: 56px;
  }
}

/* ========== DaisyUI density (business / dashboard) ========== */
/* Make badges slightly smaller for status indicators */
.badge-sm {
  font-size: 10px;
  height: 1.25rem;
  padding-left: 0.5rem;
  padding-right: 0.5rem;
}

/* Terminal keeps its dark appearance */
#terminal #terminalOutput {
  background: #1e1e2e;
  color: #a6e3a1;
}
#terminal .border-neutral-focus {
  border-color: #313244;
}

/* Smooth transitions + 触控（减少 300ms 延迟） */
.btn, button, .nav-item, .mobile-nav-btn { touch-action: manipulation; }
.btn { transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease; }
input, select { transition: border-color 0.15s ease, box-shadow 0.15s ease; }
