/* ============================================================
   乐议 H5 参会端 — 全局样式
   品牌色对齐 Flutter AppTheme.brand (#2563EB)
   断点：<768px 手机 / ≥768px PC（硬性自适应要求）
   ============================================================ */

:root {
  --brand: #2563EB;
  --brand-hover: #1D4ED8;
  --brand-light: #DBEAFE;
  --danger: #E8463A;
  --warning: #EFAA17;
  --success: #1DC981;

  /* 落地页（浅色） */
  --bg: #F1F5F9;
  --card: #FFFFFF;
  --text: #0F172A;
  --text2: #475569;
  --text3: #94A3B8;
  --border: #E2E8F0;

  /* 会议室（深色） */
  --room-bg: #0B1220;
  --room-card: #111A2E;
  --room-border: #1E293B;
  --room-text: #E2E8F0;
  --room-text2: #94A3B8;

  --radius: 10px;
  --radius-sm: 6px;
  --radius-lg: 16px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

#app { height: 100%; }
button { font-family: inherit; cursor: pointer; border: none; background: none; }
input { font-family: inherit; outline: none; }

/* ============ 通用组件 ============ */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border-radius: var(--radius-sm);
  font-size: 15px; font-weight: 500;
  transition: background .15s, opacity .15s;
  user-select: none;
}
.btn:active { opacity: .85; }
.btn-primary { background: var(--brand); color: #fff; height: 44px; padding: 0 20px; width: 100%; }
.btn-primary:hover { background: var(--brand-hover); }
.btn-outline {
  background: #fff; color: var(--text2); height: 40px; padding: 0 16px;
  border: 1px solid var(--border); font-size: 13px;
}
.btn-link { color: var(--brand); font-size: 13px; }

.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; color: var(--text2); margin-bottom: 6px; }
.field input {
  width: 100%; height: 44px; padding: 0 14px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-size: 15px; background: #fff; color: var(--text);
  transition: border-color .15s, box-shadow .15s;
}
.field input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(37, 99, 235, .12); }
.field .err { color: var(--danger); font-size: 12px; margin-top: 5px; display: none; }
.field.error input { border-color: var(--danger); }
.field.error .err { display: block; }

/* Toast */
#toast-wrap {
  position: fixed; top: calc(16px + var(--safe-top)); left: 50%; transform: translateX(-50%);
  z-index: 999; display: flex; flex-direction: column; gap: 8px; align-items: center;
  width: min(90vw, 400px); pointer-events: none;
}
.toast {
  background: rgba(15, 23, 42, .92); color: #fff;
  padding: 10px 18px; border-radius: 999px; font-size: 13px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, .2);
  animation: toast-in .2s ease; max-width: 100%;
}
.toast.danger { background: rgba(232, 70, 58, .95); }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }

/* ============ 落地页 / 登录页 ============ */

