/* 全局設定 */
*, *::before, *::after { box-sizing: border-box; }

body {
    font-family: 'Segoe UI', sans-serif;
    margin: 0;
    background-color: #f4f4f4;
    color: #333;
}

header {
    background-color: #007bff; 
    color: #fff;
    padding: 20px;
    text-align: center;
    position: relative; /* <--- 確保有這個屬性 */
    overflow: hidden; /* 防止內容溢出 */
}

h1 { margin: 0; font-size: 1.8rem; }
p { margin: 5px 0 0; color: #ccc; }

/* 區塊通用 */
.section {
    max-width: 1000px;
    margin: 20px auto;
    background: #fff;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

/* 上傳區 */
.upload-section { text-align: center; }
.upload-section button {
    padding: 10px 20px;
    background: #333;
    color: #fff;
    border: none;
    cursor: pointer;
}

/* 進度條 */
.progress-wrapper {
    width: 100%;
    background: #ddd;
    height: 20px;
    border-radius: 10px;
    margin-top: 15px;
    overflow: hidden;
}
.progress-bar {
    height: 100%;
    background: #2196F3; 
    width: 0%;
    color: #fff;
    text-align: center;
    font-size: 12px;
    line-height: 20px;
    transition: width 0.2s;
}

/* 工具列 */
.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}
.sort-box a {
    margin: 0 5px;
    text-decoration: none;
    color: #007bff;
}
.sort-box a.active {
    color: #333;
    font-weight: bold;
    text-decoration: underline;
}
.batch-box .btn {
    padding: 5px 10px;
    cursor: pointer;
    border: none;
    border-radius: 3px;
    font-size: 0.9rem;
    margin-left: 5px;
}
.btn-del { background: #d9534f; color: #fff; }
.btn-zip { background: #28a745; color: #fff; }

/* 圖片網格 (三欄布局，約 320px) */
.gallery-grid {
    display: grid;
    grid-template-columns: repeat(3, 320px);
    justify-content: center;
    gap: 20px;
}

/* 手機版 RWD */
@media (max-width: 768px) {
    .gallery-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 480px) {
    .gallery-grid { grid-template-columns: 1fr; }
}

/* 卡片樣式 */
.gallery-item {
    background: #fff;
    border: 4px solid #fff; /* 預設白色邊框 */
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    overflow: hidden;
    transition: border-color 0.3s, box-shadow 0.3s;
}

/* === 狀態樣式 === */
.gallery-item.state-liked {
    border-color: #FFEB3B; /* 黃色邊框 */
    box-shadow: 0 0 10px #FFEB3B;
}
.gallery-item.state-favorited {
    border-color: #F44336; /* 紅色邊框 */
    box-shadow: 0 0 10px #F44336;
}

/* 圖片 */
.img-wrap {
    position: relative;
    height: 200px; 
    background: #eee;
}
.thumbnail {
    width: 100%;
    height: 100%;
    object-fit: contain; 
    cursor: pointer;
}
.file-check {
    position: absolute;
    top: 10px;
    left: 10px;
    transform: scale(1.5);
}

/* 資訊區 */
.info-wrap { padding: 10px; }
.filename {
    font-weight: bold;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.time { font-size: 0.8rem; color: #888; margin-bottom: 5px; }

/* 備註區 */
.note-input {
    width: 100%;
    height: 60px;
    font-size: 0.9rem;
    resize: none;
    margin-bottom: 5px;
    border: 1px solid #ccc;
}
.btn-save-note {
    width: 100%;
    background: #333;
    color: #fff;
    border: none;
    padding: 5px;
    cursor: pointer;
    margin-bottom: 10px;
}

/* 按鈕區 */
.actions {
    display: flex;
    gap: 5px;
}
.actions button, .actions a {
    flex: 1;
    padding: 8px 0;
    text-align: center;
    border: 1px solid #ccc;
    cursor: pointer;
    font-size: 0.9rem;
    text-decoration: none;
    color: #333;
    background: #fff;
}

/* === 按鈕顏色切換 === */
.btn-normal { background: #fff;border-radius: 8px }
.btn-liked { background: #FFEB3B; border-color: #FFC107;border-radius: 8px } 
.btn-favorited { background: #F44336; color: #fff; border-color: #D32F2F;border-radius: 8px } 

/* 修改名稱按鈕 (藍色) - 透過父容器 .actions 提升權重 */
.actions .btn-rename {
    background-color: #2196F3 !important; /* 強制使用藍色，避免被其他樣式覆蓋 */
    color: white;
    border: none;
    padding: 8px 12px; 
    border-radius: 8px;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
    font-size: 14px;
    margin-right: 5px;
}

.actions .btn-rename:hover {
    background-color: #00ffff !important; /* 懸停時變亮藍色 */
}
/* 單檔下載連結 (綠色) - 透過父容器 .actions 提升權重 */
.actions .btn-dl {
    background-color: #4CAF50 !important; /* 強制使用綠色 */
    color: white;
    border: none;
    padding: 8px 12px;
    border-radius: 8px;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
    font-size: 14px;
}

.actions .btn-dl:hover {
    background-color: #00FF00 !important; /* 懸停時變亮綠色 */
}

/* 訊息 */
.message { padding: 10px; text-align: center; margin: 10px auto; max-width: 1000px; }
.success { background: #dff0d8; color: #3c763d; }
.error { background: #f2dede; color: #a94442; }

/* 分頁 */
.pagination { text-align: center; margin: 30px 0; }
.pagination a {
    padding: 8px 12px;
    border: 1px solid #ddd;
    text-decoration: none;
    color: #333;
    margin: 0 2px;
}
.pagination a.current { background: #333; color: #fff; }

/* Footer */
footer { text-align: center; padding: 20px; color: #666; }

/* Lightbox */
.lightbox {
    display: none;
    position: fixed;
    z-index: 9999;
    left: 0; top: 0;
    width: 100%; height: 100%;
    background: rgba(0,0,0,0.9);
}
.lb-content {
    margin: auto;
    display: block;
    width: 80%;
    max-width: 1000px;
    max-height: 80%;
    object-fit: contain;
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
}
.close {
    position: absolute;
    top: 20px; right: 35px;
    color: #fff;
    font-size: 40px;
    cursor: pointer;
}
.lb-nav {
    cursor: pointer;
    position: absolute;
    top: 50%;
    width: auto;
    padding: 16px;
    margin-top: -22px;
    color: white;
    font-weight: bold;
    font-size: 30px;
    transition: 0.3s;
    user-select: none;
}
.lb-nav:hover { background-color: rgba(0,0,0,0.8); }
.prev { left: 0; }
.next { right: 0; }

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0; top: 0;
    width: 100%; height: 100%;
    background: rgba(0,0,0,0.5);
}
.modal-content {
    background: #fff;
    margin: 15% auto;
    padding: 20px;
    border-radius: 5px;
    width: 300px;
    text-align: center;
}
.close-modal { float: right; cursor: pointer; font-size: 20px; }

/* 2. 移除黑框背景，只保留絕對定位 */
.nsfw-link-container {
    position: absolute;
    top: 50%; /* 垂直置中 */
    right: 30px; /* 靠右邊距（請根據您實際的 header padding 微調） */
    transform: translateY(-50%); /* 垂直置中校正 */
    /* 移除 width, height, background, border */
}

/* 3. 設定連結的樣式 */
.nsfw-link-container a {
    color: #fff; /* 連結文字/圖示顏色 */
    font-size: 30px; /* 放大圖示，使其更顯眼 */
    text-decoration: none;
    line-height: 1;
}

.nsfw-link-container a:hover {
    color: #f00; /* 滑鼠懸停時變成紅色 */
}
/* 請在 style.css 中確認這段基礎樣式是否存在 */
.modal {
    display: none; /* 預設隱藏 */
    position: fixed;
    z-index: 100; 
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0,0,0,0.4); 
}

.modal-content {
    background-color: #fefefe;
    margin: 15% auto; 
    padding: 20px;
    border: 1px solid #888;
    width: 90%; 
    border-radius: 8px;
    position: relative;
}
/* Modal 基礎樣式 (確保它們能蓋住頁面) */
.modal {
    display: none; /* 預設隱藏 */
    position: fixed;
    z-index: 100; 
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0,0,0,0.4); /* 半透明黑色背景 */
}

/* Modal 內容區 */
.modal-content {
    background-color: #fefefe;
    margin: 15% auto; /* 距離頂部 15% 且水平置中 */
    padding: 20px;
    border: 1px solid #888;
    width: 80%; 
    max-width: 400px;
    border-radius: 8px;
    text-align: center;
    position: relative;
}

/* 關閉按鈕 */
.close-modal {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}

.close-modal:hover,
.close-modal:focus {
    color: #000;
    text-decoration: none;
    cursor: pointer;
}

/* 輸入框和按鈕樣式 */
#nsfw-password-input,
#verify-password-btn {
    width: calc(100% - 20px);
    padding: 10px;
    margin-top: 10px;
    box-sizing: border-box;
}

#verify-password-btn {
    background-color: #4CAF50;
    color: white;
    border: none;
    cursor: pointer;
    font-size: 16px;
}
/* =============================== */
/* 留言板按鈕樣式與定位 (新增) */
/* =============================== */

/* 容器定位：將按鈕放在 header 內部的左下角 */
.message-board-container {
    position: absolute;
    bottom: 5px; /* 距離底部 5px */
    left: 0px; /* 距離左側 0px */
    z-index: 10;
}

/* 按鈕美化 */
.btn-message-board {
    display: inline-block;
    float: left;
    padding: 8px 15px;
    background-color: #8df2f2; /* 亮藍色背景 */
    color: #333; /* 深灰像黑色文字 */
    text-decoration: none;
    font-weight: bold;
    border-radius: 20px; /* 圓角效果 */
    border: 2px solid #8df2f2;  /* 2px 的亮藍色邊框 */
    transition: background-color 0.3s, transform 0.1s;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.btn-message-board:hover {
    background-color: #58dada; 
    color: #fff;
    transform: translateY(-1px);
}

/* =============================== */
/* 管理員按鈕樣式與定位 (新增) */
/* =============================== */

/* 容器定位：將按鈕放在 header 內部的右下角 */
.admin-container {
    position: absolute;
    bottom: 5px; /* 距離底部 10px */
    right: 0px; /* 距離右側 70px (避開小惡魔按鈕) */
    z-index: 10; 
}

/* 按鈕美化 */
.btn-admin {
    display: inline-block;
    padding: 8px 15px;
    background-color: #f44336; /* 紅色背景 */
    color: #fff; /* 白色文字 */
    text-decoration: none;
    font-weight: bold;
    border-radius: 20px; /* 圓角效果 */
    border: 2px solid #d32f2f;
    transition: background-color 0.3s, transform 0.1s;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.btn-admin:hover {
    color: black; /* 白色文字 */
    background-color: #d32f2f;
    transform: translateY(-1px);
}


/* 手機版 RWD 調整 */
@media (max-width: 600px) {
    .message-board-container {
        position: static; /* 在小螢幕上恢復到靜態流 */
        margin-left: 0 !important;
        margin-top: 10px;
        text-align: center;
        width: 100%;
        order: 1; /* 調整順序，可能需要根據實際 header 佈局調整 */
    }
    .btn-message-board {
        float: left;
        margin-bottom: -15px !important;        
        margin-left: -20px !important;
        padding-left:-20px !important;
    }
}
/* =============================== */
/* 公告區塊樣式 (新增) */
/* =============================== */
.announcement-section {
    border-left: 5px solid #ff9800; /* 左側橘色邊框 */
    background-color: #fff3e0; /* 淺橘色背景 */
    padding: 15px 20px;
}
.announcement-section h2 {
    color: #e65100; /* 深橘色標題 */
    margin-top: 0;
    font-size: 1.2rem;
    border-bottom: 1px dashed #ff9800;
    padding-bottom: 5px;
    margin-bottom: 10px;
}
.announcement-section p {
    margin: 5px 0;
    color: #333;
}
/* --- 公告內容自定義樣式 (用於 [TAG] 替換) --- */
.announcement-red {
    color: #cc0000; /* 紅色 */
    font-weight: bold;
}

.announcement-blue {
    color: #004085; /* 深藍色 */
}

.announcement-deepgreen {
    color: #1B5E20; /* 深綠色 */
}

.announcement-purple {
    color: #673AB7; /* 紫色 */
}

.announcement-earthyellow {
    color: #B8860B; /* 土黃色 */
}

.announcement-large {
    font-size: 1.5em; /* 較大的字體 */
    font-weight: bold;
}

/* 確保公告內的強烈文字 (strong 標籤，例如 [B]) 也是深色 */
.announcement-section strong {
    color: #333; 
}

/* --- 置頂區樣式 (Pinned Section) --- */
.pinned-section h2 {
    color: #007bff;
    border-bottom: 2px solid #007bff;
    padding-bottom: 5px;
    margin-bottom: 15px;
}

.pinned-gallery {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    justify-content: flex-start; /* 靠左排列 */
}

.pinned-item {
    position: relative;
    /* 確保每個置頂圖片都是一個固定大小，例如：300px 寬 */
    width: calc(33.33% - 10px); /* 在 PC 上顯示 3 張 */
    overflow: hidden;
    border: 3px solid #ffaa00; /* 突顯置頂圖片 */
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

.pinned-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.3s;
}

.pinned-item img:hover {
    transform: scale(1.05);
}

.pinned-tag {
    position: absolute;
    top: 0;
    left: 0;
    background: #ffaa00;
    color: white;
    padding: 2px 8px;
    font-weight: bold;
    border-radius: 8px 0 8px 0;
    z-index: 10;
}

/* RWD 調整：在小螢幕上只顯示 1 張 */
@media (max-width: 768px) {
    .pinned-item {
        width: 100%;
    }
}
/* 公告板的通用樣式 (固定背景和邊框) */
.message-board {
    background-color: #f7f7f7; /* 淺灰色背景 */
    border: 1px solid #ddd;
    border-left: 5px solid #007bff; /* 預設藍色邊框 */
    padding: 15px;
    border-radius: 6px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

/* 顏色標籤樣式 (應用於公告內容中的 <span> 標籤) */

/* 1. 紅色 (保留現有或新增) */
.announcement-color-red {
    color: #DC3545; /* 紅色 */
    font-weight: bold;
}

/* 📣 新增顏色 1: 深綠色 (DEEPGREEN) */
.announcement-color-deepgreen {
    color: #1B5E20; /* 深綠色 */
    font-weight: bold;
}

/* 📣 新增顏色 2: 紫色 (PURPLE) */
.announcement-color-purple {
    color: #673AB7; /* 紫色 */
    font-weight: bold;
}

/* 📣 新增顏色 3: 土黃色 (EARTHYELLOW) */
.announcement-color-earthyellow {
    color: #B8860B; /* 暗金色/深土黃色 */
    font-weight: bold;
}
/* 其他常見顏色 */
.message-board-text-red {
    color: #DC3545; /* 紅色 */
}

.message-board-text-blue {
    color: #007bff; /* 藍色 */
}