/* ========================================
   全域樣式
   寶可夢 ZA 資訊查詢網站
   ======================================== */

/* --- 基礎設定 --- */
:root {
    --primary-color: #0066cc;
    --secondary-color: #667eea;
    --success-color: #28a745;
    --danger-color: #dc3545;
    --warning-color: #ffc107;
    --info-color: #17a2b8;
    --light-color: #f8f9fa;
    --dark-color: #343a40;
    --text-color: #333;
    --border-color: #dee2e6;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    --shadow-hover: 0 4px 12px rgba(0, 0, 0, 0.15);
}

* {
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    color: var(--text-color);
    line-height: 1.6;
    background-color: #f5f5f5;
}

h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    margin-bottom: 1rem;
}

/* --- Header 樣式 --- */
header {
    background: linear-gradient(135deg, var(--secondary-color) 0%, #764ba2 100%);
    color: white;
    box-shadow: var(--shadow);
}

header h1 {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
}

/* --- 區域卡片樣式 (AreaCard) --- */
.area-card {
    background: white;
    border-radius: 12px;
    box-shadow: var(--shadow);
    padding: 1.5rem;
    margin-bottom: 2rem;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    max-width: 100%;
    overflow-x: auto;
}

.area-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-hover);
}

.area-card__header {
    border-bottom: 2px solid var(--primary-color);
    padding-bottom: 1rem;
    margin-bottom: 1.5rem;
}

.area-card__title {
    font-size: 1.75rem;
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}

.area-card__level {
    color: var(--warning-color);
    font-weight: 600;
    font-size: 1rem;
}

.area-card__description {
    color: #666;
    font-size: 0.95rem;
    margin-top: 0.5rem;
}

/* --- 寶可夢表格樣式 (PokemonTable) --- */
.pokemon-table {
    width: 100%;
    margin-top: 1rem;
    border-collapse: collapse;
    font-size: 16px;
    background: white;
}

.pokemon-table thead {
    background-color: var(--primary-color);
    color: white;
}

.pokemon-table th {
    padding: 12px 8px;
    text-align: center;
    font-weight: 600;
    cursor: pointer;
    user-select: none;
    position: relative;
    transition: background-color 0.2s ease;
}

.pokemon-table th:hover {
    background-color: #0052a3;
}

.pokemon-table th.sortable::after {
    content: " ⇅";
    opacity: 0.5;
    font-size: 0.8em;
}

.pokemon-table th.sort-asc::after {
    content: " ▲";
    opacity: 1;
}

.pokemon-table th.sort-desc::after {
    content: " ▼";
    opacity: 1;
}

.pokemon-table tbody tr {
    border-bottom: 1px solid var(--border-color);
    transition: background-color 0.2s ease;
}

.pokemon-table tbody tr:hover {
    background-color: #f8f9fa;
}

.pokemon-table td {
    padding: 10px 8px;
    text-align: center;
}

.pokemon-table td:first-child {
    text-align: left;
}

/* 寶可夢縮圖 */
.pokemon-thumbnail {
    width: 40px;
    height: 40px;
    vertical-align: middle;
    margin-right: 8px;
}

