/* ---
* 變數定義
--- */
:root {

    --primary-color: #95B8A6;    /* 靈竹青 */
    --accent-color-1: #B85042;   /* 血霞紅 */
    --accent-color-2: #6B5B95;   /* 暮紫煙 */
    --highlight-color: #D4AF37;  /* 淡金 */

    --light-bg: #F5F5F5;         /* 曇影灰 */
    --light-text: #333333;
    --light-card-bg: #FFFFFF;

    --dark-bg: #000000;          /* 純黑 */
    --dark-text: #E0E0E0;
    --dark-card-bg: #121212;     /* 深灰 */

    /* 字體 */
    --font-heading: 'Ma Shan Zheng', 'Noto Serif TC', serif;
    --font-body: 'Noto Sans TC', 'Inter', sans-serif;

    /* UI 樣式 */
    --border-radius: 1rem; /* 接近 2xl */
    --box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    --soft-glow-shadow: 0 0 15px rgba(212, 175, 55, 0.5); /* 淡金光暈 */
}

body.dark-mode {
    --light-bg: var(--dark-bg);
    --light-text: var(--dark-text);
    --light-card-bg: var(--dark-card-bg);
}

/* ---
* 切換器
--- */
.theme-switch-wrapper {
    position: absolute;
    top: 1rem;
    right: 1rem;
    z-index: 20;
}

.theme-switch {
    position: relative;
    display: inline-block;
    width: 60px;
    height: 34px;
}

.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: 26px;
    width: 26px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: .4s;
}

input:checked + .slider {
    background-color: var(--primary-color);
}

input:checked + .slider:before {
    transform: translateX(26px);
}

.slider.round {
    border-radius: 34px;
}

.slider.round:before {
    border-radius: 50%;
}

/* ---
* 全局樣式
--- */
html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-body);
    background-color: var(--light-bg);
    color: var(--light-text);
    margin: 0;
    line-height: 1.6;
    transition: background-color 0.3s, color 0.3s;
}

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-heading);
    font-weight: normal;
}

a {
    color: var(--accent-color-1);
    text-decoration: none;
}

/* ---
* Home Page英雄區塊
--- */
.hero {
    background: linear-gradient(to bottom, #d1e6d9 25%, var(--light-bg) 95%);
    color: var(--light-text);
    text-align: center;
    padding: 6rem 1rem 2rem;
    position: relative;
}

body.dark-mode .hero {
    background: linear-gradient(rgba(0,0,0,0.7), rgba(0,0,0,0.7)), url('../images/background.jpg') no-repeat center center/cover;
    color: white;
}

.logo img {
    border-radius: 9999px;
    border: 3px solid var(--primary-color);
    box-shadow: var(--box-shadow);
}

body.dark-mode .logo img {
    background-color: transparent;
    border-color: var(--highlight-color);
    box-shadow: 0 0 20px var(--highlight-color);
}

.hero-content {
    opacity: 0;
    animation: fadeIn 2s forwards;
    animation-delay: 0.5s;
}

@keyframes fadeIn {
    to {
        opacity: 1;
    }
}

.main-title {
    font-size: 4.5rem;
    margin: 0;
    letter-spacing: 0.2rem;
    color: var(--highlight-color);
    text-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

body.dark-mode .main-title {
    text-shadow: 0 0 10px rgba(212, 175, 55, 0.7), 0 0 20px rgba(0,0,0,0.5);
}

.subtitle {
    font-size: 1.8rem;
    margin: 0.5rem 0 2rem;
    font-family: var(--font-heading);
}

.announcement-bar {
    background: var(--primary-color);
    color: white;
    padding: 0.5rem 1rem;
    text-align: center;
}

body.dark-mode .announcement-bar {
    background: var(--dark-card-bg);
    border-bottom: 1px solid var(--highlight-color);
}

.announcement-bar p {
    margin: 0;
    transition: opacity 0.5s ease-in-out;
}

main {
    padding: 2rem 1rem;
    display: flex;
    gap: 2rem;
    align-items: flex-start;
    max-width: 1280px;
    margin: 0 auto;
}

.main-column {
    flex: 1;
    max-width: 800px;
}

.sidebar {
    width: 350px;
    position: sticky;
    top: 2rem;
}

.quick-actions {
    display: flex;
    justify-content: center;
    gap: 1.5rem;
    margin: 4rem 0;
}

.btn,
button.btn {
    display: inline-block;
    font-family: var(--font-body);
    font-size: 1.1rem;
    font-weight: 700;
    background-color: var(--primary-color);
    color: white;
    padding: 0.8rem 2rem;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    transition: transform 0.3s, box-shadow 0.3s, background-color 0.3s, color 0.3s;
    position: relative;
    overflow: hidden;
    border: 2px solid var(--primary-color);
    cursor: pointer;
}

.btn:hover,
button.btn:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
    background-color: transparent;
    color: var(--primary-color);
}

.btn::before,
button.btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: width 0.4s, height 0.4s;
    opacity: 0;
    z-index: -1;
}

