* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: "Chiron GoRound TC", sans-serif;
    background-color: #f4f7f6;
    color: #333333;
    padding-bottom: 30px;
}

.header {
    background-color: #0a2540;
    color: white;
    padding: 25px 15px;
    text-align: center;
    border-bottom: 4px solid #c4a77d;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}

.header h1 {
    font-size: 24px;
    margin-bottom: 5px;
    letter-spacing: 1px;
}

.header p {
    font-size: 13px;
    opacity: 0.8;
}
/* 頂部連結容器 */
.header-links {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
    margin-top: 12px;
}

/* 連結按鈕基本樣式 */
.header-link-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    font-size: 13px;
    font-weight: 600;
    color: #c4a77d; /* 古典金屬色 */
    background-color: rgba(196, 167, 125, 0.1);
    border: 1px solid rgba(196, 167, 125, 0.3);
    border-radius: 20px;
    text-decoration: none;
    transition: all 0.2s ease-in-out;
}

/* Hover 懸停效果 */
.header-link-btn:hover {
    background-color: #c4a77d;
    color: #ffffff;
    border-color: #c4a77d;
    box-shadow: 0 2px 8px rgba(196, 167, 125, 0.3);
    transform: translateY(-1px);
}

/* FontAwesome 圖示微調 */
.header-link-btn i {
    font-size: 12px;
}
.container {
    max-width: 1100px;
    margin: 20px auto;
    padding: 0 15px;
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 20px;
}

.card {
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
    padding: 20px;
    border: 1px solid transparent;
    transition: border-color 0.3s;
}

.card:hover {
    border-color: rgba(196, 167, 125, 0.4);
}

.card h2 {
    font-size: 17px;
    color: #0a2540;
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom: 2px solid #f4f7f6;
    padding-bottom: 10px;
}

.card h2 i {
    color: #c4a77d;
}

.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
    font-size: 14px;
    color: #0a2540;
}

.form-group input {
    width: 100%;
    padding: 12px;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    font-size: 16px;
    /* 防止 iOS 自動放大 */
    transition: border-color 0.3s;
}

.form-group input:focus {
    outline: none;
    border-color: #c4a77d;
}

.btn-submit {
    width: 100%;
    padding: 12px;
    background-color: #28a745;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.1s;
    margin-top: 10px;
}

.btn-submit:hover {
    background-color: #218838;
}

.btn-submit:active {
    transform: scale(0.98);
}

/* 表格與容器設定 */
.table-responsive {
    width: 100%;
    overflow-x: auto;
    overflow-y: visible;
    -webkit-overflow-scrolling: touch;
}

table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    table-layout: auto;
}

th,
td {
    padding: 10px 12px;
    border-bottom: 1px solid #e0e0e0;
    font-size: 14px;
}

th {
    background-color: #f8f9fa;
    color: #0a2540;
}

tbody tr:hover {
    background-color: #f1f8ff;
}

/* 按鈕風格 */
.btn-chart {
    padding: 6px 12px;
    background-color: #17a2b8;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    font-weight: bold;
    transition: background-color 0.2s;
    white-space: nowrap;
}

.btn-chart:hover {
    background-color: #138496;
}

.btn-delete {
    padding: 6px 12px;
    background-color: #e74c3c;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    font-weight: bold;
    margin-left: 5px;
    transition: background-color 0.2s;
}

.btn-delete:hover {
    background-color: #c0392b;
}

.main-right {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.chart-container {
    position: relative;
    height: 260px;
    width: 100%;
}

/* Toast 通知設定 */
#toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: calc(100% - 40px);
}

.toast {
    background: #0a2540;
    color: white;
    padding: 12px 18px;
    border-radius: 8px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 14px;
    border-left: 5px solid #c4a77d;
    animation: slideIn 0.3s ease, fadeOut 0.3s ease 2.7s forwards;
}

.toast.success {
    border-left-color: #28a745;
}

