/* style.css */
:root {
    --sage-primary: #76bfa2;
    --sage-light: #eef7f4;
    --sage-dark: #3d6b59;
    --bg-gray: #f2f4f3;
}

body {
    background-color: var(--bg-gray);
    margin: 0;
    padding: 15px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    display: flex;
    justify-content: center;
}

.app-container {
    width: 100%;
    max-width: 500px; /* 鎖定手機寬度 */
    display: flex;
    flex-direction: column;
    gap: 20px;
    height: calc(100vh - 30px);
}

.card {
    background: white;
    border-radius: 24px;
    box-shadow: 0 8px 24px rgba(118, 191, 162, 0.1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    flex: 1; /* 讓兩個卡片平分高度 */
}

/* --- 清單容器：支援置中對齊 --- */
.list-container {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    /* 預設不置中，方便搜尋結果由上而下排列 */
}

/* 當容器內只有說明框時，啟動置中模式 */
.list-container.centered {
    justify-content: center;
    align-items: center;
    text-align: left; /* 文字維持靠左較好閱讀 */
}

/* --- 注意事項框框樣式 --- */
.instruction-box {
    /* background: var(--sage-light); */
    /* border: 1px dashed var(--sage-primary); */
    max-width: 100%; /* 在手機畫面上留點邊緣 */
    animation: fadeIn 0.5s ease-out;
}

.instruction-box.hide {
    display: none;
}

.info-title {
    color: var(--sage-dark);
    font-weight: 800;
    font-size: 18px;
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.info-list {
    margin: 0;
    padding-left: 0px;
    color: var(--sage-dark);
    font-size: 14px;
    line-height: 1.5;
}

.info-list p {
    margin-bottom: 8px;
    padding-left: 5px;
    border-left: 3px solid var(--sage-primary);
    font-size: 13px;
}

/* 簡單的淡入動畫 */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* 搜尋列：固定在卡片底部 */
.search-bar-wrapper {
    padding: 15px 20px;
    background: white;
    border-top: 1px solid var(--sage-light);
}

#main-search {
    width: calc(100% - 40px); /* u placeholder asshole */
    padding: 12px 20px;
    border-radius: 50px;
    border: 2px solid var(--sage-light);
    outline: none;
    font-size: 16px; /* 防止 iOS 輸入時自動放大 */
    transition: 0.3s;
}

#main-search:focus {
    border-color: var(--sage-primary);
}

/* 按鈕樣式 */
.copy-button {
    margin: 15px 20px;
    background: var(--sage-primary);
    color: white;
    border: none;
    padding: 15px;
    border-radius: 16px;
    font-size: 17px;
    font-weight: bold;
    cursor: pointer;
    transition: transform 0.2s;
}

.copy-button:active {
    transform: scale(0.98);
}

/* 校系項目樣式 */
.dept-item {
    padding: 12px;
    border-radius: 12px;
    margin-bottom: 8px;
    transition: background 0.2s;
    border: 1px solid transparent;
}

.dept-item.light-grey {
    background-color: #b7cac332;
}

.dept-item.dark-grey {
    background-color: #4e5a5624;
}

.dept-item.suggestion_selected {
    background: var(--sage-light);
    color: var(--sage-dark);
}

.dept-item.selected {
    border: 1px solid var(--sage-light);
    background: #fff;
    padding: 15px;
    border-radius: 16px;
    margin-bottom: 12px;
}

.last-year {
    color: grey;
    font-weight: normal;
    font-size: 0.8rem;
}

.above-standards {
    margin-top: 5px;
    margin-bottom: 0;
}

.dept-header-row {
    display: flex;
    /* justify-content: space-between; */
    margin-bottom: 10px;
}

.dept-name-bold {
    font-size: 16px;
    font-weight: 800;
    color: var(--sage-dark);
}

.dept-comparison {
    background: var(--sage-light);
    padding: 10px;
    border-radius: 8px;
    font-size: 11px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    flex-shrink: 0;
    white-space: nowrap;
}

.dept-comparison::-webkit-scrollbar { display: none; }

.data-row {
    display: flex;
    /* justify-content: flex-start; */
}

.data-row .label {
    font-weight: bold;
    color: var(--sage-primary);
    flex-shrink: 0;
}

.highlight-red {
    color: #ab4700;
    font-weight: bold;
}

.value{
    margin-left: 5px;
}

.dept-actions {
    margin-top: 10px;
    display: flex;
    gap: 15px;
    padding-right: 0;
}

.action-btn {
    /* padding-bottom: 0; */
    font-size: 12px;
    color: var(--sage-primary);
    text-decoration: none;
    font-weight: bold;
    background: none;
    border: none;
    padding: 0;
    margin-top: 0;
}

.go-right-mf {
    margin-left: auto;
}

.delete-btn {
    color: #ccc;
    cursor: pointer;
    font-weight: bold;
    padding: 5px;
    margin-left: auto;
}

.data-separator {
    color: #cccccc;
    font-size: 1em;
    font-weight: 300;
    margin: 0 8px;
    display: inline-block;
}

.link {
    color: rgb(122, 139, 131);
    cursor: pointer;
    text-decoration: underline;
}

