/* ==========================================================================
   家庭教育服務入口網 - 樣式表 (紅色/粉紅色系 - 完全依據圖示一垂直單欄與對比徽章設計)
   ========================================================================== */

/* 1. CSS 變數定義 (設計系統) */
:root {
    --primary-red: #e11d48;
    --primary-pink: #f43f5e;
    --soft-pink: #ff8fa3;
    --header-title-color: #881337;
    --bg-page: #fff5f7;
    --card-bg: #ffffff;
    --card-border-radius: 24px;
    --card-shadow: 0 16px 40px rgba(225, 29, 72, 0.12);
    
    /* 粉紅/玫瑰紅按鈕色彩 (圖示一特色：主體與左側徽章顏色不同) */
    --btn-main-bg: linear-gradient(135deg, #fb7185 0%, #f43f5e 100%);
    --btn-badge-bg: linear-gradient(135deg, #e11d48 0%, #be123c 100%);
    --btn-alt-bg: linear-gradient(135deg, #ff758f 0%, #fb7185 100%);
    --btn-alt-badge-bg: linear-gradient(135deg, #f43f5e 0%, #e11d48 100%);
    
    --btn-shadow: 0 6px 18px rgba(244, 63, 94, 0.28);
    --btn-hover-shadow: 0 10px 24px rgba(244, 63, 94, 0.45);

    --text-white: #ffffff;
    --font-family: 'Noto Sans TC', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* 2. 基本重置與頁面底色 */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-family);
    background-color: var(--bg-page);
    background-image: radial-gradient(#fecdd3 1.5px, transparent 1.5px);
    background-size: 24px 24px;
    color: #334155;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* 3. 頁首橫幅區塊 (Header) */
.school-header {
    background-color: #ffffff;
    box-shadow: 0 4px 20px rgba(225, 29, 72, 0.06);
    position: relative;
}

.header-container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 16px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* 左側學校 Logo 與校名 */
.school-brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-circle {
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, #ff4d6d, #e11d48);
    color: #ffffff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: 900;
    box-shadow: 0 4px 12px rgba(225, 29, 72, 0.35);
}

.brand-text {
    display: flex;
    flex-direction: column;
}

.school-name-zh {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--header-title-color);
    line-height: 1.2;
}

.school-name-en {
    font-size: 0.75rem;
    color: #94a3b8;
    font-weight: 500;
}

/* 中間大標題 */
.portal-title {
    font-size: 1.65rem;
    font-weight: 900;
    color: var(--header-title-color);
    letter-spacing: 2px;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.04);
}

/* 右側星星裝飾 */
.header-stars {
    display: flex;
    align-items: flex-start;
    gap: 6px;
}

.star {
    font-size: 1.5rem;
}

.star-pink {
    color: #ff85a1;
    transform: rotate(-10deg);
}

.star-rose {
    color: #e11d48;
    font-size: 1.25rem;
    transform: rotate(15deg);
}

/* 頂部斜線裝飾條 */
.stripe-bar {
    height: 12px;
    background: repeating-linear-gradient(
        -45deg,
        #ff85a1,
        #ff85a1 14px,
        #f43f5e 14px,
        #f43f5e 28px
    );
    width: 100%;
}

/* 4. 主要內容容器 (置中垂直卡片，寬度對齊圖示一) */
.main-container {
    flex: 1;
    max-width: 680px; /* 圖示一垂直單欄最佳視口寬度 */
    width: 100%;
    margin: 32px auto;
    padding: 0 16px;
}

/* 主卡片區塊 */
.card-section {
    background-color: var(--card-bg);
    border-radius: var(--card-border-radius);
    box-shadow: var(--card-shadow);
    border: 1px solid rgba(254, 205, 211, 0.8);
    overflow: hidden;
    padding: 24px;
}

/* 依據圖示一頂部標題列 (軟粉紅背景 + 左側黃色圓形放大鏡圖示) */
.card-header-pill {
    background: linear-gradient(135deg, #ff9ebb 0%, #ff758f 100%);
    border-radius: 50px;
    padding: 10px 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    box-shadow: 0 4px 14px rgba(255, 117, 143, 0.35);
    margin-bottom: 24px;
    border: 2px solid #ffffff;
}

.pill-icon-wrap {
    position: absolute;
    left: 8px;
    width: 44px;
    height: 44px;
    background-color: #ffd166; /* 圖示一黃色圓形 */
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #1e293b;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.2);
    border: 2px solid #ffffff;
}

.pill-title {
    color: #ffffff;
    font-size: 1.65rem;
    font-weight: 900;
    letter-spacing: 4px;
    text-shadow: 1px 2px 4px rgba(0, 0, 0, 0.25);
}

/* 搜尋與篩選列 */
.search-filter-section {
    margin-bottom: 20px;
}

.search-box {
    position: relative;
    display: flex;
    align-items: center;
    background: #fff1f2;
    border: 1.5px solid #fecdd3;
    border-radius: 50px;
    padding: 8px 18px;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.04);
    width: 100%;
    transition: all 0.3s ease;
}

.search-box:focus-within {
    background: #ffffff;
    border-color: #f43f5e;
    box-shadow: 0 0 0 3px rgba(244, 63, 94, 0.2);
}

.search-box-icon {
    color: #f43f5e;
    font-size: 1rem;
    margin-right: 10px;
}

.search-box input {
    border: none;
    outline: none;
    background: transparent;
    font-size: 0.95rem;
    color: #334155;
    width: 100%;
    font-family: inherit;
}

.clear-btn {
    border: none;
    background: none;
    color: #94a3b8;
    cursor: pointer;
    padding: 2px 4px;
    font-size: 0.95rem;
}

.clear-btn:hover {
    color: #e11d48;
}

/* 分類 Tab 頁籤 */
.category-tabs {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 12px;
    flex-wrap: wrap;
}

.tab-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border-radius: 20px;
    border: 1px solid #fecdd3;
    background-color: #ffffff;
    color: #9f1239;
    font-size: 0.88rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
}

.tab-btn:hover {
    background-color: #ffe4e6;
    color: #e11d48;
}

.tab-btn.active {
    background: linear-gradient(135deg, #f43f5e 0%, #e11d48 100%);
    color: #ffffff;
    border-color: transparent;
    box-shadow: 0 3px 8px rgba(244, 63, 94, 0.25);
}

/* 5. 單欄垂直堆疊按鈕列表 (Vertical Stack List - 完全符合圖示一) */
.button-stack-container {
    display: flex;
    flex-direction: column;
    gap: 14px; /* 圖示一垂直按鈕之間的間隔 */
}

/* 獨立長條按鈕樣式 (圖示一風格：主體粉紅，左側深色斜切星星區塊) */
.rule-btn {
    display: flex;
    align-items: center;
    border-radius: 16px;
    text-decoration: none;
    color: var(--text-white);
    transition: all 0.22s cubic-bezier(0.25, 0.8, 0.25, 1);
    position: relative;
    overflow: hidden;
    cursor: pointer;
    border: 2px solid rgba(255, 255, 255, 0.7);
    outline: none;
    user-select: none;
    min-height: 64px;
    width: 100%;
    background: var(--btn-main-bg);
    box-shadow: var(--btn-shadow);
}

.rule-btn:hover {
    box-shadow: var(--btn-hover-shadow);
    transform: translateY(-2.5px) scale(1.01);
}

/* 交替微調顏色 variant */
.rule-btn.btn-alt {
    background: var(--btn-alt-bg);
}

/* 圖示一特有：第二個按鈕亮藍色外框 (Blue focus / selection glow) */
.rule-btn.selected-glow,
.rule-btn:focus-visible {
    outline: none;
    border-color: #1d4ed8 !important;
    box-shadow: 0 0 0 4px #3b82f6, 0 8px 24px rgba(59, 130, 246, 0.4) !important;
    z-index: 5;
}

/* 左側斜切徽章 (區塊顏色與右側主體不同！色階較深呈對比) */
.btn-star-badge {
    width: 62px;
    height: 100%;
    min-height: 64px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--btn-badge-bg);
    clip-path: polygon(0 0, 100% 0, 68% 100%, 0 100%);
    flex-shrink: 0;
    padding-right: 12px;
    transition: background 0.2s ease;
}

.rule-btn.btn-alt .btn-star-badge {
    background: var(--btn-alt-badge-bg);
}

/* 星星圖示 (圖示一白色實心星★) */
.btn-icon-star {
    font-size: 1.6rem;
    color: #ffffff;
    filter: drop-shadow(1px 2px 3px rgba(0, 0, 0, 0.3));
    transform: translateX(-3px);
}

/* 按鈕文字：置中呈現圖示一標準字型 (大字體) */
.btn-label {
    flex: 1;
    padding: 12px 18px 12px 0px;
    font-size: 1.5rem;
    font-weight: 900;
    line-height: 1.4;
    text-shadow: 1px 2px 5px rgba(0, 0, 0, 0.35);
    letter-spacing: 1.2px;
    word-break: break-word;
    text-align: center;
}

/* 按鈕按下效果 */
.rule-btn:active {
    transform: translateY(-1px) scale(0.99);
}

/* 無搜尋結果提示 */
.no-results-box {
    text-align: center;
    padding: 40px 20px;
    color: #64748b;
}

.no-results-icon {
    font-size: 2.5rem;
    color: #fb7185;
    margin-bottom: 12px;
}

.reset-btn {
    margin-top: 14px;
    padding: 8px 20px;
    background-color: var(--primary-pink);
    color: white;
    border: none;
    border-radius: 20px;
    cursor: pointer;
    font-weight: 700;
}

.reset-btn:hover {
    background-color: var(--primary-red);
}

/* 6. 頁尾 */
.site-footer {
    text-align: center;
    padding: 24px 20px;
    color: #881337;
    font-size: 0.92rem;
    border-top: 1px solid rgba(254, 205, 211, 0.6);
    background-color: rgba(255, 255, 255, 0.75);
    margin-top: auto;
}

.sub-text {
    font-size: 0.82rem;
    color: #9f1239;
    margin-top: 6px;
    opacity: 0.85;
}

/* 7. Toast 提示懸浮窗 */
.toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background-color: #881337;
    color: #ffffff;
    padding: 14px 26px;
    border-radius: 50px;
    box-shadow: 0 10px 30px rgba(136, 19, 55, 0.35);
    display: flex;
    align-items: center;
    gap: 10px;
    opacity: 0;
    visibility: hidden;
    transition: all 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 9999;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
    visibility: visible;
}

.toast-icon {
    font-size: 1.2rem;
}

.toast-text {
    font-size: 0.98rem;
    font-weight: 600;
}

/* 8. Modal 彈窗通用樣式 */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    padding: 20px;
}

