/* ============================================================
   网页版远程摄像头系统 - 样式
   移动优先 / 简洁 / 微信小程序风格
   ============================================================ */
:root {
    --green: #07c160;
    --green-dark: #06a24f;
    --blue: #2f86ff;
    --red: #fa5151;
    --orange: #ff9d00;
    --gray: #999;
    --gray-light: #f7f7f7;
    --text: #222;
    --card: #fff;
    --radius: 14px;
    --shadow: 0 2px 10px rgba(0, 0, 0, .06);
}

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

html, body {
    background: #f5f6f8;
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue",
                 "Segoe UI", Roboto, "Microsoft YaHei", Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
}

.page { max-width: 720px; margin: 0 auto; padding: 16px 16px 40px; min-height: 100vh; }

/* ---------- 顶部 ---------- */
.topbar { text-align: center; padding: 26px 0 18px; }
.topbar .logo {
    width: 58px; height: 58px; margin: 0 auto 12px;
    background: linear-gradient(135deg, var(--green), #0ad07a);
    border-radius: 16px;
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-size: 30px;
    box-shadow: 0 6px 16px rgba(7, 193, 96, .35);
}
.topbar h1 { font-size: 22px; font-weight: 600; letter-spacing: .5px; }
.topbar p { color: var(--gray); font-size: 13px; margin-top: 6px; }

/* ---------- 通用卡片 ---------- */
.card {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 18px;
    margin-bottom: 14px;
}

/* ---------- 按钮 ---------- */
.btn {
    display: block; width: 100%;
    border: none; outline: none; cursor: pointer;
    padding: 15px 0; border-radius: 12px;
    font-size: 17px; font-weight: 600; color: #fff;
    background: var(--green);
    transition: opacity .15s, transform .05s;
    -webkit-user-select: none; user-select: none;
}
.btn:active { transform: scale(.985); opacity: .9; }
.btn.blue   { background: var(--blue); }
.btn.red    { background: var(--red); }
.btn.gray   { background: #e5e6eb; color: #555; }
.btn.small  { width: auto; padding: 10px 20px; font-size: 15px; display: inline-block; border-radius: 20px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.btn-row { display: flex; gap: 10px; }
.btn-row .btn { flex: 1; }

/* ---------- 首页 ---------- */
.home-hero { text-align: center; padding: 20px 0 10px; }
.home-actions { display: flex; flex-direction: column; gap: 14px; margin-top: 26px; }
.home-actions .btn { padding: 22px 0; font-size: 19px; border-radius: 16px; }
.home-actions .btn .ico { display: block; font-size: 26px; margin-bottom: 6px; }
.home-note { text-align: center; color: var(--gray); font-size: 12px; margin-top: 30px; line-height: 1.7; }

/* ---------- 状态条 ---------- */
.status-bar {
    display: flex; align-items: center; gap: 8px;
    font-size: 15px; font-weight: 600;
    padding: 12px 14px; border-radius: 10px;
    background: var(--gray-light); color: var(--text);
}
.status-bar .dot {
    width: 10px; height: 10px; border-radius: 50%;
    background: var(--gray); flex-shrink: 0;
    animation: none;
}
.status-bar.ok      { background: rgba(7,193,96,.10); color: var(--green-dark); }
.status-bar.ok .dot { background: var(--green); box-shadow: 0 0 0 3px rgba(7,193,96,.15); }
.status-bar.wait    { background: rgba(255,157,0,.10); color: #d97d00; }
.status-bar.wait .dot { background: var(--orange); animation: pulse 1.2s infinite; }
.status-bar.bad     { background: rgba(250,81,81,.10); color: var(--red); }
.status-bar.bad .dot { background: var(--red); }
@keyframes pulse { 0%,100% {opacity:1} 50% {opacity:.3} }

/* ---------- 房间号 ---------- */
.room-box { text-align: center; padding: 20px 18px; }
.room-box .label { color: var(--gray); font-size: 13px; }
.room-box .room-code {
    font-size: 46px; font-weight: 700; letter-spacing: 8px;
    margin: 10px 0 6px; font-variant-numeric: tabular-nums;
    padding-left: 8px; /* 抵消 letter-spacing 右偏 */
}

/* ---------- 视频区 ---------- */
.video-wrap {
    position: relative; background: #000; border-radius: var(--radius);
    overflow: hidden; width: 100%; aspect-ratio: 16 / 10;
}
/* 摄像头端预览框: 宽度70%(上限480px), 标准16:9 比例, 居中 —— 观看端保持全宽不变 */
.video-wrap-cam { width: 70%; max-width: 480px; aspect-ratio: 16 / 9; margin: 0 auto; }
.video-wrap video { width: 100%; height: 100%; object-fit: contain; display: block; }
.video-empty {
    position: absolute; inset: 0; display: flex; flex-direction: column;
    align-items: center; justify-content: center; color: #777; font-size: 14px; gap: 8px;
}
.video-empty .ico { font-size: 40px; opacity: .5; }

/* ---------- 信息格(观看端统计) ---------- */
.stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.stat {
    background: var(--gray-light); border-radius: 10px; padding: 10px 12px;
}
.stat .k { color: var(--gray); font-size: 12px; }
.stat .v { font-size: 17px; font-weight: 700; margin-top: 2px; font-variant-numeric: tabular-nums; }

/* ---------- 提示横幅 ---------- */
.banner {
    padding: 12px 14px; border-radius: 10px; font-size: 13px; line-height: 1.6;
    margin-bottom: 12px; display: none;
}
.banner.show { display: block; }
.banner.warn { background: rgba(255,157,0,.12); color: #b26a00; }
.banner.err  { background: rgba(250,81,81,.10); color: var(--red); }
.banner.info { background: rgba(47,134,255,.10); color: #1f66c4; }

/* ---------- 输入框 ---------- */
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 14px; color: var(--gray); margin-bottom: 8px; }
.field input {
    width: 100%; padding: 15px; border: 1px solid #e3e3e8; border-radius: 12px;
    font-size: 24px; letter-spacing: 4px; text-align: center; color: var(--text);
    background: #fff; outline: none; font-variant-numeric: tabular-nums;
}
.field input:focus { border-color: var(--green); }

/* ---------- 分段选择(分辨率) ---------- */
.seg {
    display: flex; background: var(--gray-light); border-radius: 10px; padding: 3px; gap: 3px;
}
.seg button {
    flex: 1; border: none; background: transparent; padding: 9px 0; border-radius: 8px;
    font-size: 14px; color: var(--gray); cursor: pointer;
}
.seg button.on { background: #fff; color: var(--green-dark); font-weight: 600; box-shadow: 0 1px 4px rgba(0,0,0,.08); }

/* ---------- 工具条 ---------- */
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 4px; }
.toolbar .btn { flex: 1; min-width: 120px; }

/* ---------- 调试日志 ---------- */
.debug-log {
    background: #0d1117; color: #9ece6a; font-family: ui-monospace, Menlo, Consolas, monospace;
    font-size: 11px; padding: 10px; border-radius: 10px; max-height: 220px; overflow-y: auto;
    display: none; line-height: 1.6; white-space: pre-wrap; word-break: break-all;
}
.debug-log.show { display: block; }

/* ---------- 页脚说明 ---------- */
.foot-note { text-align: center; color: #b0b0b6; font-size: 12px; margin-top: 20px; line-height: 1.7; }

.hidden { display: none !important; }
