/* =========================================
   1. 基本設定：背景與佈局
   ========================================= */
body {
    font-family: 'Segoe UI', "Microsoft JhengHei", Arial, sans-serif;
    background-color: #333; 
    display: flex;
    justify-content: center;
    align-items: flex-start;
    min-height: 100vh;
    margin: 0;
    padding: 15px; /* 縮小邊距以符合一頁顯示 */
    position: relative;
    overflow-x: hidden;
}

body::before {
    content: "";
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background-image: url('SBC Banner.png'); 
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    opacity: 0.3;
    z-index: -1;
}

.container {
    background: rgba(255, 255, 255, 0.95);
    padding: 20px;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.3);
    width: 98%;
    max-width: 1300px;
    z-index: 1;
}

h1 { text-align: center; color: #2c3e50; margin-bottom: 20px; font-size: 1.6rem; }

/* 左右並排佈局 */
.main-layout {
    display: flex;
    gap: 20px;
    align-items: flex-start;     /* 改成 flex-start，讓頂部對齊 */
    min-height: 40vh;            /* 確保整體有足夠高度 */
}

.summary-section {  /* 左邊看板區域 */
    flex: 4;
    border: 1px solid #ddd;
    background: rgba(255,255,255,0.85);
    border-radius: 12px;
    padding: 15px;
    overflow-y: auto;
    box-shadow: 0 4px 15px rgba(0,0,0,0.08);
    min-height: 78vh;            /* 讓左邊看板有固定最小高度 */
}

.rooms-area {  /* 右邊房間列表區域 */
    flex: 6;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

/* 讓樓層標題同內容更整齊 */
.floor-title {
    background: #34495e; 
    color: white; 
    padding: 10px 16px; 
    border-radius: 8px; 
    margin: 0 0 12px 0; 
    font-size: 1.08rem;
    font-weight: 600;
}

/* =========================================
   2. 今日看板項目樣式
   ========================================= */
.summary-item {
    position: relative;
    display: flex;
    align-items: center;
    padding: 12px 85px 12px 10px; /* 右邊留空間給按鈕 */
    border-bottom: 1px solid #f0f0f0;
    background: white;
    margin-bottom: 5px;
    border-radius: 6px;
    transition: 0.2s;
}

.summary-time {
    width: 130px;
    flex-shrink: 0;
    color: #2980b9;
    font-weight: bold;
    font-size: 0.9rem;
}

.summary-room { font-weight: bold; color: #2c3e50; width: 140px; flex-shrink: 0; }
.summary-info { flex: 1; color: #555; font-size: 0.85rem; line-height: 1.4; }

/* 看板按鈕 */
.summary-ops {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    gap: 6px;
}

.edit-btn, .del-btn {
    border: none; border-radius: 4px; width: 28px; height: 28px;
    cursor: pointer; font-weight: bold; display: flex;
    align-items: center; justify-content: center; transition: 0.2s; color: white;
}
.edit-btn { background: #f1c40f; }
.edit-btn:hover { background: #d4ac0d; }
.del-btn { background: #e74c3c; }
.del-btn:hover { background: #c0392b; }

/* =========================================
   3. 房間列表卡片
   ========================================= */
#rooms-dynamic-container
/* 房卡樣式：關鍵在於不要寫死 width */
.room-card {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    
    /* 固定高度 */
    height: 80px; 
    
    /* 自動寬度：根據內容伸展，但設定最小寬度避免太窄 */
    min-width: 140px; 
    width: auto; 
    
    /* 內距：確保左右有足夠空間留白 */
    padding: 15px 25px; 
    
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    cursor: pointer;
    transition: all 0.2s ease;
}

/* 房卡內的文字：強制不換行 */
.room-card h3 {
    margin: 0;
    font-size: 1.1rem;
    white-space: nowrap; /* 這是關鍵：防止文字太長時自動折行 */
    color: #2d3748;
}

.room-card .room-status {
    font-size: 0.85rem;
    margin-top: 8px;
    white-space: nowrap;
}

/* 懸停效果 */
.room-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    border-color: #3182ce;
}

.room-card h3 {
    margin: 0 0 10px 0;
    font-size: 0.9rem;
}

.room-card button {
    background: #3182ce;
    color: white;
    border: none;
    padding: 5px 15px;
    border-radius: 4px;
    cursor: pointer;
}

.close-btn {
    position: absolute;
    top: 12px;
    right: 16px;
    font-size: 26px;
    color: #ef4444;
    cursor: pointer;
    z-index: 10;
    line-height: 1;
    font-weight: bold;
}

.close-btn:hover {
    color: #dc2626;
    transform: scale(1.1);
}
/* =========================================
   5. 總覽表格 (Colspan 優化)
   ========================================= */
.table-responsive { overflow-x: auto; margin-top: 15px; }
table { width: 100%; border-collapse: collapse; background: white; min-width: 1000px; }
table th, table td { border: 1px solid #ddd; padding: 6px; text-align: center; height: 45px; vertical-align: middle; }
.room-name-col { background: #f1f1f1; font-weight: bold; position: sticky; left: 0; z-index: 5; }

.cell-booked { background-color: rgba(0, 0, 0, 0.05) !important; color: #333; font-size: 11px; line-height: 1.4; }
.cell-paused { background-color: rgba(255, 0, 0, 0.08) !important; color: #d00; font-weight: bold; font-size: 12px; }

/* 刪除確認彈窗 */
#delete-confirm-modal { z-index: 3000; }
#delete-confirm-modal button:hover { filter: brightness(0.9); transform: scale(1.02); transition: 0.2s; }

.hidden { display: none !important; }

/* =========================================
   6. 時間格樣式優化
     - 強制每行顯示 5 個，並且保持整齊的外觀
   ========================================= */
/* 時間格容器 */
#time-slots {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;                    /* 格子之間的間距 */
    width: 100%;
    padding: 8px 0;
}
/* 單個時間格 - 強制每行顯示 5 個 */
.time-slot {
    flex: 0 0 calc(20% - 8px);    /* 改成 20% = 每行 5 個 */
    min-width: 105px;             /* 最小寬度 */
    max-width: 120px;             /* 最大寬度（可微調） */
    padding: 12px 8px;
    text-align: center;
    border-radius: 8px;
    font-size: 0.90rem;           /* 字體稍小，避免太擠 */
    cursor: pointer;
    transition: all 0.2s;
    box-sizing: border-box;
    height: 52px;                 /* 固定高度，讓所有格子一樣高 */
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #e2e8f0;
    background: white;
}
/* 已預約格子 - 改為虛線框 + 加強 "已預約" 文字 */
.time-slot.booked {
    background: #fff1f1;                    /* 非常淺的紅色背景 */
    color: #991b1b;
    border: 2px dashed #f87171;             /* 改為紅色虛線框 */
    cursor: help;                           /* 問號游標 */
    position: relative;
    height: 54px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 500;
    overflow: hidden;
    box-shadow: inset 0 0 0 1px #fecaca;    /* 內陰影加強虛線感覺 */
}

/* 在格子中央顯示 "已預約" 文字 */
.time-slot.booked::after {
    content: " - 已預約 -";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 0.86rem;
    color: #aa5252;
    font-weight: bold;
    background: rgba(255, 255, 255, 0.92);
    padding: 3px 14px;
    border-radius: 6px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.12);
    z-index: 3;
    white-space: nowrap;
}

/* 原時間文字變淡並置底 */
.time-slot.booked span {
    opacity: 0.35;
    font-size: 0.79rem;
}

/* 已選擇的時間格 */
.time-slot.selected {
    background: #3498db !important;
    color: #fff !important;
    border-color: #2980b9 !important;
    box-shadow: 0 4px 12px rgba(52, 152, 219, 0.3);
}
/* --- 時間格美化 --- */
.time-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 10px;
    padding: 10px 0;
}
/* 時間格的懸停效果：只有未預約的格子才有懸停效果 */
.time-slot:hover:not(.booked) {
    border-color: #3498db;
    color: #3498db;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.05);
}

/* 當全日暫停時，整個區域變灰且不可點擊 */
.disabled-section {
    opacity: 0.4;
    pointer-events: none;
    filter: grayscale(1);
    background: #f5f5f5;
    border-radius: 8px;
    padding: 10px;
    display: none; /* 如果你想直接「隱瞞」隱藏，用這個 */
}
/* ==================== Modal 內容框統一樣式 ==================== */
.modal-content {
    background: white;
    padding: 30px;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.45);
    border: 1px solid rgba(0,0,0,0.05);
    max-width: 460px;
    width: 92%;
    position: relative;
    overflow: hidden;
    z-index: 100000;
}

/* 如果是 admin-modal 或 change-pass-modal 需要更大寬度，可以再個別調整 */
#admin-modal .modal-content,
#change-pass-modal .modal-content {
    max-width: 480px;
    padding: 35px 30px;
}
.modal-content h2 {
    color: #2c3e50;
    font-size: 1.5rem;
    margin-bottom: 25px;
    border-left: 5px solid #3498db; /* 加入小裝飾線 */
    padding-left: 15px;
}

/* --- 輸入框與選擇框美化 --- */
.form-group label {
    color: #5d6d7e;
    font-size: 0.85rem;
    margin-bottom: 8px;
    letter-spacing: 0.5px;
}

.form-group input[type="text"], 
.form-group input[type="date"], 
.form-group select {
    width: 100%;
    height: 45px;
    background: #f8f9fa; /* 淺灰色底色，睇落高級啲 */
    border: 1.5px solid #e9ecef;
    border-radius: 10px;
    padding: 0 15px;
    transition: all 0.3s ease;
    color: #2c3e50;
    font-weight: 500;
}

/* 聚焦效果：輸入時框框變色並有微微光暈 */
.form-group input:focus, 
.form-group select:focus {
    outline: none;
    border-color: #3498db;
    background: #fff;
    box-shadow: 0 0 0 4px rgba(52, 152, 219, 0.1);
}

/* --- 全日暫停 Banner 美化 --- */
.pause-banner {
    background: #fff5f5;
    border: 1px solid #feb2b2;
    color: #c53030;
    padding: 15px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    font-size: 0.95rem;
    margin-bottom: 20px;
}
.pause-banner input[type="checkbox"] {
    width: 18px;
    height: 18px;
    margin-right: 10px;
    cursor: pointer;
}
/* --- 提交按鈕美化 --- */
.submit-btn {
    background: linear-gradient(135deg, #28a745, #218838); /* 漸變色 */
    color: white;
    padding: 15px;
    border-radius: 12px;
    font-size: 1.1rem;
    letter-spacing: 1px;
    border: none;
    box-shadow: 0 6px 15px rgba(40, 167, 69, 0.2);
    transition: all 0.3s ease;
    margin-top: 25px;
}

.submit-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(40, 167, 69, 0.3);
    filter: brightness(1.1);
}

.submit-btn:active {
    transform: translateY(0);
}
/* --- 查看預約總覽表按鈕美化 --- */
.view-btn {
    background: #34495e; /* 保持深色調，或改用 #3498db 變藍色 */
    color: white;
    border: none;
    padding: 10px 22px;
    border-radius: 50px; /* 使用較大的數值來達成「膠囊形」圓角 */
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1); /* 加入輕微陰影 */
    display: inline-flex;
    align-items: center;
    gap: 8px; /* 預留位置畀圖標 (如果有) */
}

/* 懸停效果：顏色變淺並向上浮動 */
.view-btn:hover {
    background: #2c3e50;
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
}

/* 點擊時的縮放反饋 */
.view-btn:active {
    transform: translateY(0);
}
/* 加大日曆選擇器 */
.large-date-input {
    font-size: 1.1rem;
    padding: 8px 15px;
    border-radius: 25px; /* 圓角化 */
    border: 2px solid #3498db;
    background: #fff;
    cursor: pointer;
    outline: none;
    color: #2c3e50;
    font-weight: bold;
}

/* 詳情彈窗的字體稍微縮細 */
#detail-body strong {
    color: #2c3e50;
    display: inline-block;
    width: 80px;
}
.overview-header h2 {
    font-size: 1.4rem;
    color: #2c3e50;
    display: flex;
    align-items: center;
    gap: 10px;
}

/* 如果你想星期幾嘅顏色同標題唔同，可以用個 span 包住佢 */
.header-weekday {
    color: #7f8c8d;
    font-size: 1.1rem;
    font-weight: normal;
}
/* 即時資訊標籤：用於顯示當前日期、時間或其他即時資訊 */
#live-info span {
    background: rgba(255, 255, 255, 0.6);
    padding: 4px 12px;
    border-radius: 15px;
    font-size: 0.95rem;
    box-shadow: 2px 2px 5px rgba(0,0,0,0.05);
    display: flex;
    align-items: center;
}
/* 用於顯示當前日期、時間或其他即時資訊的標籤 */
.info-tag {
    background: #f8f9fa; /* 淺灰色背景 */
    padding: 4px 12px;
    border-radius: 50px;
    font-size: 0.85rem; /* 稍微縮小字體 */
    color: #555;
    border: 1px solid #e9ecef;
    display: flex;
    align-items: center;
    white-space: nowrap; /* 防止換行 */
}
/* 登入背景圖保留與優化 */
#login-overlay {
    background-image: linear-gradient(rgba(255,255,255,0.8), rgba(255,255,255,0.8)), url('your-background-image.jpg'); /* 替換為你的圖片路徑 */
    background-size: cover;
    background-position: center;
}

/* 總覽表全屏優化：確保一頁睇晒 */
#overview-modal .modal-content {
    width: 98vw !important;
    max-width: 1400px !important;
    height: 95vh;
    display: flex;
    flex-direction: column;
    padding: 15px !important;
}

.table-responsive {
    flex: 1;
    overflow: auto;
    margin-top: 10px;
}

#booking-table {
    font-size: 0.75rem; /* 縮小字體以容納更多欄目 */
    border-spacing: 0;
    width: 100%;
}