.btn:hover::before,
button.btn:hover::before {
    width: 400px;
    height: 400px;
    opacity: 1;
    transform: scale(3);
}

body.dark-mode .btn,
body.dark-mode button.btn {
    border-color: var(--highlight-color);
    background-color: var(--highlight-color);
    color: var(--dark-bg);
}

body.dark-mode .btn:hover,
body.dark-mode button.btn:hover {
    background-color: transparent;
    color: var(--highlight-color);
}


.content-section {
    max-width: 800px;
    margin: 4rem auto;
    padding: 2rem;
    background: var(--light-card-bg);
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    text-align: center;
}

.content-section h2 {
    font-size: 2.5rem;
    color: var(--primary-color);
    font-family: var(--font-body);
}

body.dark-mode .content-section h2 {
    color: var(--dark-text);
}

#introduction {
    font-family: 'Yuji Boku', 'Noto Serif TC', serif;
}

#introduction h2,
#introduction h4 {
    font-family: inherit;
}

#introduction .symbol {
    font-family: 'Noto Sans TC', sans-serif;
    margin-right: 0.5em;
    font-size: 0.9em;
}

.feature-list {
    list-style: none;
    padding-left: 0;
}

.audience-list {
    display: inline-block;
    text-align: left;
    list-style: disc;
    padding-left: 2em;
}

.feature-list li,
.audience-list li {
    margin-bottom: 1.2rem;
}

.main-column > .content-section:first-child,
.sidebar > .content-section:first-child {
    margin-top: 0;
}

#discord-widget-custom {
    text-align: left;
}

#discord-widget-custom .widget-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

#discord-widget-custom h3, #discord-widget-custom h4 {
    margin: 0;
    font-family: var(--font-body);
}

#discord-widget-custom h3 {
    font-size: 1.2rem;
}

#discord-widget-custom h4 {
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--primary-color);
}

body.dark-mode #discord-widget-custom h4 {
    border-color: var(--highlight-color);
}

#discord-widget-custom .widget-list {
    margin-bottom: 1.5rem;
}

#discord-widget-custom ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

#discord-members ul {
    max-height: 300px;
    overflow-y: auto;
    padding-right: 1rem;
}

/* ---
* 暗黑模式滾動條
--- */
/* For Firefox */
body.dark-mode #discord-members ul {
    scrollbar-width: thin;
    scrollbar-color: var(--highlight-color) transparent;
}

/* For WebKit Browsers (Chrome, Safari, Edge) */
body.dark-mode #discord-members ul::-webkit-scrollbar {
    width: 8px;
}

body.dark-mode #discord-members ul::-webkit-scrollbar-track {
    background: transparent;
}

body.dark-mode #discord-members ul::-webkit-scrollbar-thumb {
    background-color: var(--highlight-color);
    border-radius: 4px;
    border: 2px solid var(--dark-card-bg);
}

body.dark-mode #discord-members ul::-webkit-scrollbar-thumb:hover {
    background-color: var(--highlight-color);
}

#discord-widget-custom .channel-item {
    margin-bottom: 0.5rem;
    padding-left: 1.2rem;
    position: relative;
    display: flex;
    align-items: center;
}

#discord-widget-custom .channel-item::before {
    content: '# ';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    color: var(--primary-color);
    font-weight: bold;
}

body.dark-mode #discord-widget-custom .channel-item::before {
    color: var(--highlight-color);
}

#discord-widget-custom .channel-item,
#discord-widget-custom .member-item {
    transition: transform 0.3s, background-color 0.3s;
    border-radius: var(--border-radius);
    padding: 0.25rem 0.5rem;
    position: relative;
}

#discord-widget-custom .channel-item:hover,
#discord-widget-custom .member-item:hover {
    background-color: rgba(0,0,0,0.05);
    transform: translateX(5px);
}

body.dark-mode #discord-widget-custom .channel-item:hover,
body.dark-mode #discord-widget-custom .member-item:hover {
    background-color: rgba(255,255,255,0.05);
}

#discord-widget-custom .member-item {
    display: flex;
    align-items: center;
    margin-bottom: 0.75rem;
    opacity: 0;
    transform: translateY(10px);
}

#discord-widget-custom .member-item.loaded {
    opacity: 1;
    transform: translateY(0);
}

#discord-widget-custom .member-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    margin-right: 1rem;
    position: relative;
    flex-shrink: 0;
}

#discord-widget-custom .member-avatar img {
    width: 100%;
    border-radius: 50%;
}

