/* ==========================================================================
   台北捷運工程 CCTV 智慧戰情室 - 樣式表 (Modern Light Clean Theme v5.0)
   ========================================================================== */

:root {
    --bg-base: #f1f5f9;
    --bg-sidebar: #ffffff;
    --bg-surface: #ffffff;
    --bg-card: #ffffff;
    --bg-card-hover: #f8fafc;
    --bg-control: #f8fafc;
    --bg-control-hover: #f1f5f9;
    
    --border-subtle: #e2e8f0;
    --border-highlight: #0284c7;
    --border-accent: #0284c7;
    
    --text-main: #0f172a;
    --text-muted: #334155;
    --text-dim: #64748b;
    
    --accent-blue: #0284c7;
    --accent-blue-hover: #0369a1;
    --accent-blue-glow: rgba(2, 132, 199, 0.15);
    --accent-green: #10b981;
    --accent-amber: #d97706;
    --accent-red: #ef4444;
    --accent-purple: #8b5cf6;
    --accent-cyan: #0891b2;

    --font-heading: 'Chakra Petch', 'Noto Sans TC', sans-serif;
    --font-body: 'Noto Sans TC', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;

    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --sidebar-width: 320px;
}

/* 全域重設 */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--bg-base);
    color: var(--text-main);
    font-family: var(--font-body);
    font-size: 13.5px;
    line-height: 1.4;
    height: 100vh;
    overflow: hidden;
}

/* 整體雙欄版面 */
.app-layout {
    display: flex;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
    position: relative;
}

/* ==========================================================================
   左側邊欄 (Sidebar - 淺色乾淨風格)
   ========================================================================== */
.sidebar-panel {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
    z-index: 50;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.04);
    transition: width 0.25s cubic-bezier(0.4, 0, 0.2, 1), min-width 0.25s cubic-bezier(0.4, 0, 0.2, 1), transform 0.25s ease;
}

/* 側邊欄收合樣式 */
.sidebar-panel.collapsed {
    width: 0 !important;
    min-width: 0 !important;
    border-right: none;
    transform: translateX(-100%);
    pointer-events: none;
}

.sidebar-header {
    padding: 12px 16px;
    background: #ffffff;
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.brand-title h2 {
    font-family: var(--font-heading);
    font-size: 15px;
    font-weight: 700;
    color: #0f172a;
    line-height: 1.2;
}

.brand-title span {
    font-family: var(--font-mono);
    font-size: 9.5px;
    color: var(--text-dim);
    letter-spacing: 0.5px;
}

.sidebar-close-btn {
    background: var(--bg-control);
    border: 1px solid var(--border-subtle);
    color: var(--text-dim);
    width: 26px;
    height: 26px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.15s ease;
}

.sidebar-close-btn:hover {
    background: #e2e8f0;
    color: #0f172a;
}

/* 邊欄區塊共用 */
.sidebar-section {
    padding: 10px 14px;
    border-bottom: 1px solid var(--border-subtle);
}

.section-label {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.section-label-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    user-select: none;
}

.toggle-icon {
    font-size: 11px;
    color: var(--text-dim);
    transition: transform 0.2s;
}

/* 1. 搜尋框 */
.search-input-wrap {
    position: relative;
    width: 100%;
    display: flex;
    align-items: center;
}

.search-icon {
    position: absolute;
    left: 10px;
    color: var(--text-dim);
    font-size: 13px;
    pointer-events: none;
}

.search-input-wrap input {
    width: 100%;
    background: var(--bg-control);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    color: var(--text-main);
    padding: 7px 30px 7px 30px;
    font-size: 12.5px;
    outline: none;
    transition: all 0.2s ease;
}

.search-input-wrap input:focus {
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 3px var(--accent-blue-glow);
    background: #ffffff;
}

.btn-clear {
    position: absolute;
    right: 8px;
    background: none;
    border: none;
    color: var(--text-dim);
    font-size: 12px;
    cursor: pointer;
    display: none;
}

.btn-clear:hover {
    color: var(--text-main);
}

.search-tip-hint {
    font-size: 10.5px;
    color: var(--text-dim);
    margin-top: 5px;
    padding-left: 2px;
    line-height: 1.3;
}

/* 2. 多維篩選折疊區 */
.filter-dropdown-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    margin-top: 6px;
    transition: all 0.2s ease;
}

