/* ===========================
   全局重置 & 基础样式
   =========================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
                 "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    background: #0a0e14;
    color: #fff;
    -webkit-font-smoothing: antialiased;
}

/* ===========================
   布局容器
   =========================== */
.app-container {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100vh;
    height: 100dvh;
}

/* ===========================
   顶部栏
   =========================== */
.app-header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 16px;
    background: linear-gradient(135deg, #0f5132 0%, #14532d 100%);
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
    z-index: 10;
    flex-shrink: 0;
}

.header-icon {
    display: flex;
    align-items: center;
    color: #4ade80;
}

.header-title {
    font-size: 18px;
    font-weight: 600;
    color: #e8f5e9;
    letter-spacing: 1px;
}

/* ===========================
   视频播放区域
   =========================== */
.video-section {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background: #000;
    padding: 12px;
}

.video-wrapper {
    position: relative;
    width: min(100%, calc((100vh - 105px) * 16 / 9));
    width: min(100%, calc((100dvh - 105px) * 16 / 9));
    max-width: 1200px;
    aspect-ratio: 16 / 9;
    flex: 0 1 auto;
    overflow: hidden;
    background: #000;
    border-radius: 8px;
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.35);
}

.video-player {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: #000;
}

/* ===========================
   视频遮罩层（加载/错误）
   =========================== */
.video-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.85);
    z-index: 5;
}

/* 加载动画 */
.loading-spinner {
    width: 44px;
    height: 44px;
    border: 3px solid rgba(74, 222, 128, 0.2);
    border-top-color: #4ade80;
    border-radius: 50%;
    animation: spin 0.9s linear infinite;
}

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

.loading-text {
    margin-top: 16px;
    font-size: 14px;
    color: #9ca3af;
}

/* 错误状态 */
.error-overlay {
    background: rgba(0, 0, 0, 0.9);
}

.error-icon {
    color: #f87171;
    margin-bottom: 12px;
}

.error-text {
    font-size: 14px;
    color: #d1d5db;
    margin-bottom: 18px;
    text-align: center;
    padding: 0 20px;
}

.retry-btn {
    padding: 10px 32px;
    font-size: 14px;
    color: #fff;
    background: #16a34a;
    border: none;
    border-radius: 24px;
    cursor: pointer;
    transition: background 0.2s;
}

.retry-btn:active {
    background: #15803d;
    transform: scale(0.96);
}

/* ===========================
   直播标识
   =========================== */
.live-badge {
    position: absolute;
    top: 12px;
    right: 12px;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    background: rgba(220, 38, 38, 0.85);
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    color: #fff;
    z-index: 4;
}

.live-dot {
    width: 7px;
    height: 7px;
    background: #fff;
    border-radius: 50%;
    animation: pulse 1.5s ease-in-out infinite;
}

/* 声音开关：自动播放默认静音，必须由用户点击后才能解除 */
.sound-toggle {
    position: absolute;
    top: 10px;
    left: 10px;
    z-index: 4;
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 6px 10px;
    color: #fff;
    background: rgba(0, 0, 0, 0.62);
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 18px;
    font-size: 12px;
    line-height: 1;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.sound-toggle:active {
    background: rgba(22, 163, 74, 0.85);
    transform: scale(0.97);
}

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

/* ===========================
   画面底部信息栏
   =========================== */
.camera-info-bar {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.8) 0%, rgba(0, 0, 0, 0.4) 80%, transparent 100%);
    z-index: 4;
}

.camera-info-item {
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
    flex: 1;
}

.camera-info-divider {
    width: 1px;
    height: 28px;
    background: rgba(255, 255, 255, 0.2);
    flex-shrink: 0;
}

.info-label {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.55);
    letter-spacing: 0.5px;
}

.info-value {
    font-size: 14px;
    font-weight: 500;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ===========================
   底部页脚
   =========================== */
.app-footer {
    padding: 8px 16px;
    text-align: center;
    background: #0a0e14;
    flex-shrink: 0;
}

.footer-text {
    font-size: 12px;
    color: #4b5563;
}

/* ===========================
   多终端适配
   =========================== */

/* 平板 */
@media (min-width: 768px) {
    .header-title {
        font-size: 20px;
    }

    .camera-info-bar {
        padding: 16px 24px;
        gap: 20px;
    }

    .info-label {
        font-size: 12px;
    }

    .info-value {
        font-size: 15px;
    }

    .footer-text {
        font-size: 13px;
    }
}

/* 横屏手机尽可能利用可用高度，同时保持 16:9 */
@media (orientation: landscape) and (max-height: 600px) {
    .app-header {
        padding: 7px 12px;
    }

    .app-footer {
        display: none;
    }

    .video-section {
        padding: 6px;
    }

    .video-wrapper {
        width: min(100%, calc((100vh - 52px) * 16 / 9));
        width: min(100%, calc((100dvh - 52px) * 16 / 9));
    }
}

/* PC */
@media (min-width: 1200px) {
    .app-container {
        max-width: 900px;
        margin: 0 auto;
        box-shadow: 0 0 40px rgba(0, 0, 0, 0.5);
    }

    .header-title {
        font-size: 22px;
    }

    .camera-info-bar {
        padding: 18px 28px;
        gap: 24px;
    }

    .info-value {
        font-size: 16px;
    }

    .retry-btn:hover {
        background: #15803d;
    }

    .retry-btn {
        transition: background 0.2s, transform 0.1s;
    }
}