#discord-widget-custom .status {
    position: absolute;
    bottom: -2px;
    right: -2px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 2px solid var(--light-card-bg);
}

.status[data-status-text]::after {
    content: attr(data-status-text);
    position: absolute;
    bottom: 120%;
    left: 50%;
    transform: translateX(-50%);
    background-color: var(--light-text);
    color: var(--light-bg);
    padding: 0.25rem 0.5rem;
    border-radius: var(--border-radius);
    font-size: 0.8rem;
    white-space: normal;
    min-width: 50px;
    max-width: 80px;
    text-align: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
    pointer-events: none;
    z-index: 10;
    box-sizing: border-box;
}

#discord-widget-custom .member-avatar:hover .status[data-status-text]::after {
    opacity: 1;
    visibility: visible;
}

body.dark-mode .status[data-status-text]::after {
    background-color: var(--dark-text);
    color: var(--dark-bg);
}

body.dark-mode #discord-widget-custom .status {
    border-color: var(--dark-card-bg);
}

#discord-widget-custom .status.online { background-color: #3ba55d; }
#discord-widget-custom .status.idle { background-color: #faa81a; }
#discord-widget-custom .status.dnd { background-color: #ed4245; }

#discord-member-search {
    width: 100%;
    box-sizing: border-box;
    padding: 0.5rem;
    margin-bottom: 1rem;
    border-radius: var(--border-radius);
    border: 1px solid var(--primary-color);
    background-color: var(--light-bg);
    color: var(--light-text);
    font-family: var(--font-body);
}

body.dark-mode #discord-member-search {
    background-color: var(--dark-bg);
    border-color: var(--highlight-color);
    color: var(--dark-text);
}

.widget-actions {
    display: flex;
    justify-content: center;
    gap: 0.75rem;
    margin-top: 1.5rem;
}

.btn-secondary {
    display: inline-block;
    font-family: var(--font-body);
    font-size: 1.1rem;
    font-weight: 700;
    background-color: var(--primary-color);
    color: white;
    padding: 0.8rem 1rem;
    border-radius: var(--border-radius);
    border: 2px solid var(--primary-color);
    transition: background-color 0.3s, color 0.3s, transform 0.3s, box-shadow 0.3s;
    cursor: pointer;
    text-align: center;
}

.btn-secondary:hover {
    background-color: transparent;
    color: var(--primary-color);
    transform: translateY(-5px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
}

body.dark-mode .btn-secondary {
    background-color: var(--highlight-color);
    color: var(--dark-bg);
    border-color: var(--highlight-color);
}

body.dark-mode .btn-secondary:hover {
    background-color: transparent;
    color: var(--highlight-color);
}

/* ---
* 商城
--- */
.product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 2rem;
    margin-top: 2rem;
}

.product-card {
    border: 1px solid var(--primary-color);
    border-radius: var(--border-radius);
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    background: var(--light-bg);
    transition: transform 0.3s, box-shadow 0.3s;
}

.product-card:hover {
    transform: translateY(-10px);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
}

.product-card img {
    max-width: 120px;
    height: auto;
    margin-bottom: 1rem;
}

.product-card h3 {
    font-family: var(--font-body);
    font-size: 1.5rem;
    color: var(--primary-color);
    margin: 0.5rem 0;
}

.product-card .price {
    font-size: 1.8rem;
    font-weight: bold;
    color: var(--highlight-color);
    margin: 0.5rem 0;
}

.product-card p {
    font-size: 0.9rem;
    line-height: 1.5;
    margin-top: 0.5rem;
}

/* ---
* 指令
--- */
.hidden {
    display: none;
}

#command-list.visible {
    display: block;
    animation: unroll 0.5s ease-out forwards;
}

@keyframes unroll {
    from {
        max-height: 0;
        opacity: 0;
    }
    to {
        max-height: 500px; /* Or a sufficiently large value */
        opacity: 1;
    }
}

.scroll-container {
    max-height: 400px;
    overflow-y: auto;
    padding-right: 1rem;
}

.command-card {
    background: var(--light-bg);
    padding: 1.5rem;
    border-radius: var(--border-radius);
    margin-bottom: 1rem;
    border-left: 5px solid var(--primary-color);
}

.command-card h3 {
    margin-top: 0;
    color: var(--accent-color-1);
}

/* --- Forms --- */
.form-control {
    width: 100%;
    padding: 0.8rem;
    margin-bottom: 1.5rem;
    border-radius: 8px;
    border: 1px solid #ccc;
    background-color: var(--light-bg);
    color: var(--light-text);
    font-family: var(--font-body);
    font-size: 1rem;
    box-sizing: border-box;
    transition: background-color 0.3s, color 0.3s, border-color 0.3s;
}

body.dark-mode .form-control {
    background-color: #333;
    border-color: #555;
}

