/* shared-styles.css */

/* 1. 定義亮色與深色模式的顏色變數 */
:root {
    /* 深色模式 (預設) */
    --bg-color: #1a202c;
    --text-color: #e2e8f0;
    --nav-bg: rgba(26, 32, 44, 0.8);
    --nav-border: #4a5568;
    --nav-text: #e2e8f0;
    --nav-text-hover: #ffffff;
    --nav-active-text: #63b3ed;
    --nav-active-border: #63b3ed;
    --card-bg: #2d3748;
    --card-border: #4a5568;
    --card-shadow: rgba(0, 0, 0, 0.2);
    --header-color: #63b3ed;
    --link-color: #63b3ed;
    --link-hover-color: #90cdf4;
    --button-bg: #63b3ed;
    --button-text: #1a202c;
    --button-hover-bg: #90cdf4;
    --dropdown-bg: #2d3748;
    --dropdown-shadow: rgba(0, 0, 0, 0.25);

    /* for index.html */
    --container-bg: #1e1e1e;
    --secondary-header-color: #8ecae6;
    --border-color: #8ecae6;
    --subtle-border-color: #457b9d;
    --interactive-text-color: #8ecae6;
    --interactive-bg-hover: #2a3a4a;
    --active-bg: #8ecae6;
    --active-text: #121212;
    --clear-btn-bg: #d90429;
    --clear-btn-hover-bg: #ef233c;
    --info-panel-bg: #2b3a42;
    --list-item-bg: #2c2c2c;
    --found-monster-text: #80ed99;
    --placeholder-bg: #2c2c2c;
    --placeholder-text: #adb5bd;

    /* for rich.html */
    --rich-card-bg: #2d3748;
    --rich-card-border: #4a5568;
    --rich-card-hover-border: #a0aec0;
    --rich-card-selected-border: #63b3ed;
    --rich-comparison-bg: rgba(26, 32, 44, 0.95);
    --rich-comparison-border: #4a5568;
    --rich-stat-highlight: #68d391;
    --rich-stat-dim: #a0aec0;
    --rich-text-slate-100: #e2e8f0;
    --rich-text-slate-300: #cbd5e0;
    --rich-text-slate-400: #a0aec0;
    --rich-bg-gray-700-50: rgba(74, 85, 104, 0.5);
    --rich-text-blue-300: #63b3ed;

    /* for about.html */
    --about-card-bg: #2d3748;
    --about-card-border: #4a5568;
    --about-header-text: #63b3ed;
    --about-divider: rgba(99, 179, 237, 0.3);
    --about-text-main: #e2e8f0;
    --about-text-secondary: #a0aec0;
    --about-button-bg: #63b3ed;
    --about-button-text: #1a202c;
    --about-button-hover-bg: #90cdf4;
}

