/*
 * Web Demo 样式
 * 深色主题，响应式设计，适配移动端
 */

/* ============================================================
   CSS 变量
   ============================================================ */
:root {
  /* 颜色 */
  --deep-space-blue: #0a0e17;
  --deep-charcoal: #12151c;
  --surface-color: #1a1f2e;
  --cyber-cyan: #00f5d4;
  --accent-purple: #9d4edd;
  --text-primary: #ffffff;
  --text-secondary: #8b949e;
  --error-color: #f85149;
  --success-color: #3fb950;
  --warning-color: #d29922;
  --border-color: rgba(255, 255, 255, 0.1);

  /* 圆角 */
  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;

  /* 阴影 */
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
  --glow-cyan: 0 0 20px rgba(0, 245, 212, 0.3);

  /* 字体 */
  --font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

/* ============================================================
   基础样式
   ============================================================ */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  height: 100%;
  font-family: var(--font-family);
  font-size: 16px;
  line-height: 1.5;
  color: var(--text-primary);
  background: var(--deep-space-blue);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: -webkit-fill-available;
}

/* 移动端安全区域适配 */
@supports (padding: max(0px)) {
  body {
    padding-top: max(0px, env(safe-area-inset-top));
    padding-bottom: max(0px, env(safe-area-inset-bottom));
    padding-left: max(0px, env(safe-area-inset-left));
    padding-right: max(0px, env(safe-area-inset-right));
  }
}

/* ============================================================
   容器
   ============================================================ */
.container {
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  padding: 20px;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.full-screen {
  max-width: 100%;
  padding: 0;
}

/* ============================================================
   头部
   ============================================================ */
.header {
  text-align: center;
  padding: 24px 0;
}

.header h1 {
  font-size: 24px;
  font-weight: 600;
  color: var(--cyber-cyan);
  margin-bottom: 8px;
}

.header p {
  font-size: 14px;
  color: var(--text-secondary);
}

/* ============================================================
   卡片
   ============================================================ */
.card {
  background: var(--surface-color);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border-color);
}

.card.glow {
  box-shadow: var(--shadow-md), var(--glow-cyan);
  border-color: rgba(0, 245, 212, 0.2);
}

.card-title {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-title .icon {
  font-size: 24px;
}

/* ============================================================
   监控码显示
   ============================================================ */
.code-display {
  text-align: center;
  padding: 32px 16px;
}

.code-label {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

.code-value {
  font-size: 48px;
  font-weight: 700;
  font-family: 'SF Mono', 'Monaco', 'Consolas', monospace;
  letter-spacing: 8px;
  color: var(--cyber-cyan);
  text-shadow: 0 0 20px rgba(0, 245, 212, 0.5);
  user-select: all;
  cursor: pointer;
}

.code-hint {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 12px;
}

/* ============================================================
   输入框
   ============================================================ */
.input-group {
  margin-bottom: 16px;
}

.input-group label {
  display: block;
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.input-field {
  width: 100%;
  padding: 14px 16px;
  font-size: 16px;
  color: var(--text-primary);
  background: var(--deep-charcoal);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  outline: none;
  transition: all 0.2s ease;
}

.input-field:focus {
  border-color: var(--cyber-cyan);
  box-shadow: 0 0 0 3px rgba(0, 245, 212, 0.1);
}

.input-field::placeholder {
  color: var(--text-secondary);
  opacity: 0.6;
}

.input-field.code-input {
  font-size: 24px;
  font-family: 'SF Mono', 'Monaco', 'Consolas', monospace;
  letter-spacing: 6px;
  text-align: center;
  text-transform: uppercase;
}

/* ============================================================
   按钮
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 24px;
  font-size: 16px;
  font-weight: 600;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
  width: 100%;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: linear-gradient(135deg, var(--cyber-cyan), #00d4aa);
  color: var(--deep-space-blue);
}

.btn-primary:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 4px 20px rgba(0, 245, 212, 0.4);
}

.btn-primary:active:not(:disabled) {
  transform: translateY(0);
}

.btn-secondary {
  background: var(--surface-color);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--deep-charcoal);
  border-color: var(--cyber-cyan);
}

.btn-danger {
  background: var(--error-color);
  color: white;
}

.btn-danger:hover:not(:disabled) {
  background: #e63946;
  box-shadow: 0 4px 20px rgba(248, 81, 73, 0.4);
}

.btn-icon {
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: 50%;
  font-size: 20px;
}

.btn-sm {
  padding: 10px 16px;
  font-size: 14px;
}

/* ============================================================
   状态指示器
   ============================================================ */
.status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: var(--radius-xl);
  font-size: 14px;
  font-weight: 500;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  animation: pulse 2s infinite;
}

.status-waiting {
  background: rgba(210, 153, 34, 0.2);
  color: var(--warning-color);
}

.status-waiting .status-dot {
  background: var(--warning-color);
}

.status-connected {
  background: rgba(63, 185, 80, 0.2);
  color: var(--success-color);
}

.status-connected .status-dot {
  background: var(--success-color);
}

.status-error {
  background: rgba(248, 81, 73, 0.2);
  color: var(--error-color);
}

.status-error .status-dot {
  background: var(--error-color);
  animation: none;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* ============================================================
   视频容器
   ============================================================ */
.video-container {
  position: relative;
  width: 100%;
  aspect-ratio: 9 / 16;
  background: var(--deep-charcoal);
  border-radius: var(--radius-lg);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.video-container.landscape {
  aspect-ratio: 16 / 9;
}

.video-container video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.video-placeholder {
  text-align: center;
  color: var(--text-secondary);
}

.video-placeholder .icon {
  font-size: 64px;
  margin-bottom: 16px;
  opacity: 0.3;
}

.video-placeholder p {
  font-size: 14px;
}

/* 视频控制覆盖层 */
.video-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 16px;
  background: linear-gradient(
    to bottom,
    rgba(0, 0, 0, 0.5) 0%,
    transparent 30%,
    transparent 70%,
    rgba(0, 0, 0, 0.5) 100%
  );
  opacity: 0;
  transition: opacity 0.3s ease;
}

.video-container:hover .video-overlay,
.video-overlay.visible {
  opacity: 1;
}

.video-top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.video-bottom-bar {
  display: flex;
  justify-content: center;
  gap: 16px;
}

/* ============================================================
   全屏视频
   ============================================================ */
.fullscreen-video {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1000;
  background: black;
  display: flex;
  align-items: center;
  justify-content: center;
}

.fullscreen-video video {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

/* ============================================================
   加载动画
   ============================================================ */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 24px;
  color: var(--text-secondary);
}

.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border-color);
  border-top-color: var(--cyber-cyan);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ============================================================
   提示消息
   ============================================================ */
.toast {
  position: fixed;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  padding: 12px 24px;
  background: var(--surface-color);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  font-size: 14px;
  opacity: 0;
  transition: all 0.3s ease;
  z-index: 2000;
  max-width: 90%;
  text-align: center;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

.toast.success {
  border: 1px solid var(--success-color);
  color: var(--success-color);
}

.toast.error {
  border: 1px solid var(--error-color);
  color: var(--error-color);
}

/* ============================================================
   角色选择
   ============================================================ */
.role-cards {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-top: 24px;
}

.role-card {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 20px;
  background: var(--surface-color);
  border: 2px solid var(--border-color);
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
  color: inherit;
}

.role-card:hover {
  border-color: var(--cyber-cyan);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md), var(--glow-cyan);
}

.role-icon {
  width: 56px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  background: var(--deep-charcoal);
  border-radius: var(--radius-md);
}

.role-info h3 {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 4px;
}

.role-info p {
  font-size: 14px;
  color: var(--text-secondary);
}

/* ============================================================
   底部导航
   ============================================================ */
.bottom-nav {
  padding: 16px 20px;
  background: var(--deep-charcoal);
  border-top: 1px solid var(--border-color);
}

.bottom-nav .btn {
  margin-bottom: 8px;
}

.bottom-nav .btn:last-child {
  margin-bottom: 0;
}

/* ============================================================
   工具类
   ============================================================ */
.text-center { text-align: center; }
.text-secondary { color: var(--text-secondary); }
.text-cyan { color: var(--cyber-cyan); }
.text-error { color: var(--error-color); }
.text-success { color: var(--success-color); }

.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }

.hidden { display: none !important; }

/* ============================================================
   响应式
   ============================================================ */
@media (max-width: 375px) {
  .code-value {
    font-size: 36px;
    letter-spacing: 6px;
  }

  .card {
    padding: 16px;
  }
}

@media (min-width: 768px) {
  .container {
    padding: 40px 20px;
  }

  .role-cards {
    flex-direction: row;
  }

  .role-card {
    flex: 1;
    flex-direction: column;
    text-align: center;
  }
}

/* ============================================================
   暗色滚动条
   ============================================================ */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--deep-charcoal);
}