#booking-table th, #booking-table td {
    padding: 4px 2px !important; /* 極小化間距 */
    height: 35px;
    text-align: center;
    border: 1px solid #eee;
}

.room-name-col {
    width: 100px;
    font-weight: bold;
    background: #f8f9fa;
    position: sticky;
    left: 0;
    z-index: 10;
}

/* 針對小螢幕自動縮放 */
@media screen and (max-height: 800px) {
    #booking-table { font-size: 0.7rem; }
    .floor-title { margin: 5px 0 !important; }
}
/* 1. 登入背景圖 */
#login-overlay {
    background: linear-gradient(rgba(255,255,255,0.7), rgba(255,255,255,0.7)), 
                url('SBC Banner.png') no-repeat center center;
    background-size: cover;
}

/* 2. 總覽表寬度固定與全屏化 */
#overview-modal .modal-content {
    width: 98vw !important;
    max-width: 1600px !important; /* 加大寬度上限 */
    height: 96vh;
    padding: 10px !important;
}

#booking-table {
    table-layout: fixed; /* 固定寬度，防止內容撐開表格 */
    width: 95%;
    border-collapse: collapse;
    font-size: 0.8rem;
}

#booking-table th, #booking-table td {
    border: 1.2px solid #d1d5db;
    padding: 6px 2px !important;
    word-break: break-all; /* 自動換行以容納更多文字 */
    vertical-align: middle;
}

