/* =========================================================
   oSharer — app.css
   合并 sharer.css + viewer.css，双模式由 html[data-mode] 区分
   ========================================================= */

/* ── 共享重置 / 基础 ── */
*, *::before, *::after { box-sizing: border-box; }
body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* ── GitHub 版本角标（两种模式均显示）── */
.github-version {
    position: absolute;
    bottom: 20px;
    right: 30px;
    color: rgba(142, 142, 147, 0.74);
    font-size: 11px;
    font-weight: 600;
    line-height: 1;
    text-decoration: none;
    letter-spacing: 0;
}
.github-version:hover { color: #007aff; }

/* =========================================================
   分享端 — 默认区（无 data-mode 或 data-mode="sharer"）
   ========================================================= */

body {
    min-height: 100vh;
    position: relative;
    background: #111;
    color: #fff;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 30px 20px;
}

#share-screen { width: 100%; }

.container {
    position: relative;
    width: 100%;
    max-width: 724px;
    margin: 0 auto;
    background: #1c1c1e;
    padding: 35px 30px;
    border-radius: 24px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
    text-align: center;
}

.page-header {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 25px;
    min-height: 30px;
    position: relative;
}

h2 {
    width: 100%;
    margin: 0;
    font-size: 24px;
    line-height: 1.2;
    font-weight: 700;
    color: #007aff;
}

.app-subtitle {
    font-size: 16px;
    line-height: 1.2;
    color: #8e8e93;
    font-weight: normal;
}

.theme-toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: #8e8e93;
    cursor: pointer;
    flex-shrink: 0;
    font-size: 12px;
    font-weight: 600;
    position: absolute;
    right: 0;
    user-select: none;
}

.theme-toggle input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.theme-toggle-track {
    position: relative;
    width: 42px;
    height: 24px;
    border-radius: 999px;
    background: #3a3a3c;
    transition: background 0.2s ease;
}

.theme-toggle-track::after {
    content: "";
    position: absolute;
    top: 3px;
    left: 3px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.24);
    transition: transform 0.2s ease;
}

.theme-toggle input:checked + .theme-toggle-track { background: #007aff; }

.theme-toggle input:checked + .theme-toggle-track::after { transform: translateX(18px); }

.guide {
    text-align: left;
    background: #2c2c2e;
    padding: 12px 15px;
    border-radius: 12px;
    margin-bottom: 20px;
    font-size: 14px;
    line-height: 1.6;
    color: #ccc;
}

.guide b { color: #fff; }

.guide-steps {
    background: transparent;
    padding: 0;
    margin-bottom: 25px;
}

.guide-title {
    color: #fff;
    font-size: 15px;
    margin: 0 0 12px;
    font-weight: 500;
}

.guide-list {
    color: #8e8e93;
    font-size: 14px;
    margin: 0;
    padding-left: 20px;
    line-height: 1.75;
}

.share-actions {
    display: flex;
    gap: 10px;
    width: 100%;
    max-width: none;
    margin: 5px auto 0;
    scroll-margin-top: 18px;
}

.share-actions button { flex: 1; min-width: 0; }

#generateBtn, #pauseBtn {
    width: 100%;
    font-size: 18px;
    font-weight: 600;
    padding: 15px;
    border: none;
    color: white;
    border-radius: 12px;
    cursor: pointer;
    transition: 0.2s;
}

#generateBtn { background: #007aff; }
#generateBtn:hover { background: #0056b3; }

#generateBtn:disabled, #pauseBtn:disabled { opacity: 0.6; cursor: not-allowed; }

#generateBtn.active { background: #ff453a; }
#generateBtn.active:hover { background: #d73a2f; }

#pauseBtn { display: none; background: #ff9f0a; }
#pauseBtn:hover { background: #c97800; }
#pauseBtn.paused { background: #34c759; }
#pauseBtn.paused:hover { background: #248a3d; }

#shareInfo {
    display: none;
    margin-top: 15px;
    text-align: left;
    word-break: break-all;
}

.info-card {
    background: #2c2c2e;
    padding: 20px;
    border-radius: 12px;
    border-left: 4px solid #34c759;
}

.share-success { margin: 0 0 10px; color: #34c759; font-weight: bold; }

.share-preview-header {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    color: #8e8e93;
    font-size: 12px;
    font-weight: 600;
}

.share-preview-video {
    position: relative;
    display: flex;
    width: 100%;
    min-height: 0;
    aspect-ratio: 16 / 9;
    align-self: flex-start;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background: #111;
    border-radius: 8px;
    color: #636366;
    font-size: 12px;
}

.share-preview-video video {
    width: 100% !important;
    height: 100% !important;
    object-fit: contain !important;
}

.url-box {
    font-size: 14px;
    background: #111;
    padding: 10px;
    border-radius: 6px;
    margin-bottom: 10px;
}

.copy-btn {
    margin-top: 10px;
    padding: 8px 15px;
    background: #3a3a3c;
    border: none;
    color: #007aff;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
}

#status {
    margin-top: 15px;
    font-size: 14px;
    color: #8e8e93;
    white-space: pre-line;
}