.filter-dropdown-grid.collapsed {
    display: none;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.filter-group label {
    font-size: 10.5px;
    color: var(--text-dim);
    font-weight: 600;
}

.filter-group select {
    background: var(--bg-control);
    border: 1px solid var(--border-subtle);
    color: var(--text-main);
    padding: 5px 6px;
    border-radius: var(--radius-sm);
    font-size: 11.5px;
    outline: none;
    cursor: pointer;
    width: 100%;
    text-overflow: ellipsis;
}

.filter-group select:focus {
    border-color: var(--accent-blue);
    background: #ffffff;
}

.filter-actions-row {
    margin-top: 8px;
    display: flex;
    justify-content: flex-end;
}

.btn-mini-reset {
    background: #fee2e2;
    color: #dc2626;
    border: 1px solid #fecaca;
    padding: 3px 8px;
    border-radius: var(--radius-sm);
    font-size: 11px;
    cursor: pointer;
    transition: all 0.15s;
    font-weight: 500;
}

.btn-mini-reset:hover {
    background: #fecaca;
    color: #b91c1c;
}

/* 3. 設備列表清單 (Device List) */
.device-list-section {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    padding: 8px 10px;
    overflow: hidden;
    border-bottom: none;
}

.device-list-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 6px;
    padding: 0 4px;
}

.device-header-left {
    display: flex;
    align-items: center;
    gap: 6px;
}

.device-count-badge {
    background: #e0f2fe;
    color: #0284c7;
    font-size: 10.5px;
    padding: 1px 6px;
    border-radius: 10px;
    font-family: var(--font-mono);
    font-weight: 600;
}

.btn-mini {
    background: var(--bg-control);
    border: 1px solid var(--border-subtle);
    color: var(--text-muted);
    font-size: 11px;
    padding: 2px 7px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.15s;
    font-weight: 500;
}

.btn-mini:hover {
    background: #e2e8f0;
    color: #0f172a;
}

.device-items-scroll {
    flex-grow: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding-right: 4px;
}

.device-items-scroll::-webkit-scrollbar {
    width: 4px;
}
.device-items-scroll::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

/* 設備卡條項目 */
.device-item-card {
    background: #ffffff;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    padding: 6px 8px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    transition: all 0.15s ease;
    user-select: none;
    gap: 6px;
}

.device-item-card:hover {
    background: #f8fafc;
    border-color: #93c5fd;
    transform: translateX(2px);
}

.device-item-card.highlighted {
    border-color: var(--accent-blue);
    box-shadow: 0 0 10px rgba(2, 132, 199, 0.25);
    background: #f0f9ff;
}

.device-item-main {
    display: flex;
    flex-direction: column;
    gap: 2px;
    overflow: hidden;
    flex-grow: 1;
}

.device-loc-row {
    display: flex;
    align-items: center;
    gap: 5px;
    overflow: hidden;
}

.device-id-tag {
    font-size: 9.5px;
    font-family: var(--font-mono);
    background: #e2e8f0;
    color: #475569;
    padding: 0 4px;
    border-radius: 2px;
    font-weight: 600;
}

.device-loc-name {
    font-size: 12px;
    font-weight: 600;
    color: #0f172a;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.device-sub-row {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 10px;
    color: var(--text-dim);
}

.device-item-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}

.btn-item-fav {
    background: transparent;
    border: none;
    color: #cbd5e1;
    font-size: 14px;
    cursor: pointer;
    padding: 2px;
    line-height: 1;
}

.btn-item-fav:hover {
    color: #f59e0b;
}

.btn-item-fav.active {
    color: #f59e0b;
}

/* ==========================================================================
   右側主監控面板 (Main Panel)
   ========================================================================== */
.main-content-panel {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
    background: var(--bg-base);
    transition: width 0.25s ease;
}