/* 3. 預約單元格樣式優化 */
.cell-booked {
    background: #ebf8ff !important;
    color: #2c5282;
    border: 1px solid #bee3f8 !important;
    line-height: 1.3;
}

.cell-booked strong { color: #2b6cb0; font-size: 0.85rem; }
.cell-booked small { display: block; color: #4a5568; font-size: 0.75rem; }

#staff-table th, #staff-table td {
    padding: 12px !important;
    font-size: 1rem;
}

/* 5. 導航欄與按鈕優化 */
.logout-btn {
    background: #e53e3e !important; /* 鮮艷的紅色，一看就知可按 */
    color: white !important;
    border-radius: 8px;
    padding: 10px 20px;
    font-weight: bold;
    transition: background 0.2s;
}

.logout-btn:hover { background: #c53030 !important; }
/* 總覽表 Modal 層級 */
#overview-modal {
    z-index: 1000;
}

/* 預約/修改表單 Modal 層級 - 必須比總覽表高 */
#booking-modal {
    z-index: 1100 !important;
}
/* 用戶選單容器 */
.user-menu-container {
    position: relative;
    display: inline-block;
}
/* 下拉選單內容 (預設隱藏) */
.user-dropdown-content {
    display: none;
    position: absolute;
    right: 0;
    background-color: white;
    min-width: 160px;
    box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.1);
    z-index: 3000; /* 確保在所有 Modal 之上 */
    border-radius: 8px;
    overflow: hidden;
    margin-top: 5px;
    border: 1px solid #e2e8f0;
}