.modal-backdrop.active {
    opacity: 1;
    visibility: visible;
}

.modal-container {
    background: #ffffff;
    width: 100%;
    max-width: 600px;
    border-radius: 20px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
    display: flex;
    flex-direction: column;
    max-height: 85vh;
    overflow: hidden;
    transform: scale(0.92);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.modal-container.modal-lg {
    max-width: 720px;
}

.modal-backdrop.active .modal-container {
    transform: scale(1);
}

.modal-header {
    background: linear-gradient(135deg, #fff1f2 0%, #ffe4e6 100%);
    padding: 18px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid #fecdd3;
}

.modal-title-group {
    display: flex;
    align-items: center;
    gap: 12px;
}

.modal-icon-badge {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: linear-gradient(135deg, #f43f5e, #e11d48);
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    box-shadow: 0 4px 10px rgba(225, 29, 72, 0.3);
}

.modal-icon-badge.badge-rose {
    background: linear-gradient(135deg, #fb7185, #f43f5e);
}

.modal-title {
    font-size: 1.25rem;
    font-weight: 800;
    color: #881337;
}

.modal-subtitle {
    font-size: 0.82rem;
    color: #9f1239;
}

.modal-close-btn {
    border: none;
    background: transparent;
    font-size: 1.4rem;
    color: #9f1239;
    cursor: pointer;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.modal-close-btn:hover {
    background: #fecdd3;
    color: #881337;
}

.modal-body {
    padding: 20px 24px;
    overflow-y: auto;
    flex: 1;
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid #ffe4e6;
    background: #fff1f2;
}

/* AI Chat 對話框樣式 */
.chat-intro {
    background-color: #fff1f2;
    border-left: 4px solid #f43f5e;
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 0.92rem;
    color: #9f1239;
    margin-bottom: 14px;
}

.quick-questions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
}

.quick-q-btn {
    background: #ffffff;
    border: 1px solid #fecdd3;
    color: #be123c;
    padding: 6px 12px;
    border-radius: 16px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.quick-q-btn:hover {
    background: #f43f5e;
    color: #ffffff;
    border-color: #f43f5e;
}

.chat-box {
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-height: 200px;
    max-height: 300px;
    overflow-y: auto;
    padding-right: 6px;
}

.chat-msg {
    display: flex;
    gap: 10px;
    max-width: 85%;
}

.chat-msg.user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.chat-msg.ai {
    align-self: flex-start;
}

.msg-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #f43f5e;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    flex-shrink: 0;
}

.chat-msg.user .msg-avatar {
    background: #0284c7;
}

.msg-bubble {
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 0.93rem;
    line-height: 1.5;
}

.chat-msg.ai .msg-bubble {
    background: #fff1f2;
    color: #881337;
    border: 1px solid #fecdd3;
    border-top-left-radius: 2px;
}

.chat-msg.user .msg-bubble {
    background: #f43f5e;
    color: white;
    border-top-right-radius: 2px;
}

.chat-input-wrap {
    display: flex;
    gap: 10px;
}

.chat-input-wrap input {
    flex: 1;
    padding: 10px 16px;
    border: 1px solid #fecdd3;
    border-radius: 24px;
    outline: none;
    font-family: inherit;
    font-size: 0.95rem;
}

.chat-input-wrap input:focus {
    border-color: #f43f5e;
    box-shadow: 0 0 0 3px rgba(244, 63, 94, 0.2);
}

.send-btn {
    background: linear-gradient(135deg, #f43f5e, #e11d48);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 24px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: opacity 0.2s;
}

.send-btn:hover {
    opacity: 0.9;
}

/* 家長手冊 Modal 樣式 */
.handbook-detail-card {
    background: #fff1f2;
    border-radius: 12px;
    padding: 16px;
    border: 1px solid #fecdd3;
    margin-bottom: 14px;
}

.handbook-detail-card h4 {
    color: #881337;
    font-size: 1.05rem;
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.handbook-detail-card p {
    font-size: 0.92rem;
    color: #9f1239;
    line-height: 1.6;
}

.handbook-highlights h5 {
    color: #be123c;
    font-size: 0.95rem;
    margin-bottom: 8px;
}

.handbook-highlights ul {
    list-style: none;
    padding-left: 0;
}

.handbook-highlights li {
    padding: 6px 0;
    font-size: 0.9rem;
    color: #475569;
    display: flex;
    align-items: center;
    gap: 8px;
    border-bottom: 1px dashed #ffe4e6;
}

.handbook-highlights li i {
    color: #f43f5e;
}

.external-link-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: linear-gradient(135deg, #f43f5e 0%, #e11d48 100%);
    color: white;
    text-decoration: none;
    padding: 10px 20px;
    border-radius: 20px;
    font-weight: 700;
    font-size: 0.92rem;
    box-shadow: 0 4px 12px rgba(244, 63, 94, 0.3);
    transition: transform 0.2s;
}

.external-link-btn:hover {
    transform: translateY(-2px);
}

/* 9. 響應式微調 */
@media (max-width: 640px) {
    .header-container {
        flex-direction: column;
        gap: 10px;
        text-align: center;
    }

    .header-stars {
        display: none;
    }

    .card-section {
        padding: 18px 14px;
    }

    .card-header-pill {
        padding: 8px 14px;
    }

    .pill-icon-wrap {
        width: 36px;
        height: 36px;
        left: 6px;
    }

    .pill-title {
        font-size: 1.35rem;
        letter-spacing: 2px;
    }

    .rule-btn {
        min-height: 58px;
    }

    .btn-label {
        font-size: 1.25rem;
    }

    .btn-star-badge {
        width: 48px;
    }
}