.page {
  min-height: 100%; display: flex; flex-direction: column; align-items: center;
  padding: calc(24px + var(--safe-top)) 16px calc(24px + var(--safe-bottom));
}
.page-card {
  width: 100%; max-width: 420px; background: var(--card);
  border-radius: var(--radius-lg); padding: 28px 24px;
  box-shadow: 0 4px 24px rgba(15, 23, 42, .06);
}
.page-logo { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.page-logo svg { flex: none; }
.page-logo .name { font-size: 18px; font-weight: 700; }
.page-sub { color: var(--text3); font-size: 13px; margin-bottom: 24px; }

.banner {
  width: 100%; max-width: 420px; margin-bottom: 12px;
  border-radius: var(--radius); padding: 10px 14px; font-size: 13px; line-height: 1.6;
}
.banner-warn { background: #FEF3C7; color: #92400E; }
.banner-error { background: #FEE2E2; color: #991B1B; }

.meeting-chip {
  display: flex; align-items: center; gap: 8px;
  background: var(--brand-light); color: #1E40AF;
  border-radius: var(--radius); padding: 10px 14px;
  font-size: 13px; margin-bottom: 18px;
}
.meeting-chip .code { font-family: ui-monospace, Menlo, Consolas, monospace; font-weight: 600; letter-spacing: 1px; }

.login-user {
  display: flex; align-items: center; gap: 10px;
  background: #F8FAFC; border: 1px solid var(--border); border-radius: var(--radius);
  padding: 10px 14px; margin-bottom: 16px; font-size: 13px;
}
.login-user .who { flex: 1; min-width: 0; }
.login-user .who .n { font-weight: 600; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.login-user .who .u { color: var(--text3); font-size: 12px; }
.avatar-sm {
  width: 34px; height: 34px; border-radius: 50%; flex: none;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 14px; font-weight: 600;
}

.page-foot { margin-top: 18px; color: var(--text3); font-size: 12px; text-align: center; line-height: 1.8; }

.spinner {
  width: 18px; height: 18px; border: 2px solid rgba(255,255,255,.35);
  border-top-color: #fff; border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============ 会议室 ============ */

.room {
  height: 100%; display: flex; flex-direction: column;
  background: var(--room-bg); color: var(--room-text);
  overflow: hidden;
}

/* 顶栏 */
.room-top {
  flex: none; display: flex; align-items: center; gap: 10px;
  padding: calc(8px + var(--safe-top)) 12px 8px;
  background: rgba(7, 12, 24, .85); backdrop-filter: blur(8px);
  min-height: 48px;
}
.room-top .title {
  font-size: 14px; font-weight: 600;
  max-width: 40vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.room-top .meta { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--room-text2); }
.room-top .meta .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--success); }
.room-top .spacer { flex: 1; }

/* 主体：视频区 + 侧栏（PC） */
.room-body { flex: 1; display: flex; min-height: 0; }

.stage { flex: 1; min-width: 0; position: relative; display: flex; flex-direction: column; }

/* 语言切换器（落地/离开页：加入会议按钮下方，同尺寸按钮样式） */
.lang-switch {
  display: block; width: 100%; height: 44px; margin-top: 12px;
  appearance: none; -webkit-appearance: none;
  background: #fff; color: var(--text2);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-size: 15px; font-weight: 500; padding: 0 20px; cursor: pointer;
  text-align: center; text-align-last: center;
  transition: background .15s, opacity .15s;
  user-select: none;
}
.lang-switch:active { opacity: .85; }
.lang-switch:focus { outline: 2px solid var(--brand, #2563EB); outline-offset: 1px; }

/* 发言布局（对齐 APK）：1 主屏 + 底部缩略行 */
.speaker-layout { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.main-tile { flex: 1; min-height: 0; display: flex; padding: 10px 10px 0; }
.main-tile .tile { flex: 1; cursor: pointer; }
.thumb-row {
  flex: none; display: flex; gap: 6px;
  overflow-x: auto; padding: 8px 10px;
}
.thumb-row:empty { display: none; }
.thumb-row .tile { flex: none; width: 64px; height: 76px; cursor: pointer; }
.thumb-row .tile .avatar { width: 32px; height: 32px; font-size: 13px; }
.thumb-row .tile .name { left: 4px; right: 4px; bottom: 4px; font-size: 10px; gap: 4px; }
.thumb-row .tile .name .badge { display: none; }
.thumb-row .tile .me-tag { display: none; }
.tile {
  position: relative; background: var(--room-card);
  border-radius: var(--radius); overflow: hidden;
  border: 2px solid transparent;
  display: flex; align-items: center; justify-content: center;
  min-height: 0;
}
.tile.speaking { border-color: var(--success); }
.tile video { width: 100%; height: 100%; object-fit: cover; background: #000; }
.tile video.contain { object-fit: contain; }
.tile .avatar {
  width: 64px; height: 64px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 24px; font-weight: 600;
}
.tile .name {
  position: absolute; left: 8px; bottom: 8px; right: 8px;
  display: flex; align-items: center; gap: 6px;
  font-size: 12px; color: #fff;
  text-shadow: 0 1px 3px rgba(0,0,0,.7);
  overflow: hidden;
}
.tile .name .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile .name .badge {
  flex: none; font-size: 10px; background: rgba(37, 99, 235, .9);
  padding: 1px 6px; border-radius: 4px;
}
.tile .name .mic { flex: none; display: flex; }
.tile .name .mic.muted { color: var(--danger); }
.tile .me-tag {
  position: absolute; top: 8px; left: 8px; font-size: 10px;
  background: rgba(15, 23, 42, .65); padding: 2px 6px; border-radius: 4px; color: #CBD5E1;
}

/* 屏幕共享 Spotlight 布局 */
.stage.share-mode .speaker-layout { display: none; }
.share-wrap { display: none; }
.stage.share-mode .share-wrap {
  flex: 1; min-height: 0; display: flex; flex-direction: column; padding: 10px; gap: 8px;
}
.share-main {
  flex: 1; min-height: 0; background: #000; border-radius: var(--radius);
  overflow: hidden; display: flex; align-items: center; justify-content: center;
  position: relative;
}
.share-main video { width: 100%; height: 100%; object-fit: contain; }
.share-main .share-label {
  position: absolute; top: 10px; left: 10px;
  font-size: 12px; color: #fff; background: rgba(15, 23, 42, .7);
  padding: 3px 10px; border-radius: 999px; display: flex; align-items: center; gap: 6px;
}
.share-strip {
  flex: none; height: 96px; display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px;
}
.share-strip .tile { flex: none; width: 128px; height: 100%; }
.share-strip .tile .avatar { width: 40px; height: 40px; font-size: 16px; }

/* 底部工具栏 */
.room-ctrl {
  flex: none; display: flex; align-items: stretch; justify-content: center; gap: 4px;
  padding: 8px 8px calc(10px + var(--safe-bottom));
  background: rgba(7, 12, 24, .92); backdrop-filter: blur(8px);
}
.ctrl-btn {
  flex: 1; max-width: 96px; min-width: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  color: var(--room-text); border-radius: var(--radius-sm); padding: 6px 2px;
  min-height: 52px;
}
.ctrl-btn svg { width: 22px; height: 22px; }
.ctrl-btn .lb { font-size: 11px; color: var(--room-text2); white-space: nowrap; }
.ctrl-btn.off { color: var(--danger); }
.ctrl-btn.off .lb { color: var(--danger); }
.ctrl-btn.active { color: var(--brand); }
.ctrl-btn.active .lb { color: var(--brand); }
.ctrl-btn.leave { color: var(--danger); }
.ctrl-btn.leave .lb { color: var(--danger); }
.ctrl-btn.danger-solid { background: var(--danger); color: #fff; border-radius: var(--radius); }
.ctrl-btn.danger-solid .lb { color: #fff; }

/* 侧栏 / 抽屉：成员 + 聊天 */
.panel {
  display: none; flex-direction: column;
  background: var(--room-card); border-top: 1px solid var(--room-border);
}
.panel-head {
  flex: none; display: flex; align-items: center; gap: 8px;
  padding: 12px 14px; border-bottom: 1px solid var(--room-border);
}
.panel-head .tabs { display: flex; gap: 4px; flex: 1; }
.panel-tab {
  padding: 6px 14px; border-radius: 999px; font-size: 13px; color: var(--room-text2);
}
.panel-tab.active { background: var(--brand); color: #fff; }
.panel-close { color: var(--room-text2); padding: 6px; display: flex; }

.panel-body { flex: 1; min-height: 0; display: flex; flex-direction: column; }

/* 成员列表 */
.member-list { flex: 1; overflow-y: auto; padding: 8px 0; }
.member-sec {
  padding: 10px 16px 4px; font-size: 12px; color: var(--room-text2);
  display: flex; justify-content: space-between;
}
.member-row {
  display: flex; align-items: center; gap: 10px; padding: 8px 16px;
}
.member-row .avatar-sm { width: 32px; height: 32px; font-size: 13px; }
.member-row .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.member-row .role-tag {
  flex: none; font-size: 11px; padding: 1px 8px; border-radius: 4px;
  background: var(--brand-light); color: #1E40AF;
}
.member-row .role-tag.viewer { background: #334155; color: #94A3B8; }
.member-row .state-ico { flex: none; display: flex; color: var(--room-text2); }
.member-row .state-ico.muted { color: var(--danger); }
.member-row .hand-ico { flex: none; color: var(--warning); }

/* 聊天 */
.chat-body { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.chat-hint { flex: none; padding: 8px 16px; font-size: 12px; color: var(--room-text2); }
.chat-msgs { flex: 1; overflow-y: auto; padding: 4px 14px; }
.msg-row { display: flex; gap: 8px; margin-bottom: 12px; }
.msg-row .avatar-sm { width: 30px; height: 30px; font-size: 12px; }
.msg-row .m-body { flex: 1; min-width: 0; }
.msg-row .m-sender { font-size: 12px; color: var(--room-text2); margin-bottom: 4px; }
.msg-row .m-bubble {
  background: #1E293B; border-radius: 2px 10px 10px 10px;
  padding: 8px 12px; font-size: 14px; line-height: 1.5;
  word-break: break-word; white-space: pre-wrap;
}
.msg-row.me { flex-direction: row-reverse; }
.msg-row.me .m-body { display: flex; flex-direction: column; align-items: flex-end; }
.msg-row.me .m-bubble { background: var(--brand); border-radius: 10px 2px 10px 10px; }
.chat-input {
  flex: none; display: flex; gap: 8px; padding: 10px 12px calc(10px + var(--safe-bottom));
  border-top: 1px solid var(--room-border);
}
.chat-input input {
  flex: 1; min-width: 0; height: 40px; padding: 0 14px;
  background: #0B1220; border: 1px solid var(--room-border); border-radius: 999px;
  color: var(--room-text); font-size: 14px;
}
.chat-input input:focus { border-color: var(--brand); }
.chat-input .send {
  flex: none; width: 40px; height: 40px; border-radius: 50%;
  background: var(--brand); color: #fff; display: flex; align-items: center; justify-content: center;
}
.chat-input .send:disabled { opacity: .4; }

/* 会议中遮罩提示（被踢/会议结束/连接中） */
.room-mask {
  position: absolute; inset: 0; z-index: 50;
  background: rgba(7, 12, 24, .82); backdrop-filter: blur(6px);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  text-align: center; padding: 24px;
}
.room-mask .ico { font-size: 40px; }
.room-mask .t1 { font-size: 17px; font-weight: 600; }
.room-mask .t2 { font-size: 13px; color: var(--room-text2); line-height: 1.6; }
.room-mask .btn-primary { max-width: 220px; }

/* 离开页 */
.leave-page { justify-content: center; }
.leave-page .ok-ico {
  width: 72px; height: 72px; border-radius: 50%; background: #DCFCE7;
  display: flex; align-items: center; justify-content: center; margin-bottom: 16px;
}

/* ============ 响应式断点：≥768px 视为 PC ============ */

@media (min-width: 768px) {
  .page-card { padding: 36px 40px; }

  /* 会议室：成员/聊天变为右侧侧栏（与视频区并排） */
  .room-body { flex-direction: row; }
  .room-ctrl { padding-bottom: 12px; }
  .ctrl-btn { flex: none; min-width: 72px; padding: 6px 10px; }
  .main-tile { padding: 14px 14px 0; }
  .thumb-row { gap: 8px; padding: 10px 14px; }
  .thumb-row .tile { width: 80px; height: 92px; }
  .panel {
    display: flex; flex: none; width: 340px;
    border-top: none; border-left: 1px solid var(--room-border);
  }
  .panel.open { display: flex; }
  .panel-close { display: none; }

  .share-strip { height: 120px; }
  .share-strip .tile { width: 160px; }
}

/* 手机端：成员/聊天为底部抽屉 */
@media (max-width: 767.98px) {
  .panel {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
    height: 72vh; border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    transform: translateY(100%); transition: transform .22s ease;
    box-shadow: 0 -8px 40px rgba(0, 0, 0, .4);
    display: flex; max-height: 72vh;
  }
  .panel.open { transform: translateY(0); }
  .ctrl-btn { max-width: none; }
}