form label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: bold;
    font-size: 1.1rem;
}


/* --- Responsive Design --- */
@media (max-width: 1200px) {
    main {
        flex-direction: column;
        align-items: center;
    }

    .main-column {
        order: 1;
    }

    .sidebar {
        position: static;
        width: 100%;
        max-width: 800px; /* 與 main 寬度一致 */
        order: 2;
    }

    #discord {
        margin-top: 4rem;
    }
}

/* ---
* 頁尾
--- */
footer {
    text-align: center;
    padding: 2rem 1rem;
    margin-top: 4rem;
    border-top: 1px solid var(--primary-color);
    font-size: 0.9rem;
}

body.dark-mode footer {
    border-top-color: var(--dark-card-bg);
}

footer p {
    margin: 0;
}

footer a {
    color: inherit;
    text-decoration: underline;
}

/* ---
* API測試頁面樣式
--- */
.api-test-container {
    display: flex;
    flex-direction: column;
    gap: 2rem;
    max-width: 1200px;
    margin: 0 auto;
}

.api-controls {
    background: var(--light-card-bg);
    padding: 2rem;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.api-controls label {
    font-weight: 600;
    color: var(--light-text);
    margin-bottom: 0.5rem;
}

.api-controls select,
.api-controls input {
    padding: 0.75rem;
    border: 2px solid var(--primary-color);
    border-radius: 0.5rem;
    background: var(--light-bg);
    color: var(--light-text);
    font-family: var(--font-body);
    font-size: 1rem;
    transition: all 0.3s ease;
}

.api-controls select:focus,
.api-controls input:focus {
    outline: none;
    border-color: var(--accent-color-2);
    box-shadow: 0 0 0 3px rgba(107, 91, 149, 0.1);
}

.api-controls .btn {
    margin-top: 1rem;
    padding: 0.75rem 1.5rem;
    background: linear-gradient(135deg, var(--primary-color), var(--accent-color-2));
    color: white;
    border: none;
    border-radius: 0.5rem;
    font-family: var(--font-body);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.api-controls .btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--soft-glow-shadow);
}

.api-results {
    background: var(--light-card-bg);
    padding: 2rem;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
}

.api-status {
    padding: 1rem;
    margin-bottom: 1rem;
    border-radius: 0.5rem;
    font-weight: 600;
    text-align: center;
}

.api-status.success {
    background: rgba(34, 197, 94, 0.1);
    color: #059669;
    border: 1px solid #059669;
}

.api-status.error {
    background: rgba(239, 68, 68, 0.1);
    color: #dc2626;
    border: 1px solid #dc2626;
}

.api-status.loading {
    background: rgba(59, 130, 246, 0.1);
    color: #2563eb;
    border: 1px solid #2563eb;
}

.api-response-display {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 0.5rem;
    padding: 1.5rem;
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
    line-height: 1.5;
    overflow-x: auto;
    max-height: 400px;
    overflow-y: auto;
    color: #212529;
}

body.dark-mode .api-response-display {
    background: #1a1a1a;
    border-color: #333;
    color: #e0e0e0;
}

.api-info {
    background: var(--light-card-bg);
    padding: 2rem;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
}

.api-info h3,
.api-info h4 {
    color: var(--primary-color);
    margin-bottom: 1rem;
}

.api-info ul {
    list-style-type: none;
    padding: 0;
}

.api-info li {
    margin-bottom: 0.75rem;
    padding-left: 1.5rem;
    position: relative;
}

.api-info li::before {
    content: "▶";
    position: absolute;
    left: 0;
    color: var(--primary-color);
}

.api-info code {
    background: rgba(149, 184, 166, 0.1);
    padding: 0.2rem 0.4rem;
    border-radius: 0.25rem;
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
    color: var(--accent-color-2);
}

.api-info pre {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 0.5rem;
    padding: 1rem;
    overflow-x: auto;
    font-family: 'Courier New', monospace;
    font-size: 0.85rem;
    line-height: 1.4;
}

body.dark-mode .api-info pre {
    background: #1a1a1a;
    border-color: #333;
    color: #e0e0e0;
}

/* 響應式設計 */
@media (max-width: 768px) {
    .api-test-container {
        gap: 1rem;
        padding: 0 1rem;
    }
    
    .api-controls,
    .api-results,
    .api-info {
        padding: 1.5rem;
    }
    
    .api-response-display {
        font-size: 0.8rem;
        max-height: 300px;
    }
    
    .api-info pre {
        font-size: 0.75rem;
    }
}

/* API測試區塊載入動畫 */
.api-test-container {
    opacity: 0;
    transform: translateY(20px);
    animation: apiTestFadeIn 0.6s ease forwards;
}

@keyframes apiTestFadeIn {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}