.dark-mode {
    /* 亮色模式 */
    --bg-color: #f8f9fa;
    --text-color: #212529;
    --nav-bg: rgba(255, 255, 255, 0.8);
    --nav-border: #dee2e6;
    --nav-text: #495057;
    --nav-text-hover: #000;
    --nav-active-text: #007bff;
    --nav-active-border: #007bff;
    --card-bg: #ffffff;
    --card-border: #e9ecef;
    --card-shadow: rgba(0, 0, 0, 0.05);
    --header-color: #007bff;
    --link-color: #007bff;
    --link-hover-color: #0056b3;
    --button-bg: #007bff;
    --button-text: #fff;
    --button-hover-bg: #0056b3;
    --dropdown-bg: #ffffff;
    --dropdown-shadow: rgba(0, 0, 0, 0.1);

    /* for index.html */
    --container-bg: #ffffff;
    --secondary-header-color: #0056b3;
    --border-color: #007bff;
    --subtle-border-color: #ced4da;
    --interactive-text-color: #007bff;
    --interactive-bg-hover: #e9ecef;
    --active-bg: #007bff;
    --active-text: #ffffff;
    --clear-btn-bg: #dc3545;
    --clear-btn-hover-bg: #c82333;
    --info-panel-bg: #e9ecef;
    --list-item-bg: #f8f9fa;
    --found-monster-text: #28a745;
    --placeholder-bg: #e9ecef;
    --placeholder-text: #6c757d;

    /* for rich.html */
    --rich-card-bg: #ffffff;
    --rich-card-border: #dee2e6;
    --rich-card-hover-border: #007bff;
    --rich-card-selected-border: #007bff;
    --rich-comparison-bg: rgba(255, 255, 255, 0.95);
    --rich-comparison-border: #dee2e6;
    --rich-stat-highlight: #28a745;
    --rich-stat-dim: #6c757d;
    --rich-text-slate-100: #343a40;
    --rich-text-slate-300: #6c757d;
    --rich-text-slate-400: #adb5bd;
    --rich-bg-gray-700-50: rgba(233, 236, 239, 0.5);
    --rich-text-blue-300: #007bff;

    /* for about.html */
    --about-card-bg: #fff;
    --about-card-border: rgba(0,0,0,0.1);
    --about-header-text: #007bff;
    --about-divider: rgba(0, 123, 255, 0.3);
    --about-text-main: #212529;
    --about-text-secondary: #6c757d;
    --about-button-bg: #007bff;
    --about-button-text: #fff;
    --about-button-hover-bg: #0056b3;
}
/* 2. 全域樣式 */
body {
    font-family: 'Noto Sans TC', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    padding-top: 70px;
    transition: background-color 0.3s, color 0.3s;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* 3. 導覽列樣式 */
.top-nav {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    background-color: var(--nav-bg);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--nav-border);
    z-index: 1000;
    transition: background-color 0.3s, border-color 0.3s;
    height: 70px;
}

.nav-container {
    max-width: 800px;
    height: 100%;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 15px;
    position: relative;
}

.nav-logo {
    font-size: 1.5em;
    font-weight: bold;
    color: var(--header-color);
    text-decoration: none;
    transition: color 0.3s;
}

#main-nav-links {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    align-items: center;
    gap: 25px;
}

#main-nav-links > li {
    position: relative;
    padding: 20px 0; /* 增加垂直感應區 */
    margin: -20px 0; /* 抵銷 padding 對佈局的影響 */
}

#main-nav-links li a {
    text-decoration: none;
    color: var(--nav-text);
    font-weight: 500;
    padding-bottom: 5px;
    border-bottom: 2px solid transparent;
    transition: all 0.3s ease;
}

#main-nav-links li a:hover {
    color: var(--nav-text-hover);
}

#main-nav-links li a.active-nav-link {
    color: var(--nav-active-text);
    border-bottom-color: var(--nav-active-border);
    font-weight: bold;
}

/* 4. 下拉式選單樣式 */
.dropdown-toggle::after {
    content: ' ▼';
    font-size: 0.6em;
    display: inline-block;
    margin-left: 4px;
    vertical-align: middle;
}

.dropdown-menu {
    display: none;
    opacity: 0;
    visibility: hidden;
    position: absolute;
    top: 90%; /* 微調位置，使其更靠近主連結 */
    left: 50%;
    transform: translateX(-50%);
    background-color: var(--dropdown-bg);
    list-style: none;
    padding: 8px 0;
    min-width: 160px;
    border-radius: 8px;
    box-shadow: 0 4px 12px var(--dropdown-shadow);
    border: 1px solid var(--nav-border);
    z-index: 1100;
    transition: opacity 0.2s ease-in-out, visibility 0.2s;
}

.dropdown-menu li a {
    display: block;
    padding: 8px 16px;
    white-space: nowrap;
    border-bottom: none;
}

.dropdown-menu li a:hover {
    background-color: var(--interactive-bg-hover);
}

/* 電腦版：滑鼠懸停時顯示選單 */
@media (min-width: 901px) {
    .dropdown:hover .dropdown-menu {
        display: block;
        opacity: 1;
        visibility: visible;
    }
}