/* ── 分享端 — 分段选择器 ── */
.segmented-control {
    display: flex;
    background: rgba(255, 255, 255, 0.05);
    padding: 4px;
    border-radius: 14px;
    margin-bottom: 10px;
    justify-content: center;
    min-height: 45px;
    box-sizing: border-box;
}

.control-item {
    flex: 1;
    min-width: 0;
    padding: 10px 0;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    font-size: 14px;
    line-height: 1;
    white-space: nowrap;
    cursor: pointer;
    border-radius: 10px;
    color: #8e8e93;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.control-item.active {
    background: #3a3a3c;
    color: #007aff;
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

#customDurationBox {
    margin-bottom: 12px;
    display: none;
}

#customDurationBox input {
    width: 100%;
    padding: 14px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #fff;
    border-radius: 12px;
    font-size: 15px;
    outline: none;
    box-sizing: border-box;
    text-align: center;
}

.field-block {
    margin-bottom: 12px;
    text-align: left;
}

.field-block label {
    display: block;
    margin-bottom: 8px;
    color: #8e8e93;
    font-size: 13px;
    font-weight: 600;
}

#sharePromptInput {
    width: 100%;
    min-height: 68px;
    padding: 12px 14px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #fff;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.5;
    resize: vertical;
    outline: none;
    box-sizing: border-box;
}

#sharePromptInput:focus { border-color: #007aff; }

#sharePromptInput:disabled { opacity: 0.65; cursor: not-allowed; }

.prompt-preview {
    display: none;
    margin: 10px 0;
    padding: 10px;
    background: rgba(0, 122, 255, 0.12);
    border-radius: 8px;
    color: #d8ecff;
    font-size: 13px;
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-word;
}

.copy-toast {
    display: none;
    margin-top: 10px;
    padding: 8px 10px;
    background: rgba(52, 199, 89, 0.14);
    color: #34c759;
    border-radius: 8px;
    font-size: 13px;
    text-align: center;
}

/* ── 分享端 — 侧边面板 ── */
.share-side-panel {
    display: none;
    position: fixed;
    top: var(--share-side-top, 30px);
    bottom: 30px;
    z-index: 2;
    width: 220px;
    min-width: 0;
    pointer-events: none;
}

.share-side-panel.active { display: flex; }

.share-side-stats {
    right: var(--side-stats-right, -9999px);
    width: 285px;
    align-items: flex-start;
    justify-content: flex-start;
}

.share-side-preview {
    left: var(--side-preview-left, -9999px);
    align-items: flex-start;
    justify-content: flex-start;
    width: var(--side-preview-width, 500px);
}

.side-panel-inner {
    width: 100%;
    pointer-events: auto;
}

.share-side-stats .side-panel-inner {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 8px;
}

.share-side-preview .side-panel-inner {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 8px;
}

.side-stat-block {
    min-width: 0;
    width: 154px;
    padding: 8px;
    background: rgba(44, 44, 46, 0.72);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 9px;
    text-align: right;
    backdrop-filter: blur(10px);
}

.side-stat-label {
    display: block;
    margin-bottom: 5px;
    color: #8e8e93;
    font-size: 13px;
    font-weight: 600;
}

.side-stat-block strong {
    display: block;
    margin-bottom: 4px;
    color: #fff;
    font-size: 23px;
    line-height: 1.1;
}

.side-stat-block span:last-child {
    display: block;
    color: #a1a1a6;
    font-size: 13px;
    line-height: 1.25;
    word-break: break-word;
}

/* ── 分享端 — 观众面板 / 记录 ── */
.viewer-panel {
    margin-top: 20px;
    padding: 15px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    text-align: left;
    display: none;
    position: relative;
}

.viewer-panel h3 {
    margin: 0 0 10px 0;
    font-size: 14px;
    color: #8e8e93;
    font-weight: 500;
}

.viewer-item {
    font-size: 10.5px;
    padding: 10px 15px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
}

.viewer-item:last-child { border-bottom: none; }

.viewer-row {
    display: flex;
    align-items: center;
    gap: 4px;
    overflow-x: auto;
    scrollbar-width: none;
}

.viewer-row::-webkit-scrollbar { display: none; }