/* 下拉選項樣式 */
.user-dropdown-content a {
    color: #4a5568;
    padding: 12px 16px;
    text-decoration: none;
    display: block;
    font-size: 0.95rem;
    transition: background 0.2s;
}

.user-dropdown-content a:hover {
    background-color: #f7fafc;
    color: #2d3748;
}

/* 懸停時顯示選單 */
.user-menu-container:hover .user-dropdown-content {
    display: block;
}
.room-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 15px;
    margin-top: 20px;
}
#room-buttons-container {  /* 房間按鈕容器：使用 Grid 佈局，讓按鈕自動適應並保持整齊 */ 
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 15px;
    padding: 20px 0;
}
/* 房間按鈕樣式：自動適應內容寬度，並保持整齊的外觀 */
.room-btn {
    position: relative;
    padding: 25px 15px;
    background: #c9dff6;
    color: #475e87;
    border: 1px solid #adcbe3;
    border-radius: 12px;
    font-weight: bold;
    cursor: pointer;
    transition: 0.2s;
}
/* 懸停效果：顏色變淺並向上浮動 */
.room-btn:hover {
    background: #b5d1f0;
    transform: translateY(-2px);
}
/* 樓層標籤 */
.floor-tag {
    position: absolute;
    top: 5px;
    left: 8px;
    font-size: 0.7rem;
    background: rgba(255,255,255,0.5);
    padding: 2px 5px;
    border-radius: 4px;
}
/* 舍友資料美化 */
#member-info-section {
    background: #f8fafc;
    padding: 15px;
    border-radius: 10px;
    border: 1px solid #e2e8f0;
    margin: 15px 0;
}

