* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%); padding: 20px; min-height: 100vh; padding-top: 70px; /* Add padding to prevent content from hiding under the fixed header */ }
h1 { text-align: center; color: #333; margin-top: 0; margin-bottom: 15px; font-size: 28px; text-shadow: 2px 2px 4px rgba(0,0,0,0.1); }

/* --- MODIFIED: Top Controls --- */
.header-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    background: rgba(255, 255, 255, 0.85);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    z-index: 1002;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    padding: 10px 20px;
    transition: top 0.3s ease-in-out; /* <-- 新增此行 */
}
.controls { max-width: 1400px; margin: 0 auto; display: flex; align-items: center; gap: 15px; flex-wrap: wrap; }

.auto-update-toggle { display: flex; align-items: center; gap: 8px; cursor: pointer; font-size: 14px; color: #555; }
.auto-update-toggle input { width: 18px; height: 18px; cursor: pointer; }

.header-hidden {
    top: -64px; /* <-- 將標頭移出畫面外，值要大於標頭高度 */
}

.update-info-container {
    display: flex;
    justify-content: space-between; /* 將子元素推向兩側 */
    align-items: center;
    flex-grow: 1; /* 允許此容器佔用可用空間 */
}


.last-update { color: #666; font-size: 14px; margin-left: auto; white-space: nowrap; }

/* --- MODIFIED: Page Toggle for Desktop --- */
.page-toggle {
    display: flex;
    gap: 10px;
    margin-left: 20px;
}
.toggle-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
    transition: all 0.3s ease;
}
.toggle-btn span { font-weight: bold; }
.toggle-btn:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(102, 126, 234, 0.5); }
.toggle-btn:disabled { opacity: 0.6; cursor: not-allowed; }
.toggle-btn.is-refreshing svg { animation: spin 1s linear infinite; }

.camera-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 15px; max-width: 1400px; margin: 20px auto; }
.camera-grid.force-2-col {
    grid-template-columns: repeat(2, 1fr) !important;
}

/* --- START: 新增此規則 --- */
.camera-grid.force-2-col .camera-label {
    white-space: nowrap; /* 強制文字不換行 */
    overflow: hidden; /* 隱藏超出的部分 */
    text-overflow: ellipsis; /* 超出部分顯示省略號 */
    /* 使用 clamp 實現響應式字體大小，最小10px，最大12px，根據視窗寬度縮放 */
    font-size: clamp(10px, 2.8vw, 12px);
}
/* --- END: 新增此規則 --- */
.camera-item { position: relative; background: white; border-radius: 8px; overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,0.1); transition: transform 0.3s ease; }
.camera-item:hover { transform: translateY(-4px); box-shadow: 0 6px 16px rgba(0,0,0,0.15); }
.camera-item img { width: 100%; height: auto; aspect-ratio: 4 / 3; object-fit: cover; display: block; background: #eee; cursor: pointer; }
.camera-item.error img {
    display: none; /* Hide the broken image icon */
}
.camera-item.error {
    background-color: #ffebee; /* Light red background for error */
    border: 1px solid #ef9a9a; /* Red border */
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 200px; /* Ensure it's visible even without image */
}
.camera-item.error::before {
    content: '❌'; /* Error icon */
    font-size: 48px;
    color: #ef5350;
    margin-bottom: 10px;
}
.camera-item.error .camera-label {
    color: #ef5350; /* Red text for label */
    font-weight: bold;
    background-color: transparent;
}
.camera-label { padding: 12px; text-align: center; font-size: 13px; color: #555; background-color: #f9f9f9; font-weight: 500; border-top: 1px solid #eee; }

.loading-indicator { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: rgba(102, 126, 234, 0.95); color: white; padding: 16px 28px; border-radius: 30px; display: none; align-items: center; gap: 12px; z-index: 1001; box-shadow: 0 6px 20px rgba(0,0,0,0.25); font-weight: 600; }
.loading-indicator.active { display: flex; }
.spinner { width: 24px; height: 24px; border: 3px solid rgba(255,255,255,0.3); border-top-color: white; border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.fab-container { position: fixed; bottom: 20px; right: 20px; z-index: 1001; display: flex; flex-direction: row; align-items: flex-end; gap: 10px; }
.fab-option-btn { background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); color: white; border: none; border-radius: 50%; width: 56px; height: 56px; display: flex; align-items: center; justify-content: center; font-size: 24px; cursor: pointer; box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4); transition: all 0.3s ease; }
.fab-option-btn:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(102, 126, 234, 0.6); }
.fab-option-btn span { font-weight: bold; }