::-webkit-scrollbar-thumb {
  background: var(--surface-color);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--border-color);
}

/* ============================================================
   聊天面板
   ============================================================ */
.chat-panel {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 50%;
  min-height: 280px;
  max-height: 400px;
  background: var(--deep-charcoal);
  border-top-left-radius: var(--radius-lg);
  border-top-right-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  z-index: 100;
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.5);
  animation: slideUp 0.3s ease;
}

@keyframes slideUp {
  from {
    transform: translateY(100%);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.chat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-color);
  font-weight: 600;
  font-size: 14px;
  color: var(--cyber-cyan);
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.chat-hint {
  text-align: center;
  font-size: 12px;
  color: var(--text-secondary);
  padding: 8px;
  background: var(--surface-color);
  border-radius: var(--radius-md);
}

.chat-message {
  display: flex;
  flex-direction: column;
  max-width: 80%;
}

.chat-message-self {
  align-self: flex-end;
  align-items: flex-end;
}

.chat-message-other {
  align-self: flex-start;
  align-items: flex-start;
}

.chat-sender {
  font-size: 11px;
  color: var(--text-secondary);
  margin-bottom: 4px;
  padding-left: 8px;
}

.chat-bubble {
  padding: 10px 14px;
  border-radius: var(--radius-lg);
  font-size: 14px;
  line-height: 1.4;
  word-wrap: break-word;
  max-width: 100%;
}

.chat-bubble-self {
  background: var(--cyber-cyan);
  color: var(--deep-space-blue);
  border-bottom-right-radius: 4px;
}

.chat-bubble-other {
  background: var(--surface-color);
  color: var(--text-primary);
  border-bottom-left-radius: 4px;
}

.chat-time {
  font-size: 10px;
  color: var(--text-secondary);
  margin-top: 4px;
  padding: 0 8px;
}

.chat-input-area {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--border-color);
  background: var(--deep-space-blue);
}

.chat-input {
  flex: 1;
  padding: 10px 14px;
  font-size: 14px;
  color: var(--text-primary);
  background: var(--surface-color);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  outline: none;
  transition: all 0.2s ease;
}

.chat-input:focus {
  border-color: var(--cyber-cyan);
  box-shadow: 0 0 0 2px rgba(0, 245, 212, 0.1);
}

.chat-input::placeholder {
  color: var(--text-secondary);
  opacity: 0.6;
}

.chat-input-area .btn {
  width: auto;
  padding: 10px 20px;
}
