/* ===================================================================
   共用樣式 (Common Styles)
   =================================================================== */

body {
    background: linear-gradient(135deg, #74798f 0%, #545868 100%);
    min-height: 100vh;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    padding: 2rem 0;
}

.container {
    max-width: 800px;
    margin: 0 auto;
    background: rgba(185,187,199);
    border-radius: 20px;
    padding: 2rem;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
}

.header {
    text-align: center;
    margin-bottom: 2rem;
}

.header h1 {
    color: #242f3d;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.header p {
    color: #393f3f;
    font-size: 1.1rem;
}

.logo-icon {
    display: inline-block;
    width: 1.5em;
    height: 1.5em;
    background-image: url('../assets/logo.svg');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    margin-right: 0.5rem;
    vertical-align: -0.35em;
}

/* Loading Spinner - 共用 */
.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #333;
    border-top: 4px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 30;   /* 低於控制列(50)，高於 canvas(1) */
    border-radius: 10px;
}

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

/* Notification System - 共用 */
.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    background: white;
    border-radius: 10px;
    padding: 1rem;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    z-index: 1001;
    max-width: 300px;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.notification-success {
    border-left: 4px solid #28a745;
}

.notification-warning {
    border-left: 4px solid #ffdf7e;
}

.notification-error {
    border-left: 4px solid #dc3545;
}

.notification-info {
    border-left: 4px solid #17a2b8;
}

.notification-close {
    background: none;
    border: none;
    color: #999;
    cursor: pointer;
    padding: 0;
    margin-left: auto;
}

/* Connection Status - 共用 */
.connection-status {
    bottom: 20px;
    right: 20px;
    background: #239833;
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-size: 0.8rem;
    z-index: 1000;
    transition: all 0.3s ease;
}

.connection-status.status-loading {
    background: #ffdf7e;
    color: #333;
}

.connection-status.status-error {
    background: #747474;
}

/* Alert - 共用 */
.alert {
    border-radius: 10px;
    border: none;
}

/* Error Message - 共用 */
.error-message {
    color: #dc3545;
    background: rgba(220, 53, 69, 0.1);
    border: 1px solid rgba(220, 53, 69, 0.3);
    border-radius: 8px;
    padding: 1rem;
    margin: 1rem 0;
    text-align: center;
}


/* ===================================================================
   Login 頁面樣式 (Login Page Styles)
   =================================================================== */

body.login-page {
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #cfd1d4;
}

.login-container {
    background: rgb(255, 255, 255);
    border-radius: 20px;
    padding: 3rem;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(10px);
    width: 100%;
    max-width: 400px;
}

.login-header {
    text-align: center;
    margin-bottom: 2rem;
}

.login-header h2 {
    color: #1d2a37;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.login-header p {
    color: #445051;
    margin-bottom: 2rem;
}

.login-container .form-control {
    border-radius: 10px;
    border: 2px solid #c1cfdd;
    padding: 0.75rem 1rem;
    font-size: 1rem;
    transition: all 0.3s ease;
}

.login-container .form-control:focus {
    border-color: #98a1c9;
    box-shadow: 0 0 0 0.2rem rgba(102, 126, 234, 0.25);
}

.login-container .input-group {
    margin-bottom: 1.5rem;
}

.login-container .input-group-text {
    background: #d1dae4;
    border: 2px solid #bcc8d5;
    border-right: none;
    border-radius: 10px 0 0 10px;
}

.login-container .input-group .form-control {
    border-left: none;
    border-radius: 0 10px 10px 0;
}

.login-btn {
    background: #23ac38;
    border: none;
    color: white;
    padding: 0.75rem;
    border-radius: 10px;
    font-weight: 600;
    width: 100%;
    transition: all 0.3s ease;
    margin-bottom: 1rem;
}

.login-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.3);
    color: white;
}

.login-btn:disabled {
    opacity: 0.6;
    transform: none;
    cursor: not-allowed;
}

.password-toggle {
    cursor: pointer;
    color: #6c757d;
    transition: color 0.2s ease;
}

.password-toggle:hover {
    color: #495057;
}

.credentials {
    background: #fff;
    border-radius: 5px;
    padding: 0.5rem;
    margin: 0.5rem 0;
    font-family: monospace;
    border: 1px dashed #1976d2;
}