/* 頂部戰情列 (清爽簡潔白底) */
.top-nav-bar {
    background: #ffffff;
    border-bottom: 1px solid var(--border-subtle);
    padding: 6px 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-shrink: 0;
    min-height: 48px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.top-nav-left {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* 側邊欄切換按鈕 */
.sidebar-toggle-btn {
    background: #f8fafc;
    border: 1px solid var(--border-subtle);
    color: #0284c7;
    padding: 5px 10px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    white-space: nowrap;
    transition: all 0.15s ease;
}

.sidebar-toggle-btn:hover {
    background: #e0f2fe;
    border-color: #0284c7;
}

/* ==========================================================================
   單一「觀看組合」下拉浮動面板 (防止按鈕過多溢出)
   ========================================================================== */
.preset-menu-wrapper {
    position: relative;
    display: inline-block;
}

.preset-menu-trigger-btn {
    background: #f0f9ff;
    border: 1px solid #bae6fd;
    color: #0369a1;
    padding: 5px 12px;
    border-radius: var(--radius-sm);
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.15s ease;
}

.preset-menu-trigger-btn:hover {
    background: #e0f2fe;
    border-color: #0284c7;
}

.preset-cur-name {
    font-weight: 700;
    color: #0c4a6e;
}

.preset-cur-count {
    background: #0284c7;
    color: #ffffff;
    font-size: 10.5px;
    padding: 1px 6px;
    border-radius: 10px;
    font-family: var(--font-mono);
}

.arrow-down {
    font-size: 10px;
    color: #0284c7;
}

/* 組合下拉展開選單 */
.preset-dropdown-panel {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    width: 280px;
    background: #ffffff;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.12), 0 4px 6px rgba(0, 0, 0, 0.04);
    z-index: 200;
    display: flex;
    flex-direction: column;
    animation: menu-down 0.15s ease-out;
}

@keyframes menu-down {
    0% { opacity: 0; transform: translateY(-6px); }
    100% { opacity: 1; transform: translateY(0); }
}

.preset-dropdown-panel.hidden {
    display: none;
}

.preset-panel-header {
    padding: 8px 12px;
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 11.5px;
    font-weight: 700;
    color: var(--text-dim);
    background: #f8fafc;
}

.btn-menu-add {
    background: #dbeafe;
    border: 1px solid #bfdbfe;
    color: #1d4ed8;
    padding: 2px 6px;
    border-radius: var(--radius-sm);
    font-size: 11px;
    cursor: pointer;
    font-weight: 600;
}

.btn-menu-add:hover {
    background: #bfdbfe;
}

.preset-panel-items {
    max-height: 280px;
    overflow-y: auto;
    padding: 4px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.preset-panel-item {
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    transition: background 0.15s;
    font-size: 12.5px;
    color: var(--text-main);
}

.preset-panel-item:hover {
    background: #f1f5f9;
}

.preset-panel-item.active {
    background: #e0f2fe;
    color: #0369a1;
    font-weight: 700;
}

.preset-item-left {
    display: flex;
    align-items: center;
    gap: 8px;
}

.preset-color-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.preset-panel-footer {
    padding: 6px;
    border-top: 1px solid var(--border-subtle);
    background: #f8fafc;
}

.btn-menu-manage {
    width: 100%;
    background: transparent;
    border: none;
    color: var(--text-dim);
    font-size: 11.5px;
    padding: 4px;
    cursor: pointer;
    text-align: center;
    border-radius: var(--radius-sm);
}

.btn-menu-manage:hover {
    color: #0f172a;
    background: #e2e8f0;
}

/* 頂部右側控制項 */
.top-right-controls {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

/* 排版快捷按鈕群 (1x1, 2x2, 3x3, 4x4, 標準, 全寬) */
.layout-quick-bar {
    display: flex;
    align-items: center;
    background: #f1f5f9;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    padding: 2px;
    gap: 2px;
}

.layout-btn {
    background: transparent;
    border: none;
    color: var(--text-dim);
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 600;
    padding: 3px 6px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.15s ease;
    user-select: none;
}

.layout-btn:hover {
    color: #0f172a;
    background: #e2e8f0;
}

.layout-btn.active {
    background: #0284c7;
    color: #ffffff;
    box-shadow: 0 1px 3px rgba(2, 132, 199, 0.3);
}

.time-clock-box {
    background: #f8fafc;
    border: 1px solid var(--border-subtle);
    padding: 3px 8px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    gap: 5px;
}

.clock-label {
    font-size: 8.5px;
    font-family: var(--font-mono);
    color: var(--text-dim);
    letter-spacing: 0.5px;
}

.clock-digits {
    font-family: var(--font-mono);
    font-size: 12.5px;
    font-weight: 600;
    color: #0284c7;
}

/* 自動重整簡潔框 */
.keepalive-simple-box {
    display: flex;
    align-items: center;
    gap: 3px;
    background: #f8fafc;
    border: 1px solid var(--border-subtle);
    padding: 3px 6px;
    border-radius: var(--radius-sm);
}

.keepalive-simple-box label {
    font-size: 11px;
    color: var(--text-dim);
    white-space: nowrap;
}

.keepalive-simple-box select {
    background: transparent;
    color: var(--text-main);
    border: none;
    font-size: 11.5px;
    cursor: pointer;
    outline: none;
    font-weight: 600;
}

.nav-btn {
    background: #f8fafc;
    color: var(--text-main);
    border: 1px solid var(--border-subtle);
    padding: 4px 9px;
    border-radius: var(--radius-sm);
    font-size: 11.5px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    transition: all 0.15s;
    user-select: none;
    font-weight: 500;
}

.nav-btn:hover {
    background: #e2e8f0;
    color: #0f172a;
}

.btn-refresh:hover {
    border-color: #0284c7;
    color: #0284c7;
}

.btn-patrol.active {
    background: #d1fae5;
    border-color: #10b981;
    color: #047857;
}

.nav-btn.icon-only {
    padding: 4px 7px;
}

/* ==========================================================================
   視訊網格區 (CCTV Viewport & Layouts 1x1, 2x2, 3x3, 4x4)
   ========================================================================== */
.cctv-viewport {
    flex-grow: 1;
    padding: 8px;
    background: #f1f5f9;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    min-height: 0;
    height: 100%;
}

.cam-grid {
    display: grid;
    gap: 8px;
    width: 100%;
    height: 100%;
    min-height: 0;
}

/* 1×1 單格專注模式 */
.cam-grid.layout-grid-1x1 {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr;
    height: 100%;
}

/* 2×2 四分割模式 (2列 x 2欄 完美填滿視窗) */
.cam-grid.layout-grid-2x2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-rows: repeat(2, minmax(0, 1fr));
    height: 100%;
}

/* 3×3 九分割模式 (3列 x 3欄 完美填滿視窗) */
.cam-grid.layout-grid-3x3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    grid-template-rows: repeat(3, minmax(0, 1fr));
    height: 100%;
}

/* 4×4 十六分割模式 (4列 x 4欄 完美填滿視窗) */
.cam-grid.layout-grid-4x4 {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    grid-template-rows: repeat(4, minmax(0, 1fr));
    height: 100%;
}

/* 在 1x1, 2x2, 3x3, 4x4 固定分割模式下，卡片高度自動填滿 */
.cam-grid.layout-grid-1x1 .cam-card,
.cam-grid.layout-grid-2x2 .cam-card,
.cam-grid.layout-grid-3x3 .cam-card,
.cam-grid.layout-grid-4x4 .cam-card {
    height: 100%;
    min-height: 0;
    max-height: 100%;
    display: flex;
    flex-direction: column;
}

.cam-grid.layout-grid-1x1 .cam-video-box,
.cam-grid.layout-grid-2x2 .cam-video-box,
.cam-grid.layout-grid-3x3 .cam-video-box,
.cam-grid.layout-grid-4x4 .cam-video-box {
    flex-grow: 1;
    height: 100%;
    min-height: 0;
    padding-bottom: 0;
    position: relative;
}

/* 自然流動網格模式 (標準 / 全寬) */
.cam-grid.layout-auto-400 {
    grid-template-columns: repeat(auto-fill, minmax(380px, 1fr));
    height: auto;
    align-content: start;
}

.cam-grid.layout-grid-100 {
    grid-template-columns: 1fr;
    height: auto;
    align-content: start;
}

.cam-grid.layout-auto-400 .cam-video-box,
.cam-grid.layout-grid-100 .cam-video-box {
    padding-bottom: 56.25%; /* 16:9 比例 */
}

/* 攝影機卡片通用樣式 (淺色質感) */
.cam-card {
    background: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: var(--radius-sm);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    position: relative;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.cam-card:hover {
    border-color: #0284c7;
    box-shadow: 0 4px 12px rgba(2, 132, 199, 0.15);
}

.cam-card.flash-highlight {
    animation: card-flash 1.5s ease-out;
}

@keyframes card-flash {
    0% { border-color: #0284c7; box-shadow: 0 0 20px rgba(2, 132, 199, 0.6); }
    100% { border-color: #cbd5e1; box-shadow: none; }
}

.cam-card-header {
    background: #f8fafc;
    padding: 4px 8px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-subtle);
    gap: 6px;
    flex-shrink: 0;
}

.cam-card-title-group {
    display: flex;
    flex-direction: column;
    gap: 1px;
    overflow: hidden;
}

.cam-location-title {
    font-size: 12px;
    font-weight: 700;
    color: #0f172a;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cam-meta-tags {
    display: flex;
    align-items: center;
    gap: 3px;
    flex-wrap: wrap;
}

.badge-tag {
    font-size: 9px;
    padding: 0 4px;
    border-radius: 2px;
    font-family: var(--font-mono);
    font-weight: 600;
}

.tag-dept { background: #e2e8f0; color: #475569; }
.tag-proj { background: #e0f2fe; color: #0284c7; border: 1px solid #bae6fd; }
.tag-station { background: #d1fae5; color: #059669; border: 1px solid #a7f3d0; }
.tag-constructor { font-size: 10px; color: var(--text-dim); }

.cam-card-quick-actions {
    display: flex;
    align-items: center;
    gap: 2px;
    flex-shrink: 0;
}

.card-tool-btn {
    background: transparent;
    border: none;
    color: #64748b;
    font-size: 12px;
    padding: 2px 4px;
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: all 0.15s;
    line-height: 1;
}

.card-tool-btn:hover {
    background: #e2e8f0;
    color: #0f172a;
}

.card-tool-btn.btn-fav.active {
    color: #f59e0b;
}

.card-tool-btn.rotating, .btn-icon.rotating {
    animation: spin 0.8s linear infinite;
}

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

/* 視訊視窗 */
.cam-video-box {
    position: relative;
    width: 100%;
    background: #000000;
    overflow: hidden;
}

.cam-video-box iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: none;
    background: #000000;
}

.cam-loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.85);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    color: #0f172a;
    font-size: 11px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
    z-index: 5;
}

.cam-loading-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.spinner {
    width: 24px;
    height: 24px;
    border: 2.5px solid #e2e8f0;
    border-top-color: var(--accent-blue);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.cam-card-footer {
    background: #f8fafc;
    padding: 3px 8px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 10.5px;
    border-top: 1px solid var(--border-subtle);
    color: var(--text-dim);
    flex-shrink: 0;
}

.cam-card-footer a {
    color: #0284c7;
    text-decoration: none;
    font-weight: 500;
}

.cam-card-footer a:hover {
    text-decoration: underline;
}

.cam-status-indicator {
    display: flex;
    align-items: center;
    gap: 5px;
}

.status-dot-live {
    width: 6px;
    height: 6px;
    background-color: var(--accent-green);
    border-radius: 50%;
}

/* 空狀態 */
.empty-placeholder {
    grid-column: 1 / -1;
    text-align: center;
    padding: 60px 20px;
    color: var(--text-dim);
}

.empty-placeholder .empty-icon {
    font-size: 40px;
    margin-bottom: 8px;
}

/* 底部狀態列 */
.bottom-status-bar {
    background: #ffffff;
    border-top: 1px solid var(--border-subtle);
    padding: 4px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 11px;
    color: var(--text-dim);
    flex-shrink: 0;
}

.tip-icon {
    color: var(--accent-amber);
}

/* ==========================================================================
   彈窗系統 (Modals - 淺色乾淨風格)
   ========================================================================== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 999;
    padding: 20px;
    opacity: 1;
    transition: opacity 0.2s ease;
}

.modal-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.modal-dialog {
    background: #ffffff;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
    width: 100%;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.modal-sm { max-width: 450px; }
.modal-md { max-width: 580px; }
.modal-lg { max-width: 820px; }

.modal-header {
    padding: 12px 18px;
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #f8fafc;
}

.modal-header h2 {
    font-size: 15px;
    font-weight: 700;
    color: #0f172a;
}

.modal-close-btn {
    background: none;
    border: none;
    color: var(--text-dim);
    font-size: 16px;
    cursor: pointer;
}

.modal-close-btn:hover {
    color: #0f172a;
}

.modal-body {
    padding: 16px 18px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.modal-footer {
    padding: 10px 18px;
    border-top: 1px solid var(--border-subtle);
    background: #f8fafc;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.form-group label {
    font-size: 12.5px;
    font-weight: 600;
    color: var(--text-main);
}

.form-group input[type="text"] {
    background: var(--bg-control);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    color: var(--text-main);
    padding: 7px 10px;
    font-size: 13px;
    outline: none;
}

.form-group input[type="text"]:focus {
    border-color: var(--accent-blue);
    background: #ffffff;
}

.color-picker-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
}

.color-chip {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid transparent;
    transition: transform 0.15s;
}

.color-chip.active {
    border-color: #0f172a;
    transform: scale(1.15);
}

/* 鏡頭多選清單 */
.cam-selector-section {
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    background: #f8fafc;
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.cam-selector-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 6px;
}

.selector-title {
    font-size: 12px;
    font-weight: 600;
    color: #0f172a;
}

.selector-quick-actions {
    display: flex;
    gap: 5px;
}

.btn-sub-action {
    background: #ffffff;
    border: 1px solid var(--border-subtle);
    color: var(--text-muted);
    font-size: 11px;
    padding: 3px 7px;
    border-radius: var(--radius-sm);
    cursor: pointer;
}

.btn-sub-action:hover {
    background: #e2e8f0;
    color: #0f172a;
}

.selector-filter-row input {
    width: 100%;
    background: #ffffff;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    color: var(--text-main);
    padding: 5px 8px;
    font-size: 12px;
    outline: none;
}

.cam-checkbox-list {
    max-height: 240px;
    overflow-y: auto;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
    gap: 6px;
}

.cam-checkbox-item {
    background: #ffffff;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    padding: 5px 7px;
    display: flex;
    align-items: flex-start;
    gap: 7px;
    cursor: pointer;
    user-select: none;
}

.cam-checkbox-item:hover {
    background: #f1f5f9;
}

.cam-checkbox-info {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.cam-check-loc {
    font-size: 11.5px;
    font-weight: 600;
    color: #0f172a;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cam-check-sub {
    font-size: 10px;
    color: var(--text-dim);
}

.preset-manage-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 380px;
    overflow-y: auto;
}

.preset-manage-item {
    background: #f8fafc;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 8px 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.manage-item-info {
    display: flex;
    align-items: center;
    gap: 8px;
}

.manage-item-color {
    width: 9px;
    height: 9px;
    border-radius: 50%;
}

.manage-item-name {
    font-size: 13px;
    font-weight: 600;
    color: #0f172a;
}

.manage-item-count {
    font-size: 11px;
    color: var(--text-dim);
    font-family: var(--font-mono);
}

.manage-item-actions {
    display: flex;
    gap: 5px;
}

.btn-primary {
    background: #0284c7;
    color: #ffffff;
    border: none;
    padding: 6px 14px;
    border-radius: var(--radius-sm);
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
}

.btn-primary:hover {
    background: #0369a1;
}

.btn-secondary {
    background: #f1f5f9;
    color: var(--text-muted);
    border: 1px solid var(--border-subtle);
    padding: 6px 14px;
    border-radius: var(--radius-sm);
    font-size: 12.5px;
    cursor: pointer;
}

.btn-secondary:hover {
    background: #e2e8f0;
    color: #0f172a;
}

.btn-danger-outline {
    background: transparent;
    border: 1px solid #fecaca;
    color: #dc2626;
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    cursor: pointer;
}

.btn-danger-outline:hover {
    background: #fee2e2;
}

/* 劇院模式 */
.modal-overlay.theater-mode {
    padding: 0;
    background: rgba(0, 0, 0, 0.95);
}

.theater-content {
    width: 95vw;
    max-width: 1400px;
    height: 90vh;
    display: flex;
    flex-direction: column;
    background: #0f172a;
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.theater-header {
    background: #1e293b;
    padding: 8px 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.theater-info {
    display: flex;
    align-items: center;
    gap: 8px;
}

.theater-title-text {
    font-size: 15px;
    font-weight: 700;
    color: #ffffff;
}

.theater-sub-text {
    font-size: 11.5px;
    color: #94a3b8;
}

.theater-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}

.theater-btn {
    background: #334155;
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #ffffff;
    padding: 5px 10px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    cursor: pointer;
}

.theater-btn:hover {
    background: #475569;
}

.theater-video-wrapper {
    flex-grow: 1;
    position: relative;
    background: #000;
}

.theater-video-wrapper iframe {
    width: 100%;
    height: 100%;
    border: none;
}