/* Icon visibility classes */
.icon-visible { display: block !important; }
.icon-hidden { display: none !important; }

/* Media Queries */
@media (max-width: 768px) {
    body { padding-top: 80px; } /* Adjust padding for potentially taller header */
    h1 { font-size: 22px; margin-top: 0; }
    .controls { flex-direction: row; flex-wrap: wrap; } /* 修改：允許換行 */
    .update-info-container { width: 100%; } /* 新增：讓新容器佔滿整行 */
    .last-update { margin-left: 0; text-align: right; width: auto; margin-top: 0; } /* 修改：移除舊的置中和寬度樣式 */
    .page-toggle { display: none; } /* Hide desktop buttons on mobile */
    .fab-container { display: flex; } /* Show FAB on mobile */
}
@media (min-width: 769px) {
    .fab-container { display: none; } /* Hide FAB on desktop */
    .page-toggle { display: flex; } /* Show desktop buttons on desktop */
}

/* Other styles (modal, error, notification, skeleton) - remain unchanged */
.error-overlay { position: absolute; top: 0; left: 0; right: 0; bottom: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; background: rgba(255, 245, 245, 0.98); padding: 20px; text-align: center; z-index: 10; }
.error-title { color: #ff6b6b; font-weight: 600; margin: 10px 0 5px; font-size: 16px; }
.error-detail { color: #999; font-size: 13px; margin-bottom: 15px; }
.retry-btn { display: flex; align-items: center; gap: 6px; padding: 8px 16px; background: #667eea; color: white; border: none; border-radius: 5px; cursor: pointer; font-weight: 600; font-size: 14px; transition: all 0.2s; }
.retry-btn:hover { background: #5568d3; }
.retry-message { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); display: flex; align-items: center; gap: 10px; background: rgba(102, 126, 234, 0.95); color: white; padding: 12px 20px; border-radius: 25px; font-weight: 600; font-size: 14px; z-index: 5; box-shadow: 0 4px 15px rgba(0,0,0,0.2); }
.spinner-small { width: 18px; height: 18px; border: 3px solid rgba(255,255,255,0.3); border-top-color: white; border-radius: 50%; animation: spin 0.8s linear infinite; }
.notification { position: fixed; top: -100px; left: 50%; transform: translateX(-50%); background: white; padding: 16px 24px; border-radius: 8px; box-shadow: 0 4px 20px rgba(0,0,0,0.15); display: flex; align-items: center; gap: 12px; z-index: 10000; transition: top 0.3s ease; font-weight: 600; }
.notification.show { top: 20px; }
.notification.success { border-left: 4px solid #4caf50; }
.notification.warning { border-left: 4px solid #ff9800; }
.notification.info { border-left: 4px solid #2196f3; }
.modal-overlay { position: fixed; z-index: 2000; left: 0; top: 0; width: 100%; height: 100%; background-color: rgba(0,0,0,0.9); display: flex; flex-direction: column; align-items: center; justify-content: center; }
.modal-content { margin: 0; display: block; max-width: 90%; max-height: 80vh; }
#modalCaption { text-align: center; color: #ccc; padding: 10px 0; font-size: 16px; margin-top: 10px; }
.modal-close { position: absolute; top: 25px; right: 45px; color: #f1f1f1; font-size: 40px; font-weight: bold; transition: 0.3s; cursor: pointer; }
.modal-close:hover, .modal-close:focus { color: #bbb; text-decoration: none; cursor: pointer; }
.camera-item.skeleton-loading img { opacity: 0; }
.camera-item.skeleton-loading .camera-label { background-color: transparent; }
.camera-item.skeleton-loading .skeleton-box { background-color: #e0e0e0; border-radius: 4px; }
.camera-item.skeleton-loading .skeleton-label { height: 20px; width: 80%; margin: 0 auto; }

/* Added styles from index.html */
#fullscreenModal {
    display: none;
}

.footer-text {
    text-align: center;
    margin-top: 40px;
    font-size: 12px;
    color: #777;
}

.hidden {
    display: none;
}