#member-info-section .form-row {
    display: flex;
    gap: 12px;
}

#member-info-section input[type="text"] {
    flex: 2;
    padding: 12px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    font-size: 1rem;
}

#member-info-section select {
    flex: 1;
    padding: 12px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    font-size: 1rem;
    background: white;
}

#time-slots {
    display: flex;
    flex-wrap: wrap;
    gap: 9px;
    width: 100%;
}
.time-slot {
    flex: 0 0 calc(33.33% - 7px);
    min-width: 118px;
    padding: 13px 10px;
    text-align: center;
    border-radius: 9px;
    font-size: 0.93rem;
    height: 54px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
}

/* 如果螢幕太窄（例如手機），改為每行 3 個以免文字重疊 */
@media (max-width: 480px) {
    #time-slots {
        grid-template-columns: repeat(3, 1fr);
    }
}
#overview-container, #booking-table {
    overflow: visible !important;
    max-height: none !important;
}
.close-btn {
    position: absolute;
    top: 12px;
    right: 16px;
    font-size: 28px;
    color: #ef4444;
    cursor: pointer;
    z-index: 10;
    line-height: 1;
    transition: transform 0.2s;
}

.close-btn:hover {
    transform: scale(1.2);
    color: #dc2626;
}
/* ==================== Modal 強制修正規則（放在 CSS 最底部） ==================== */

/* 基礎 Modal 樣式 - 強制可被 JS 控制 */
.modal-overlay,
#change-pass-modal,
#admin-modal,
#booking-modal,
#overview-modal,
#detail-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.85);
    z-index: 9999;
    display: none;                    /* 預設隱藏 */
    align-items: center;
    justify-content: center;
}

/* 當移除 .hidden 時強制顯示 */
.modal-overlay:not(.hidden),
#change-pass-modal:not(.hidden),
#admin-modal:not(.hidden) {
    display: flex !important;
    visibility: visible !important;
    opacity: 1 !important;
}
/* === 手機友好整體設定 === */
html, body {
    margin: 0;
    padding: 0;
    width: 100%;
    min-height: 100vh;
    overflow-x: hidden;           /* 防止橫向滾動 */
    font-size: 16px;              /* 防止手機自動縮小字體 */
    box-sizing: border-box;
}
/* 確保每個重要 Modal 的 z-index 足夠高 */
#change-pass-modal { z-index: 99999 !important; }
#admin-modal       { z-index: 99999 !important; }
#booking-modal     { z-index: 11000 !important; }
#overview-modal    { z-index: 10000 !important; }
#detail-modal      { z-index: 12000 !important; }