/* =========================================
   1. 全域變數與基礎設定
   ========================================= */
:root {
  --ocean-dark: #006994;
  --ocean-light: #48CAE4;
  --sand: #FFFDF7;
  --coral: #FF6B6B; 
  --gift-orange: #FF9F1C;
  --eco-green: #2D6A4F;
  --text-main: #2B2D42;
  --text-gray: #6D6E7C;
  --shadow-card: 0 10px 30px rgba(0,0,0,0.06);
}

* { box-sizing: border-box; }

body { 
    margin: 0; 
    font-family: 'Noto Sans TC', sans-serif; 
    background-color: var(--sand); 
    color: var(--text-main); 
}

/* =========================================
   2. 頁首視覺區 (Hero)
   ========================================= */
.biology-hero {
    height: 50vh; 
    min-height: 400px;
    background: linear-gradient(rgba(0,105,148,0.7), rgba(0,0,0,0.4)), url('https://images.unsplash.com/photo-1544078864-16da9446d3e3?q=80&w=2000&auto=format&fit=crop') center/cover;
    display: flex; flex-direction: column; justify-content: center; align-items: center; color: white; text-align: center;
}
.hero-content h1 { font-size: 3rem; margin: 10px 0; text-shadow: 0 4px 15px rgba(0,0,0,0.4); }
.hero-content p { font-size: 1.1rem; line-height: 1.6; opacity: 0.95; text-shadow: 0 2px 5px rgba(0,0,0,0.5); }

/* =========================================
   3. 佈局與標題
   ========================================= */
.main-content { max-width: 1200px; margin: 0 auto; padding: 40px 20px; }
.section-title { font-size: 1.6rem; color: var(--ocean-dark); font-weight: 900; }

/* =========================================
   4. 搜尋列與分類按鈕
   ========================================= */
.filter-section { margin-bottom: 50px; background: white; padding: 30px; border-radius: 20px; box-shadow: var(--shadow-card); }