/* 手機版：透過 'open' class 控制顯示 */
.dropdown.open .dropdown-menu {
    display: block;
    opacity: 1;
    visibility: visible;
}


/* 5. 主題切換開關樣式 */
#theme-switch-wrapper {
    position: static;
    margin-left: 15px;
}

.theme-switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 26px;
}

.theme-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .4s;
}

.slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .4s;
    background-repeat: no-repeat;
    background-position: center center;
    background-size: 14px 14px;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23f6993f' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3ccircle cx='12' cy='12' r='5'%3e%3c/circle%3e%3cline x1='12' y1='1' x2='12' y2='3'%3e%3c/line%3e%3cline x1='12' y1='21' x2='12' y2='23'%3e%3c/line%3e%3cline x1='4.22' y1='4.22' x2='5.64' y2='5.64'%3e%3c/line%3e%3cline x1='18.36' y1='18.36' x2='19.78' y2='19.78'%3e%3c/line%3e%3cline x1='1' y1='12' x2='3' y2='12'%3e%3c/line%3e%3cline x1='21' y1='12' x2='23' y2='12'%3e%3c/line%3e%3cline x1='4.22' y1='19.78' x2='5.64' y2='18.36'%3e%3c/line%3e%3cline x1='18.36' y1='5.64' x2='19.78' y2='4.22'%3e%3c/line%3e%3c/svg%3e");
}

input:checked + .slider {
    background-color: var(--nav-active-border);
}

input:focus + .slider {
    box-shadow: 0 0 1px var(--nav-active-border);
}

input:checked + .slider:before {
    transform: translateX(24px);
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpath d='M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z'%3e%3c/path%3e%3c/svg%3e");
}

.slider.round { border-radius: 34px; }
.slider.round:before { border-radius: 50%; }

/* 6. 響應式設計 (手機版) */
#hamburger-btn { display: none; }

@media (max-width: 900px) {
    .nav-logo { font-size: 1.2em; }
    
    #theme-switch-wrapper {
        position: absolute;
        right: 70px;
    }

    #hamburger-btn {
        display: flex;
        flex-direction: column;
        justify-content: space-around;
        width: 30px;
        height: 30px;
        background: transparent;
        border: none;
        cursor: pointer;
        padding: 0;
        z-index: 1200;
        position: absolute;
        right: 15px;
    }

    #hamburger-btn span {
        width: 30px;
        height: 3px;
        background-color: var(--text-color);
        border-radius: 5px;
        transition: all 0.3s linear;
        position: relative;
        transform-origin: 1px;
    }

    #main-nav-links {
        position: fixed;
        top: 70px;
        right: 0;
        height: calc(100vh - 70px);
        width: 250px;
        background-color: var(--nav-bg);
        flex-direction: column;
        align-items: flex-start;
        padding: 2rem;
        gap: 1.5rem;
        transform: translateX(100%);
        transition: transform 0.3s ease-in-out;
        border-left: 1px solid var(--nav-border);
    }
    
    #main-nav-links > li {
        padding: 0; /* 移除手機版選單項目的額外 padding */
        margin: 0;
    }

    .top-nav.nav-open #main-nav-links {
        transform: translateX(0);
    }

    .top-nav.nav-open #hamburger-btn span:nth-child(1) {
        transform: rotate(45deg);
    }
    .top-nav.nav-open #hamburger-btn span:nth-child(2) {
        opacity: 0;
        transform: translateX(20px);
    }
    .top-nav.nav-open #hamburger-btn span:nth-child(3) {
        transform: rotate(-45deg);
    }

    /* 手機版下拉選單 */
    .dropdown-menu {
        position: static;
        display: none;
        transform: none;
        box-shadow: none;
        border: none;
        margin-top: 10px;
        padding-left: 15px;
        background-color: transparent;
        min-width: auto;
        opacity: 1; /* 手機版不需淡入淡出 */
        visibility: visible;
    }

    .dropdown.open .dropdown-menu {
        display: block;
    }
}