.viewer-main {
    display: flex;
    align-items: center;
    flex-shrink: 0;
    margin-right: 0;
}

.viewer-device-name { color: #fff; margin-right: 0; }

.viewer-item .dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #34c759;
    margin-right: 8px;
}

.viewer-details {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.viewer-times {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding-left: 0;
    margin-top: 2px;
}

.tag {
    padding: 3px 8px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 6px;
    color: #a1a1a6;
    white-space: nowrap;
}

.tag-uid { background: rgba(0, 122, 255, 0.15); color: #007aff; }
.tag-session { background: rgba(94, 92, 230, 0.15); color: #8f8cff; }
.tag-support { background: rgba(10, 132, 255, 0.14); color: #64d2ff; }
.tag-visits { background: rgba(255, 55, 95, 0.15); color: #ff375f; font-weight: bold; }
.tag-net { background: rgba(52, 199, 89, 0.15); color: #34c759; }
.tag-res { background: rgba(255, 159, 10, 0.15); color: #ff9f0a; }

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 10px;
}

.mini-btn {
    padding: 5px 9px;
    background: rgba(255, 255, 255, 0.08);
    border: none;
    color: #8e8e93;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
}

.viewer-panel.collapsed .panel-body { display: none; }

.record-group { padding-top: 0; }
.record-group + .record-group {
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.record-group-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 10px;
}

.record-group-header h4 { margin: 0; color: #8e8e93; font-size: 14px; font-weight: 500; }

.record-group-count {
    display: inline-block;
    color: rgba(99, 99, 102, 0.6);
    font-size: 12.5px;
    white-space: nowrap;
}

.record-group-summary {
    display: flex;
    align-items: baseline;
    gap: 6px;
    min-width: 0;
}

.record-group-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.record-group.collapsed .record-group-body { display: none; }

.record-group-body {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.record-group-toggle { flex-shrink: 0; }

.record-item { border-bottom: 1px solid rgba(255, 255, 255, 0.06); }
.record-item:last-child { border-bottom: none; }

.empty-state {
    padding: 12px 0;
    color: #636366;
    font-size: 13px;
    text-align: center;
}

/* ── 分享端 — 亮色主题 ── */
body.theme-light {
    background: #f3f5f8;
    color: #1d1d1f;
}

body.theme-light .container {
    background: #fff;
    box-shadow: 0 20px 50px rgba(28, 36, 48, 0.14);
}

body.theme-light .app-subtitle,
body.theme-light .guide-list,
body.theme-light .theme-toggle,
body.theme-light #status,
body.theme-light .field-block label,
body.theme-light .viewer-panel h3,
body.theme-light .share-preview-header,
body.theme-light .side-stat-label,
body.theme-light .side-stat-block span:last-child,
body.theme-light .empty-state,
body.theme-light .record-group-header h4,
body.theme-light .record-group-count { color: #6e7480; }

body.theme-light .guide-title,
body.theme-light .guide b,
body.theme-light .viewer-device-name,
body.theme-light .side-stat-block strong { color: #1d1d1f; }

body.theme-light .segmented-control,
body.theme-light .viewer-panel { background: rgba(20, 28, 38, 0.06); }

body.theme-light .control-item { color: #6e7480; }

body.theme-light .control-item.active {
    background: #fff;
    color: #007aff;
    box-shadow: 0 2px 10px rgba(20, 28, 38, 0.12);
}

body.theme-light .theme-toggle-track,
body.theme-light .copy-btn,
body.theme-light .mini-btn { background: rgba(20, 28, 38, 0.08); }

body.theme-light .info-card,
body.theme-light .side-stat-block {
    background: rgba(255, 255, 255, 0.82);
    border-color: rgba(20, 28, 38, 0.1);
    box-shadow: 0 12px 32px rgba(28, 36, 48, 0.1);
}

body.theme-light .url-box {
    background: #fff;
    color: #1d1d1f;
    border: 1px solid rgba(20, 28, 38, 0.12);
}

body.theme-light .share-preview-video { background: #101418; color: #8e949d; }

body.theme-light #customDurationBox input,
body.theme-light #sharePromptInput {
    background: #fff;
    border-color: rgba(20, 28, 38, 0.14);
    color: #1d1d1f;
}

body.theme-light #customDurationBox input:focus,
body.theme-light #sharePromptInput:focus { border-color: #007aff; }

body.theme-light .prompt-preview {
    background: rgba(0, 122, 255, 0.1);
    color: #164a7a;
}

body.theme-light .viewer-item,
body.theme-light .record-item { border-bottom-color: rgba(20, 28, 38, 0.08); }

body.theme-light .record-group + .record-group { border-top-color: rgba(20, 28, 38, 0.1); }

body.theme-light .tag { background: rgba(20, 28, 38, 0.08); color: #6e7480; }
body.theme-light .tag-uid { background: rgba(0, 122, 255, 0.12); color: #006edb; }
body.theme-light .tag-session { background: rgba(94, 92, 230, 0.12); color: #5e5ce6; }
body.theme-light .tag-support { background: rgba(10, 132, 255, 0.12); color: #0874d1; }
body.theme-light .tag-visits { background: rgba(255, 55, 95, 0.12); color: #d92d54; }
body.theme-light .tag-net { background: rgba(52, 199, 89, 0.14); color: #22863a; }
body.theme-light .tag-res { background: rgba(255, 159, 10, 0.16); color: #b86b00; }

/* ── 响应式：侧边面板 ── */
@media (max-width: 1260px) {
    .share-side-panel {
        position: static;
        width: 100%;
        max-width: 884px;
        margin: 0 auto 16px;
    }
    .share-side-preview { margin: 16px auto 0; }
}

@media (max-width: 720px) {
    body { padding: 20px 14px; }
    .container { padding: 28px 18px; }
    .page-header { flex-direction: column; gap: 12px; }
    .theme-toggle { position: static; }
    .side-stat-block strong { font-size: 29px; }
}

/* 分享端默认隐藏观看端 */
#viewer-screen { display: none; }

/* =========================================================
   观看端 — html[data-mode="viewer"] 作用域
   ========================================================= */
html[data-mode="viewer"] body {
    margin: 0;
    padding: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: #000;
    color: #fff;
}

html[data-mode="viewer"] #share-screen { display: none; }

html[data-mode="viewer"] #viewer-screen {
    display: flex;
    flex-direction: column;
    flex: 1;
}

html[data-mode="viewer"] #login-screen {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 20px;
    background: #111;
}

html[data-mode="viewer"] .login-box {
    width: 100%;
    max-width: 320px;
    text-align: center;
}

html[data-mode="viewer"] .login-title {
    margin-bottom: 40px;
    color: #fff;
    font-weight: 400;
}

html[data-mode="viewer"] .login-subtitle {
    font-size: 16px;
    color: #8e8e93;
}

html[data-mode="viewer"] #pwdInput {
    width: 100%;
    padding: 15px;
    font-size: 24px;
    letter-spacing: 12px;
    text-align: center;
    background: #2c2c2e;
    border: 1px solid #3a3a3c;
    color: #fff;
    border-radius: 12px;
    outline: none;
}

html[data-mode="viewer"] #pwdInput:focus { border-color: #007aff; }

html[data-mode="viewer"] #enterBtn {
    width: 100%;
    margin-top: 20px;
    padding: 15px;
    font-size: 18px;
    font-weight: 600;
    background: #007aff;
    border: none;
    color: white;
    border-radius: 12px;
    cursor: pointer;
}

html[data-mode="viewer"] #enterBtn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

html[data-mode="viewer"] #video-container {
    display: none;
    position: relative;
    flex: 1;
    background: #000;
}

html[data-mode="viewer"] #player {
    width: 100%;
    height: 100%;
}

html[data-mode="viewer"] video {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

html[data-mode="viewer"] #status-bar {
    position: absolute;
    top: 0;
    width: 100%;
    background: rgba(0,0,0,0.5);
    padding: 10px;
    font-size: 12px;
    color: #ccc;
    text-align: center;
    z-index: 10;
}

html[data-mode="viewer"] #error-msg {
    color: #ff453a;
    font-size: 14px;
    margin-top: 15px;
    min-height: 20px;
}

html[data-mode="viewer"] #share-note {
    display: none;
    margin: -20px 0 22px;
    padding: 12px 14px;
    background: #1c1c1e;
    border-left: 4px solid #007aff;
    border-radius: 10px;
    color: #d8ecff;
    font-size: 14px;
    line-height: 1.5;
    text-align: left;
    white-space: pre-wrap;
    word-break: break-word;
}

html[data-mode="viewer"] #video-note {
    display: none;
    position: absolute;
    top: 44px;
    left: 12px;
    right: 12px;
    z-index: 11;
    padding: 10px 12px;
    background: rgba(28, 28, 30, 0.88);
    border-left: 4px solid #007aff;
    border-radius: 10px;
    color: #d8ecff;
    font-size: 13px;
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-word;
    backdrop-filter: blur(8px);
}

html[data-mode="viewer"] .invalid-link {
    padding: 50px;
    text-align: center;
}

/* 观看端不需要侧边面板，直接隐藏 */
html[data-mode="viewer"] .share-side-panel { display: none !important; }