/* 搜尋框 */
.search-container { max-width: 600px; margin: 0 auto 10px; }
.search-box {
    position: relative; display: flex; align-items: center;
    background: #f8f9fa; border: 2px solid #dee2e6; border-radius: 50px;
    padding: 5px 20px; transition: 0.3s;
}
.search-box:focus-within { border-color: var(--ocean-dark); background: white; box-shadow: 0 4px 12px rgba(0, 105, 148, 0.1); }
.search-box i { color: #adb5bd; margin-right: 10px; }
.search-box input { border: none; background: transparent; width: 100%; padding: 10px 0; font-size: 1rem; outline: none; }
#clear-search { background: none; border: none; color: #ced4da; cursor: pointer; font-size: 1.2rem; }

/* 分類按鈕 */
.tab-buttons { display: flex; gap: 10px; flex-wrap: wrap; }
.tab-btn {
    background: #e9ecef; color: #495057; border: none;
    padding: 10px 18px; border-radius: 4px; font-size: 0.95rem;
    font-weight: 600; cursor: pointer; transition: 0.2s;
}
.tab-btn:hover { background: #dee2e6; }
.tab-btn.active { background: #00406c; color: white; }

/* =========================================
   5. 生物卡片系統 (已整合)
   ========================================= */
.biology-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 25px; }

.bio-card {
    background: white; border-radius: 20px; overflow: hidden;
    box-shadow: var(--shadow-card); transition: all 0.4s ease;
    display: flex; flex-direction: column; 
    position: relative; /* 確保內部絕對定位生效 */
    z-index: 1;
    cursor: pointer !important;
    pointer-events: auto; /* 卡片本身接收點擊 */
}

/* 讓圖片、文字等內部所有東西都不阻擋點擊 */
.bio-card * { 
    pointer-events: none; 
}
.bio-card:hover { transform: translateY(-10px); box-shadow: 0 20px 40px rgba(0,0,0,0.1); }

/* 圖片區塊 */
.bio-img-box { position: relative; height: 200px; overflow: hidden; }
.bio-img-box img { width: 100%; height: 100%; object-fit: cover; transition: transform 0.6s ease; }
.bio-card:hover .bio-img-box img { transform: scale(1.08); }

/* 紅色警告標籤 (左下角) */
.badge-warning {
    position: absolute !important; 
    bottom: 12px !important;    /* 距離底部 */
    left: 12px !important;      /* 距離左側 */
    top: auto !important;       /* 取消 top */
    background: rgba(255, 107, 107, 0.95); color: white; padding: 5px 12px; border-radius: 30px;
    font-size: 0.8rem; font-weight: 800; backdrop-filter: blur(5px);
    box-shadow: 0 4px 10px rgba(0,0,0,0.2); z-index: 10;
}

/* 分類標籤 (右上角保持不變) */
.badge-category {
    position: absolute !important; top: 12px !important; right: 12px !important;
    background: rgba(255, 255, 255, 0.9); color: var(--ocean-dark); padding: 5px 12px; border-radius: 10px;
    font-size: 0.8rem; font-weight: 900; box-shadow: 0 2px 10px rgba(0,0,0,0.1); z-index: 10;
}

/* 卡片文字資訊 */
.bio-info { padding: 25px 20px; display: flex; flex-direction: column; flex-grow: 1; }
.bio-name { font-size: 1.4rem; color: var(--ocean-dark); margin: 0 0 5px 0; font-weight: 900; }
.bio-sciname { font-size: 0.8rem; color: #a1a1aa; margin: 0 0 15px 0; font-style: italic; }
.bio-desc { font-size: 0.95rem; color: var(--text-gray); line-height: 1.6; margin-bottom: 20px; flex-grow: 1; }
.bio-tags { display: flex; gap: 8px; flex-wrap: wrap; margin-top: auto; }
.b-tag { font-size: 0.75rem; background: #f0f7f9; color: var(--ocean-light); padding: 4px 10px; border-radius: 20px; font-weight: 600;}

/* =========================================
   6. 詳細資訊彈窗 (Modal)
   ========================================= */
.bio-modal-overlay {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.65); backdrop-filter: blur(5px);
    z-index: 9999; display: flex; justify-content: center; align-items: center; padding: 20px;
    opacity: 0; visibility: hidden; transition: 0.3s ease;
}
.bio-modal-overlay.show { opacity: 1; visibility: visible; }

.bio-modal-container {
    background: var(--sand); width: 95%; max-width: 850px;
    border-radius: 24px; position: relative; overflow: hidden;
    box-shadow: 0 30px 60px rgba(0,0,0,0.4);
    transform: scale(0.95) translateY(20px); transition: 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}
.bio-modal-overlay.show .bio-modal-container { transform: scale(1) translateY(0); }

.bio-modal-layout { display: flex; flex-direction: column; max-height: 90vh; overflow-y: auto; }
.bio-modal-image { width: 100%; height: 450px; position: relative; flex-shrink: 0; background: #f0f0f0; }
.bio-modal-image img { width: 100%; height: 100%; object-fit: cover; }

/* --- 修正彈窗內的警告標籤 --- */
.modal-warn-badge {
    position: absolute !important; 
    bottom: 25px !important;    /* 距離底部距離 */
    left: 25px !important;      /* ✨ 改為 left，與小卡片一致 */
    right: auto !important;     /* 務必取消原本的 right: 25px */
    
    background: #ff6b6b; 
    color: white;
    padding: 10px 20px;         /* 稍微增加內邊距更顯眼 */
    border-radius: 50px; 
    font-weight: 800; 
    font-size: 1rem; 
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
    z-index: 10;

    /* ✨ 關鍵修正：讓圖示和文字完美垂直對齊 ✨ */
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 8px; /* 圖示與文字的間距 */
    line-height: 1; /* 防止文字行高撐開背景 */
}

/* 確保圖示大小正確 */
.modal-warn-badge i {
    font-size: 1.1rem;
}
.bio-modal-info { padding: 40px 50px; background: white; }
.modal-title { font-size: 2.2rem; color: var(--ocean-dark); margin: 0 0 8px; font-weight: 900; }
.modal-sciname { font-size: 1.1rem; color: #a1a1aa; margin-bottom: 30px; }

/* 表格樣式 */
.tax-row { display: flex; border-bottom: 1px dashed #eee; padding: 12px 0; }
.tax-label { width: 120px; color: var(--text-gray); font-size: 1rem; }
.tax-value { flex: 1; font-weight: 600; color: var(--text-main); font-size: 1rem; }
.modal-divider { width: 100%; height: 4px; background: #f0f7f9; border-radius: 5px; margin: 25px 0; }
.modal-desc-box { line-height: 1.8; color: var(--text-gray); font-size: 1.05rem; }

/* 地點樣式 */
.modal-location-section { margin-bottom: 25px; background: #f0f7f9; padding: 15px 20px; border-radius: 12px; }
.loc-title { font-size: 0.95rem; font-weight: 800; color: var(--ocean-dark); margin-bottom: 10px; display: flex; align-items: center; gap: 8px; }
.loc-pill { background: white; color: var(--ocean-dark); border: 1px solid var(--ocean-light); padding: 4px 12px; border-radius: 50px; font-size: 0.85rem; font-weight: 700; margin-right: 5px; }

.bio-modal-close {
    position: absolute; top: 20px; right: 20px; background: rgba(255,255,255,0.9);
    border: none; border-radius: 50%; width: 45px; height: 45px; font-size: 1.4rem; cursor: pointer; z-index: 20;
}

/* =========================================
   7. 其他組件 (返回按鈕、動畫)
   ========================================= */
.btn-back {
    display: inline-flex; align-items: center; gap: 8px; text-decoration: none;
    background: white; color: var(--ocean-dark); font-weight: 700; padding: 10px 22px;
    border-radius: 50px; box-shadow: 0 4px 15px rgba(0,0,0,0.06); transition: 0.3s;
}
.btn-back:hover { transform: translateX(-5px); background: var(--ocean-dark); color: white; }

@keyframes fadeUp {
    0% { opacity: 0; transform: translateY(20px); }
    100% { opacity: 1; transform: translateY(0); }
}

/* =========================================
   8. 響應式佈局 (RWD)
   ========================================= */
@media (max-width: 768px) {
    .filter-section { padding: 20px 15px; }
    .tab-buttons { justify-content: center; }
    .biology-grid { grid-template-columns: repeat(1, 1fr); gap: 20px; }
    .bio-modal-container { width: 95%; }
    .bio-modal-image { height: 300px; }
    .bio-modal-info { padding: 30px 20px; }
    .modal-title { font-size: 1.8rem; }
}