.login-container .loading-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid transparent;
    border-top: 2px solid white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    display: inline-block;
    margin-right: 0.5rem;
}


/* ===================================================================
   Index 頁面樣式 (Index Page Styles)
   =================================================================== */

.status-overview .status-card {
    background: #d1e1fa;
    border-radius: 10px;
    padding: 1rem;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    border-left: 4px solid #577e93;
}

.status-number {
    font-size: 2rem;
    font-weight: 700;
    color: #243342;
    margin-bottom: 0.5rem;
}

.status-label {
    font-size: 0.9rem;
    color: #1c1f1f;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.camera-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.camera-card {
    background: #fcfafb;
    border-radius: 15px;
    padding: 2rem 1.5rem;
    text-align: center;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
    border: 3px solid transparent;
    cursor: pointer;
    position: relative;
}

.camera-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.15);
}

.camera-card.online {
    border-color: #235e98;
    background: linear-gradient(145deg, #ffffff, #f8fff9);
}

.camera-card.offline {
    border-color: #747474;
    background: linear-gradient(145deg, #ffffff, #fff8f8);
    opacity: 0.7;
    cursor: not-allowed;
}

.camera-card.checking {
    border-color: #ffdf7e;
    background: linear-gradient(145deg, #ffffff, #fffcf5);
}


    

.camera-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    background: linear-gradient(45deg, #424242, #696969);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.camera-card.online .camera-icon {
    background: linear-gradient(45deg, #144779, #235e98);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: pulse 2s infinite;
}

.camera-card.offline .camera-icon {
    color: #747474;
}

.camera-card.checking .camera-icon {
    background: linear-gradient(45deg, #ffcd36, #ffe38e);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: spin 2s linear infinite;
}

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

.camera-title {
    font-size: 1.3rem;
    font-weight: 600;
    margin-bottom: 0.3rem;
    color: #1a252f;
}

.camera-subtitle {
    font-size: 0.9rem;
    color: #484f50;
    margin-bottom: 1rem;
    font-weight: 500;
}

.camera-status {
    font-size: 0.9rem;
    font-weight: 500;
    padding: 0.4rem 1rem;
    border-radius: 20px;
    display: inline-block;
    margin-bottom: 0.5rem;
}

.status-online {
    background: #235e98;
    color: white;
}

.status-offline {
    background: #747474;
    color: white;
}

.status-checking {
    background: #ffdf7e;
    color: #333;
}

.camera-actions {
    margin-top: 0.5rem;
}

/* 編輯按鈕 */
.camera-edit-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(255, 255, 255, 0.9);
    border: 2px solid #6094ae;
    color: #195471;
    width: 35px;
    height: 35px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 10;
    font-size: 0.9rem;
}

.camera-edit-btn:hover {
    background: #6094ae;
    color: white;
    transform: scale(1.1);
}

.camera-card.offline .camera-edit-btn {
    opacity: 0.6;
}

/* 模態框樣式 */
.modal-content {
    border-radius: 15px;
    border: none;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
}

.modal-header {
    border-bottom: 2px solid #e9ecef;
    border-radius: 15px 15px 0 0;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
}

.modal-title {
    font-weight: 600;
    color: #2c3e50;
}

.modal-footer {
    border-top: 2px solid #e9ecef;
    border-radius: 0 0 15px 15px;
}

.btn-logout {
    color: white;
    border-color: #1b5993;
    background-color: #205f9a;
}

.btn-logout:hover {
    background-color: #dc3545;
    border-color: #dc3545;
    color: white;
}

.refresh-btn {
    background: linear-gradient(45deg, #6094ae, #195471);
    border: none;
    color: white;
    padding: 0.8rem 2rem;
    border-radius: 25px;
    font-weight: 600;
    transition: all 0.3s ease;
    display: block;
    margin: 2rem auto 0;
}

.refresh-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.3);
    color: white;
}


/* ===================================================================
   Player 頁面樣式 (Player Page Styles)
   =================================================================== */

body.player-page {
    background: #f8f9fa;
    padding: 1rem;
    margin: 0;
}

.player-container {
    background: white;
    border-radius: 15px;
    padding: 1.5rem;
    max-width: 100%;
    max-height: 100vh;
    width: 100%;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.player-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid #eee;
}

.player-title {
    font-size: 1.3rem;
    font-weight: 600;
    color: #2c3e50;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.close-btn {
    background: #dc3545;
    border: none;
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.close-btn:hover {
    background: #c82333;
    transform: scale(1.1);
}

.video-container {
    width: 100%;
    height: 500px;
    background: #000;
    border-radius: 10px;
    overflow: visible;
    margin-bottom: 0;
    position: relative;
    z-index: 10;
}

.vr-mode-indicator {
    position: absolute;
    top: 10px;
    right: 10px;
    background: linear-gradient(45deg, #ff6b6b, #ee5a24);
    color: white;
    padding: 5px 10px;
    border-radius: 15px;
    font-size: 0.7rem;
    font-weight: 600;
    z-index: 100;
}

#videojs-panorama-player {
    width: 100% !important;
    height: 100% !important;
}

/* Video.js 覆寫樣式 */

/* panorama v5 的三個模式按鈕（一般/Cardboard/VR）全部隱藏 */
.vjs-panorama-canvas-button,
.vjs-panorama-normal-button,
.vjs-panorama-cardboard-button,
.vjs-panorama-vr-button,
.vjs-vr-button,
.vjs-cardboard-button {
    display: none !important;
}

.vjs-loading-spinner {
    display: none !important;
}

.video-js .vjs-loading-spinner,
.video-js.vjs-waiting .vjs-loading-spinner {
    display: none !important;
    opacity: 0 !important;
    visibility: hidden !important;
}

.video-js.vjs-waiting .vjs-big-play-button {
    display: block !important;
}

/* ── panorama 全螢幕修正 ──────────────────────────────────────────
   videojs-panorama 插件會在 video 上疊一個 Three.js <canvas>。
   控制列需要比 canvas 有更高的 z-index，才能在全螢幕被點到。
   注意：canvas 不可設 pointer-events:none，否則拖曳旋轉會失效。
   ---------------------------------------------------------------- */

/* canvas 保持可互動（拖曳旋轉需要），只調低 z-index */
.video-js canvas {
    z-index: 1 !important;
}

/* 控制列在 canvas 上方，點擊優先 */
.video-js .vjs-control-bar {
    z-index: 50 !important;
    pointer-events: auto !important;
}

/* Big Play Button 也需要在 canvas 上方 */
.video-js .vjs-big-play-button {
    z-index: 20 !important;
}

/* 全螢幕時同樣規則 */
.video-js.vjs-fullscreen canvas {
    z-index: 1 !important;
}

.video-js.vjs-fullscreen .vjs-control-bar {
    z-index: 50 !important;
    pointer-events: auto !important;
}


/* ===================================================================
   響應式設計 (Responsive Design)
   =================================================================== */

@media (max-width: 768px) {
    body {
        padding: 1rem 0;
    }
    
    .container {
        margin: 1rem;
        padding: 1rem;
    }
    
    /* Index 響應式 */
    .camera-grid {
        grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
        gap: 1rem;
    }
    
    .camera-card {
        padding: 1.5rem 1rem;
    }
    
    .camera-icon {
        font-size: 2.5rem;
    }
    
    .camera-title {
        font-size: 1.1rem;
    }

    .camera-edit-btn {
        width: 30px;
        height: 30px;
        font-size: 0.8rem;
    }
    
    /* Player 響應式 */
    body.player-page {
        padding: 0.5rem;
    }
    
    .player-container {
        padding: 1rem;
    }

    .player-title {
        font-size: 1rem;
    }
    
    .video-container {
        height: 250px;
    }
    
    /* Notification 響應式 */
    .notification {
        top: 10px;
        right: 10px;
        max-width: calc(100vw - 20px);
    }
}

@media (max-width: 480px) {
    /* Index 響應式 */
    .camera-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .status-overview .row {
        gap: 0.5rem;
    }
    
    .status-card {
        padding: 0.8rem !important;
    }
    
    .status-number {
        font-size: 1.5rem !important;
    }
    
    /* Player 響應式 */
    .video-container {
        height: 200px;
    }
    
    .player-header {
        flex-direction: column;
        gap: 0.5rem;
        align-items: flex-start;
    }

    .player-title {
        font-size: 0.9rem;
        flex-wrap: wrap;
    }

    .close-btn {
        position: absolute;
        top: 1rem;
        right: 1rem;
    }
}