.toast i {
    font-size: 16px;
    color: #28a745;
}
/* 🗂️ 分頁與交易板共用樣式 */
.market-tabs-container {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
    border-bottom: 2px solid var(--border-color, #ccc);
    padding-bottom: 10px;
}

.tab-btn {
    padding: 10px 20px;
    font-weight: bold;
    cursor: pointer;
    border: none;
    background: #e0e0e0;
    color: #333;
    border-radius: 6px;
    transition: 0.2s;
}

.tab-btn.active {
    background: #0a2540;
    color: #ffffff;
}

.tab-content {
    display: none;
}

.tab-content.active-content {
    display: block;
}

/* 🔍 搜尋框容器 */
.table-search-box {
    margin-bottom: 15px;
}

.search-input-wrapper {
    position: relative;
    display: inline-block;
    width: 100%;
    max-width: 300px;
}

.search-input-wrapper i {
    position: absolute;
    left: 10px;
    top: 10px;
    color: #999;
}

.search-input-wrapper input {
    width: 100%;
    padding: 8px 8px 8px 30px;
    border: 1px solid var(--border-color, #ccc);
    border-radius: 4px;
    box-sizing: border-box;
    background: var(--card-bg, #fff);
    color: var(--text-color, #333);
}

/* 🔒 登入提示區塊 */
.trade-login-prompt {
    display: none;
    padding: 15px;
    text-align: center;
    background: #fff3cd;
    border: 1px solid #ffeeba;
    border-radius: 6px;
    margin-bottom: 15px;
}

.trade-login-prompt span {
    color: #856404;
    font-weight: bold;
    font-size: 13px;
}

/* 📝 發布需求表單 */
.trade-input-form {
    display: none;
    background: var(--bg-secondary, #f9f9f9);
    padding: 15px;
    border-radius: 6px;
    margin-bottom: 15px;
    border: 1px solid var(--border-color, #eee);
}

.trade-form-row {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.trade-select, .trade-input {
    padding: 8px;
    border-radius: 4px;
    border: 1px solid var(--border-color, #ccc);
    background: var(--card-bg, #fff);
    color: var(--text-color, #333);
}

.trade-select {
    width: 110px;
}

.trade-input-item {
    flex: 1;
    min-width: 120px;
}

.trade-input-price {
    width: 110px;
}

.trade-input-qty {
    width: 70px;
}

.trade-input-contact {
    flex: 1;
    min-width: 140px;
}

.trade-submit-btn {
    padding: 8px 16px;
    background: #0a2540;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
}

.trade-submit-btn:hover {
    background: #133a5e;
}
@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes fadeOut {
    from {
        opacity: 1;
    }

    to {
        opacity: 0;
        transform: translateY(10px);
    }
}


/* ==========================================================================
   平板與手機響應式設計 (Media Queries)
   ========================================================================== */

/* 1. 當螢幕小於 850px（平板與大手機）*/
@media (max-width: 850px) {
    .container {
        grid-template-columns: 1fr;
        margin: 15px auto;
        padding: 0 12px;
        gap: 15px;
    }

    .header h1 {
        font-size: 22px;
    }
}

/* 2. 當螢幕小於 480px（標準直向手機：表格自動變身獨立卡片）*/
@media (max-width: 480px) {
    body {
        padding-bottom: 20px;
    }

    .card {
        padding: 15px;
    }

    .header {
        padding: 20px 10px;
    }

    .header h1 {
        font-size: 20px;
    }

    .chart-container {
        height: 220px;
    }

    /* 隱藏傳統表格標題 */
    table thead {
        display: none;
    }

    /* 將 tr 變成獨立卡片 */
    table,
    tbody,
    tr,
    td {
        display: block;
        width: 100%;
    }

    tr {
        margin-bottom: 15px;
        border: 1px solid #e0e0e0;
        border-radius: 8px;
        padding: 12px;
        background: white;
        box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
    }

    /* 每一行 td 變成左右分佈並帶自動標籤 */
    td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 8px 0;
        border-bottom: 1px dashed #eee;
        text-align: right;
        font-size: 14px;
    }

    /* 給手機版卡片加上欄位名稱 */
    td:nth-of-type(1)::before {
        content: "物品名稱";
        font-weight: bold;
        color: #777777;
    }

    td:nth-of-type(2)::before {
        content: "最新價格 (兩)";
        font-weight: bold;
        color: #777777;
    }

    td:nth-of-type(3)::before {
        content: "最後更新時間";
        font-weight: bold;
        color: #777777;
    }

    /* 操作行獨立變成滿版按鈕區 */
    td:nth-of-type(4) {
        border-bottom: none;
        display: flex;
        gap: 8px;
        margin-top: 10px;
        padding-top: 8px;
    }

    td:nth-of-type(4)::before {
        content: "";
    }

    /* 手機版按鈕放大更好按 */
    .btn-chart,
    .btn-delete {
        flex: 1;
        padding: 8px !important;
        font-size: 13px !important;
        margin-left: 0 !important;
        text-align: center;
    }

    /* 手機版 Toast 提示置底居中 */
    #toast-container {
        left: 50%;
        right: auto;
        transform: translateX(-50%);
        bottom: 15px;
        width: 90%;
    }

    @keyframes slideIn {
        from {
            transform: translate(-50%, 20px);
            opacity: 0;
        }

        to {
            transform: translate(-50%, 0);
            opacity: 1;
        }
    }
}
/* ==========================================
   1. 全域深色模式色彩反轉邏輯 (CSS Filters)
   ========================================== */
html.dark-mode-active {
    filter: invert(1) hue-rotate(180deg);
    background-color: #121212; 
}

html.dark-mode-active img, 
html.dark-mode-active video, 
html.dark-mode-active iframe,
html.dark-mode-active canvas, 
html.dark-mode-active select,
html.dark-mode-active textarea,
html.dark-mode-active .btn-submit, 
html.dark-mode-active #loginLinkBtn, 
html.dark-mode-active #loginPromptBox, 
html.dark-mode-active .dark-mode-toggle-container, 
html.dark-mode-active .header, 
html.dark-mode-active .no-invert { 
    filter: invert(1) hue-rotate(180deg);
}

html.dark-mode-active .form-group input,
html.dark-mode-active .search-box-container input {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-color: #ffffff !important; 
    color: #000000 !important;            
    border: 1px solid #dddddd !important; 
    box-shadow: none !important;
    opacity: 1 !important; 
}

html.dark-mode-active .form-group input::placeholder,
html.dark-mode-active .search-box-container input::placeholder {
    color: #666666 !important; 
    opacity: 1 !important;     
}

.dark-mode-toggle-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 999999 !important;
}

.dark-mode-toggle {
    background: #ffffff;
    border: 1px solid #ddd;
    padding: 0;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 46px;
    height: 46px;
    border-radius: 50%;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    transition: transform 0.2s ease, background-color 0.3s ease, border-color 0.3s ease;
    
    -webkit-tap-highlight-color: transparent; 
}

.dark-mode-svg {
    display: block;
    color: #222222; 
    transition: transform 0.3s ease, color 0.3s ease;
    
    pointer-events: none; 
}

html.dark-mode-active .dark-mode-toggle {
    background: #222222;
    border-color: #444;
}

html.dark-mode-active .dark-mode-svg {
    color: #ffffff; 
}

.dark-mode-toggle:hover .dark-mode-svg {
    transform: rotate(15deg);
}
.dark-mode-toggle:active {
    transform: scale(0.92);
}