.pokemon-name {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.pokemon-types {
    display: flex;
    gap: 4px;
    justify-content: center;
    flex-wrap: wrap;
}

.type-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    color: white;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

/* 屬性顏色 */
.type-一般 { background-color: #A8A878; }
.type-火 { background-color: #F08030; }
.type-水 { background-color: #6890F0; }
.type-電 { background-color: #F8D030; color: #333; }
.type-草 { background-color: #78C850; }
.type-冰 { background-color: #98D8D8; }
.type-格鬥 { background-color: #C03028; }
.type-毒 { background-color: #A040A0; }
.type-地面 { background-color: #E0C068; }
.type-飛行 { background-color: #A890F0; }
.type-超能力 { background-color: #F85888; }
.type-蟲 { background-color: #A8B820; }
.type-岩石 { background-color: #B8A038; }
.type-幽靈 { background-color: #705898; }
.type-龍 { background-color: #7038F8; }
.type-惡 { background-color: #705848; }
.type-鋼 { background-color: #B8B8D0; }
.type-妖精 { background-color: #EE99AC; }

/* EV 值高亮 */
.ev-value {
    font-weight: 600;
}

.ev-value.ev-high {
    color: var(--success-color);
}

.ev-value.ev-zero {
    color: #ccc;
}

/* --- 浮動選單樣式 (FloatingMenu) --- */
.floating-menu {
    position: fixed;
    z-index: 1000;
    transition: all 0.3s ease;
}

.floating-menu__button {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--primary-color);
    color: white;
    border: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    cursor: move;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    transition: background-color 0.3s ease, transform 0.2s ease;
}

.floating-menu__button:hover {
    background: #0052a3;
    transform: scale(1.1);
}

.floating-menu__items {
    position: absolute;
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
    padding: 0.5rem;
    min-width: 200px;
    display: none;
    opacity: 0;
    transform: scale(0.9);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.floating-menu__items.show {
    display: block;
    opacity: 1;
    transform: scale(1);
}

.floating-menu__item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 15px;
    border-radius: 8px;
    text-decoration: none;
    color: var(--text-color);
    transition: background-color 0.2s ease;
}

.floating-menu__item:hover {
    background-color: var(--light-color);
}

.floating-menu__item i {
    font-size: 1.2rem;
    color: var(--primary-color);
}

/* --- 回到頂部按鈕 (BackToTop) --- */
#back-to-top {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: var(--primary-color);
    color: white;
    border: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    cursor: pointer;
    z-index: 999;
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    transition: background-color 0.3s ease, transform 0.2s ease;
}

#back-to-top:hover {
    background: #0052a3;
    transform: scale(1.1);
}

#back-to-top.show {
    display: flex;
}

/* 廣告相關樣式已移至 css/ad-switch.css */

/* 主內容區域 - 限制最大寬度避免被廣告遮擋 */
main.container {
    max-width: 1200px;
    padding-left: 15px;
    padding-right: 15px;
}

/* 大螢幕時,為側邊欄廣告預留空間 */
@media (min-width: 1400px) {
    main.container {
        max-width: 1100px;
        margin-right: auto;
        margin-left: auto;
    }
}

/* --- 錯誤訊息樣式 --- */
.error-message {
    padding: 1rem;
    margin: 2rem 0;
    border-radius: 8px;
    background-color: #f8d7da;
    border: 1px solid #f5c6cb;
    color: #721c24;
}

.error-message h4 {
    margin-bottom: 0.5rem;
    color: #721c24;
}

.error-message button {
    margin-top: 0.5rem;
}

/* --- 載入中動畫 --- */
.spinner-border {
    width: 3rem;
    height: 3rem;
}

/* --- 焦點可見性 (無障礙性) --- */
button:focus,
a:focus,
th:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* 隱藏但保留給螢幕閱讀器 */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* --- 其它BOSS寶可夢折疊樣式 --- */
.pokemon-table__separator {
    height: 12px;
    background: linear-gradient(to bottom, transparent, #f0f0f0);
}

.pokemon-table__separator td {
    border: none;
    padding: 0;
}

.pokemon-table__toggle-row {
    background-color: #f9f9f9;
    border-top: 2px solid var(--primary-color);
    border-bottom: 1px solid var(--border-color);
}

.pokemon-table__toggle-row td {
    padding: 0;
}

.pokemon-table__toggle-btn {
    width: 100%;
    padding: 12px 16px;
    background-color: #f9f9f9;
    border: none;
    border-radius: 0;
    font-size: 15px;
    font-weight: 600;
    color: var(--primary-color);
    cursor: pointer;
    text-align: left;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

.pokemon-table__toggle-btn:hover {
    background-color: #f0f0f0;
    color: #0052a3;
}

.pokemon-table__toggle-btn:active {
    background-color: #e8e8e8;
}

.pokemon-table__boss-section {
    border-top: 2px solid var(--primary-color);
}

.pokemon-table__boss-row {
    background-color: #fff3cd !important;
}

.pokemon-table__boss-row:hover {
    background-color: #ffe8a0 !important;
}

/* ========================================
   多語言優化樣式
   ======================================== */

/* 英文版本 - 文字較長 */
html[data-lang="en"] {
    font-size: 14px;
}

html[data-lang="en"] h1,
html[data-lang="en"] h2,
html[data-lang="en"] h3 {
    line-height: 1.3;
}

html[data-lang="en"] .pokemon-table th,
html[data-lang="en"] .pokemon-table td {
    padding: 10px 6px;
    font-size: 0.95rem;
}

html[data-lang="en"] .area-card__title {
    font-size: 1.4rem;
}

html[data-lang="en"] button {
    white-space: nowrap;
    padding: 0.4rem 0.8rem;
}

/* 日文版本 - 字符通常較短 */
html[data-lang="ja"] {
    font-size: 15px;
}

html[data-lang="ja"] .pokemon-table th,
html[data-lang="ja"] .pokemon-table td {
    padding: 11px 7px;
}

html[data-lang="ja"] .area-card__title {
    font-size: 1.6rem;
}

/* 中文版本 - 預設值 */
html[data-lang="zh-TW"],
html[data-lang=""] {
    font-size: 16px;
}

/* 確保在所有語言中浮動選單文字不會超出邊界 */
html[data-lang="en"] .floating-menu__items {
    min-width: 230px;
}

html[data-lang="ja"] .floating-menu__items {
    min-width: 210px;
}

html[data-lang="zh-TW"] .floating-menu__items,
html[data-lang=""] .floating-menu__items {
    min-width: 220px;
}

/* 按鈕在不同語言中的適應 */
html[data-lang="en"] .btn {
    padding: 0.45rem 0.85rem;
}

html[data-lang="ja"] .btn {
    padding: 0.5rem 0.75rem;
}

html[data-lang="zh-TW"] .btn,
html[data-lang=""] .btn {
    padding: 0.5rem 0.8rem;
}

/* ========================================
   區域摘要表樣式 (AreaSummaryTable)
   ======================================== */
.area-summary-wrapper {
    background: white;
    border-radius: 12px;
    box-shadow: var(--shadow);
    padding: 0;
    margin-bottom: 2rem;
    margin-top: 3rem;
    overflow: hidden;
}

.area-summary-title {
    background-color: var(--light-color);
    border-bottom: 2px solid var(--primary-color);
    color: var(--primary-color);
    font-size: 1.5rem;
    margin: 0;
    padding: 1rem 1.5rem;
    font-weight: 600;
}

.area-summary-table-container {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
    padding: 1.5rem;
}

/* 桌面版 - 2 欄並排 */
@media (min-width: 992px) {
    .area-summary-table-container {
        grid-template-columns: 1fr 1fr;
    }
}

.area-summary-table {
    margin-bottom: 0;
    font-size: 0.9rem;
    table-layout: fixed;
    width: 100%;
    margin: 0;
}

.area-summary-table tbody {
    padding: 1rem;
}

.area-summary-table thead {
    background-color: var(--primary-color) !important;
    color: white !important;
}

.area-summary-table thead th {
    padding: 0.5rem;
    font-size: 0.85rem;
    font-weight: 600;
    word-wrap: break-word;
    color: white !important;
    background-color: var(--primary-color) !important;
}

.area-summary-table tbody td {
    padding: 0.5rem;
    vertical-align: middle;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.area-summary-name {
    width: 15%;
    font-weight: bold;
    white-space: normal;
}

.area-summary-desc {
    width: 30%;
    font-size: 0.85rem;
    white-space: normal;
    line-height: 1.4;
}

.area-summary-link {
    width: 10%;
    text-align: center;
    white-space: nowrap;
}

.area-summary-table .btn-sm {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    height: fit-content;
}

/* 手機裝置適應 - 每個區域單獨成行 */
@media (max-width: 991px) {
    .area-summary-table {
        table-layout: auto;
        border-collapse: collapse;
        width: 100%;
    }
    
    .area-summary-table tbody tr {
        display: table-row;
    }
    
    .area-summary-table tbody td {
        display: table-cell;
        padding: 0.75rem 0.5rem;
        border-bottom: 1px solid var(--border-color);
    }
    
    .area-summary-name {
        width: auto;
        font-weight: bold;
        font-size: 0.9rem;
    }
    
    .area-summary-desc {
        width: auto;
        font-size: 0.85rem;
        line-height: 1.4;
    }
    
    .area-summary-link {
        width: auto;
        text-align: center;
    }
    
    /* 手機版隱藏右欄表頭 */
    .area-summary-table-right thead {
        display: none;
    }
    
    /* 手機版隱藏空行 (isEmpty 標記) */
    .area-summary-table-right tbody tr:last-child {
        display: none;
    }
}

/* ========================================
   卡片標頭樣式修正
   ======================================== */
.card-header {
    background-color: var(--light-color);
    border-bottom: 2px solid var(--primary-color);
    color: var(--dark-color);
    padding: 1rem 1.25rem;
}

.card-header h3 {
    color: var(--primary-color);
    font-size: 1.5rem;
    margin: 0;
    display: inline;
}

.card-header .text-muted {
    color: #6c757d;
}

