/* --- 全域設定 --- */
:root {
    --bg-dark: #0f172a;
    --bg-side: #1e293b;
    --accent: #38bdf8;
    --text-main: #f1f5f9;
    --text-muted: #94a3b8;
    --glass: rgba(255, 255, 255, 0.03);
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --header-height: 75px; /* 定義頁首高度變數 */
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', 'PingFang TC', 'Microsoft JhengHei', sans-serif;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* --- 頁首區塊 --- */
header {
    height: var(--header-height);
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    /* justify-content: space-between;  <-- 修改這裡 */
    padding: 0 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    z-index: 100;
    position: relative; /* 確保 z-index 生效 */
}

/* 新增：手機版漢堡選單按鈕樣式 */
.mobile-menu-btn {
    display: none; /* 預設隱藏，手機版才顯示 */
    flex-direction: column;
    justify-content: space-around;
    width: 30px;
    height: 25px;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0;
    z-index: 101; /* 比側邊欄高 */
    margin-right: 20px;
}

.mobile-menu-btn span {
    width: 100%;
    height: 3px;
    background-color: var(--text-main);
    border-radius: 10px;
    transition: var(--transition);
}

/* 漢堡按鈕變成 X 的動畫效果 */
.mobile-menu-btn.open span:nth-child(1) {
    transform: rotate(45deg) translate(5px, 6px);
}
.mobile-menu-btn.open span:nth-child(2) {
    opacity: 0;
}
.mobile-menu-btn.open span:nth-child(3) {
    transform: rotate(-45deg) translate(5px, -6px);
}


.logo {
    font-size: 1.4rem;
    font-weight: 800;
    background: linear-gradient(to right, #38bdf8, #818cf8);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: 1px;
    /* width: 150px;  <-- 移除固定寬度 */
    text-decoration: none;
    color: inherit;
    display: inline-block;
    margin-right: auto; /* 讓 Logo 靠左，標題靠右 */
}

.page-title {
    text-align: right; /* 標題靠右對齊 */
}

.title-top {
    font-size: 1.2rem;
    font-weight: 600;
    letter-spacing: 3px;
    color: var(--text-main);
}

.title-bottom {
    font-size: 0.85rem;
    color: var(--accent);
    letter-spacing: 5px;
    margin-top: 2px;
}

/* .header-placeholder { width: 150px; } <-- 移除 */

/* --- 主區域佈局 --- */
.main-wrapper {
    display: flex;
    flex: 1;
    overflow: hidden;
    position: relative; /* 為遮罩層定位 */
}

/* 新增：遮罩層樣式 */
.menu-overlay {
    display: none; /* 預設隱藏 */
    position: fixed;
    top: var(--header-height);
    left: 0;
    width: 100%;
    height: calc(100% - var(--header-height));
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 98; /* 在側邊欄之下，內容之上 */
    backdrop-filter: blur(2px);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.menu-overlay.show {
    display: block;
    opacity: 1;
}


/* --- 側邊欄 --- */
aside {
    width: 280px;
    background: var(--bg-side);
    padding: 20px;
    overflow-y: auto;
    border-right: 1px solid rgba(255, 255, 255, 0.05);
    transition: var(--transition); /* 添加過渡效果 */
    z-index: 99; /* 確保在手機版時浮在內容上 */
}

/* 手機版樣式 (螢幕寬度小於 768px) */
@media (max-width: 768px) {
    .mobile-menu-btn {
        display: flex; /* 顯示漢堡按鈕 */
    }

    .page-title {
        display: none; /* 手機版隱藏完整標題，節省空間 */
    }

    aside {
        position: fixed;
        top: var(--header-height);
        left: 0;
        height: calc(100% - var(--header-height));
        transform: translateX(-100%); /* 預設隱藏在左側螢幕外 */
        width: 80%; /* 手機版寬度設為 80% */
        max-width: 300px;
        border-right: 1px solid rgba(255, 255, 255, 0.1);
        box-shadow: 5px 0 15px rgba(0,0,0,0.3);
    }

    /* 選單開啟時的狀態 */
    aside.show {
        transform: translateX(0); /* 滑入螢幕 */
    }

    main {
        padding: 20px; /* 減少手機版內容的內距 */
    }

    .content-card {
        padding: 25px; /* 減少手機版卡片的內距 */
    }
}


.menu-trigger {
    width: 100%;
    padding: 12px 15px;
    background: var(--glass);
    border: 1px solid rgba(255,255,255,0.05);
    border-radius: 12px;
    color: var(--text-main);
    text-align: left;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    font-weight: 600;
    margin-bottom: 5px;
}

.menu-group.active .submenu { max-height: 200px; margin-bottom: 15px; }

.submenu {
    max-height: 0;
    overflow: hidden;
    transition: var(--transition);
    list-style: none;
    padding-left: 10px;
}

.submenu li {
    padding: 8px 15px;
    border-radius: 8px;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 0.9rem;
    transition: 0.2s;
}

.submenu li:hover, .submenu li.active-item {
    color: var(--accent);
    background: rgba(56, 189, 248, 0.1);
}

/* --- 內容與圖片 --- */
main {
    flex: 1;
    padding: 40px;
    overflow-y: auto;
    background: radial-gradient(circle at center, #1e293b 0%, #0f172a 100%);
}

.content-card {
    max-width: 800px;
    margin: 0 auto;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 25px;
    padding: 40px;
    animation: fadeIn 0.5s ease;
}

.preview-container {
    margin-top: 25px;
    border-radius: 15px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.preview-img {
    width: 100%;
    display: block;
}

/* --- 頁尾 --- */
footer {
    height: 65px;
    background: #020617;
    text-align: center;
    padding: 10px;
    font-size: 0.8rem;
    color: var(--text-muted);
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    z-index: 101; /* 確保頁尾在最上層 */
    position: relative;
}

/* Notice style for emphasis */
.notice { color: #c00; font-weight: 800; }

.editor-panel {
    margin-top: 16px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.upload-btn {
    display: inline-block;
    width: fit-content;
    padding: 10px 18px;
    border-radius: 10px;
    border: 1px solid rgba(56, 189, 248, 0.6);
    background: rgba(56, 189, 248, 0.12);
    color: var(--text-main);
    cursor: pointer;
    transition: 0.2s ease;
}

.upload-btn:hover {
    background: rgba(56, 189, 248, 0.2);
}

.editor-file-input {
    display: none;
}

.editor-textarea {
    width: 100%;
    min-height: 140px;
    resize: vertical;
    border-radius: 12px;
    border: 1px solid rgba(148, 163, 184, 0.4);
    background: rgba(15, 23, 42, 0.85);
    color: var(--text-main);
    padding: 12px 14px;
    outline: none;
}

.editor-textarea:focus {
    border-color: var(--accent);
}

.editor-submit-btn {
    width: fit-content;
    padding: 10px 22px;
    border: none;
    border-radius: 10px;
    background: var(--accent);
    color: #082f49;
    font-weight: 700;
    cursor: pointer;
    transition: 0.2s ease;
}

.editor-submit-btn:hover {
    filter: brightness(1.08);
}

.editor-top-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.editor-clear-btn {
    width: fit-content;
    padding: 10px 22px;
    border: 1px solid rgba(148, 163, 184, 0.45);
    border-radius: 10px;
    background: rgba(15, 23, 42, 0.9);
    color: var(--text-main);
    font-weight: 700;
    cursor: pointer;
    transition: 0.2s ease;
}

.editor-clear-btn:hover:not(.hidden) {
    background: rgba(148, 163, 184, 0.2);
}

.server-status {
    color: var(--text-main);
    font-size: 0.95rem;
}

.hidden {
    display: none;
}

.image-preview-container {
    min-height: 100px;
    border-radius: 12px;
    border: 1px dashed rgba(148, 163, 184, 0.5);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.preview-image {
    max-width: 100%;
    max-height: 400px;
    border-radius: 10px;
    object-fit: contain;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}