/* --- GSAT Side-Island Style --- */
/* 側邊觸發標籤 */
.island-trigger {
    position: fixed;
    top: 80%;
    right: 0;
    width: 30px;
    background-color: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(10px); /* 磨砂玻璃感 */
    border: 1px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
    padding: 10px 5px;
    font-size: 15px;
    border-radius: 12px 0 0 12px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    font-weight: bold;
    align-items: center;
    color: black;
}

.trigger-icon { font-size: 18px; writing-mode: horizontal-tb; }
/* --- 極窄智慧島 --- */
.gsat-island {
    position: fixed;
    right: -100px; /* 初始隱藏位置 */
    top: 25%;
    width: 60px;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    border: 1px solid var(--sage-light);
    border-radius: 20px 0 0 20px;
    box-shadow: -5px 0 20px rgba(0,0,0,0.05);
    z-index: 1001;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    padding: 20px 0;
}

.gsat-island.active {
    transform: translateX(-100px);
}

/* 輸入框清單 */
.score-minimal-list {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}

/* 輸入框樣式 */
.score-input {
    width: 70%;
    padding: 10px 5px;
    border: none;
    border-bottom: 2px solid var(--sage-light);
    background: transparent;
    text-align: center;
    font-size: 16px;
    font-weight: bold;
    color: var(--sage-dark);
    outline: none;
    transition: border-color 0.3s;
}

.score-input:focus {
    border-bottom-color: var(--sage-primary);
}

/* 針對 Placeholder 的樣式 */
.score-input::placeholder {
    font-size: 12px;
    color: #ccc;
    font-weight: normal;
}

/* 隱藏數字箭頭 */
.score-input::-webkit-outer-spin-button,
.score-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* 自動存檔小圓點 */
.status-dot {
    width: 6px;
    height: 6px;
    background: var(--sage-primary);
    border-radius: 50%;
    margin: 15px auto 0;
    opacity: 0;
    transition: opacity 0.3s;
}

.mode-toggle-btn {
    width: 80%;
    margin: 0 auto 15px auto;
    display: block;
    padding: 8px;
    background: var(--sage-light, #e8f3ee);
    color: var(--sage-dark, #3d6b59);
    border: 1px solid var(--sage-primary, #76bfa2);
    border-radius: 10px;
    font-size: 12px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s;
}

.mode-toggle-btn:hover {
    background: var(--sage-primary, #76bfa2);
    color: white;
}

/* 讓容器維持原本的垂直排列 */
.score-minimal-list {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}

/* --- Desktop 響應式優化 --- */
@media (min-width: 1024px) {
    
    /* 1. 整體佈局改為雙欄 */
    .app-container {
        display: grid;
        grid-template-columns: 1fr 1fr; /* 左邊搜尋，右邊清單 */
        gap: 30px;
        max-width: 1200px;
        margin: 0 5vh;
        padding: 20px 20px;
        height: 90vh;
    }

    /* 2. 讓右側清單固定（Sticky），滾動左邊時右邊不動 */
    #selected-section {
        position: sticky;
        top: 20px;
        height: calc(100vh - 100px);
        overflow-y: auto;
        background: #fdfdfd;
        border-radius: 24px;
        padding: 20px;
        box-shadow: 0 10px 30px rgba(0,0,0,0.05);
    }

    /* 3. 已選卡片在寬螢幕下稍微縮減 padding */
    .dept-item.selected {
        transition: transform 0.2s, box-shadow 0.2s;
    }

    .dept-item.selected:hover {
        transform: translateY(-2px);
        box-shadow: 0 5px 15px rgba(0,0,0,0.08);
    }


    /* 5. 搜尋結果改為 Grid 網格佈局，增加效率 */
    #search-results {
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
        gap: 15px;
    }

    .info-list p {
        font-size: 18px;
    }

    .dept-comparison {
        font-size: 15px;
    }

    .delete-btn:hover {
        color: #e74c3c;
    }

    .suggestion-section .dept-item:hover  {
        background: var(--sage-light);
        color: var(--sage-dark);
    }

    #left-hand-trigger {
        visibility: hidden;
    }
}

/* 針對超大螢幕 (如 2K 螢幕) 的寬度限制 */
@media (min-width: 1600px) {
    .app-container {
        max-width: 1400px;
    }
}

#left-hand-trigger {
    position: fixed;
    top: 65%;
    left: 0;
    width: 20px; /* 平時很窄 */
    height: 40%;
    z-index: 4000;
    cursor: pointer;
    display: flex;
    align-items: center;
    transition: width 0.3s;
}

.trigger-indicator {
    width: 10px;
    height: 150px;
    background: rgba(76, 175, 80, 0.3); /* 淡淡的綠色線條提示 */
    border-radius: 0 4px 4px 0;
}

.left-handed .island-trigger {
    right: auto;
    left: 0px;
    border-radius: 0 12px 12px 0;
    box-shadow: 4px 0px 15px rgba(0, 0, 0, 0.15);
}

.left-handed #gsat-island{
    right: auto;
    left: -100px;
    border-radius: 0px 20px 20px 0px;
    box-shadow: 4px 0px 15px rgba(0, 0, 0, 0.15);
}

.left-handed #gsat-island.active {
    transform: translateX(100px);
}

.left-handed .go-right-mf {
    margin-left: 0;
}

.left-handed .delete-btn {
    margin-left: 5px;
}