/* Reset/重置 */
* {
    box-sizing: border-box;
}

/* 共同樣式 - Body 和背景 */
body, html {
    font-family: "Microsoft JhengHei", "微軟正黑體", Arial, sans-serif;
    background: url('../images/bg.jpg') no-repeat center center fixed;
    background-size: cover;
    background-position: center top;
    background-repeat: no-repeat;
    background-attachment: fixed;
    margin: 0;
    min-height: 100vh;
    position: relative;
}

/* 背景遮罩層提升可讀性，符合無障礙對比度要求 */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.85);
    z-index: -1;
}

/* 統一容器寬度 */
.container {
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
    padding: 20px;
    background-color: rgba(255, 255, 255, 0.95);
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* 主內容區域 */
main {
    padding: 20px 0;
}

header {
    margin-bottom: 20px;
}

/* 跳過連結（無障礙功能） */
.skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background: #000000;
    color: #ffffff;
    padding: 8px 16px;
    text-decoration: none;
    z-index: 1000;
    font-weight: bold;
}

.skip-link:focus {
    top: 0;
    outline: 3px solid #ffd700;
    outline-offset: 2px;
}

/* 頁面標題樣式 */
.page-title {
    text-align: center;
    margin: 0 auto 30px;
    padding: 20px;
    min-height: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    max-width: 768px;
}

.page-title h1 {
    font-size: 2rem;
    color: #1a1a1a;
    margin: 0;
    font-weight: bold;
}

/* 區塊標題樣式 */
.section-title {
    font-size: 1.8rem;
    color: #2d2d2d;
    margin: 40px 0 20px;
    font-weight: bold;
}

/* 螢幕閱讀器專用樣式 */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* 基本連結樣式 */
a {
    color: #1976d2;
    text-decoration: none;
    transition: color 0.3s ease;
}

a:hover {
    color: #0d47a1;
    text-decoration: underline;
}

a:focus {
    outline: 3px solid #ffd700;
    outline-offset: 2px;
}

/* 基本按鈕樣式 */
input[type="image"] {
    padding: 8px;
    cursor: pointer;
    transition: transform 0.2s ease, opacity 0.2s ease;
    border: 2px solid transparent;
    border-radius: 6px;
}

input[type="image"]:hover {
    transform: scale(1.05);
    opacity: 0.9;
}

input[type="image"]:focus {
    outline: 3px solid #ffd700;
    outline-offset: 2px;
    background-color: rgba(255, 215, 0, 0.2);
    border: 2px solid #ffd700;
}
input[type="image"]:focus-visible {
    outline: 3px solid #ffd700;
    outline-offset: 2px;
    background-color: rgba(255, 215, 0, 0.2);
    border: 2px solid #ffd700;
}

/* 基本表單元素樣式 */
input[type="text"],
select,
textarea {
    padding: 10px 15px;
    font-size: 1rem;
    border: 2px solid #ccc;
    border-radius: 6px;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
    font-family: "Microsoft JhengHei", "微軟正黑體", Arial, sans-serif;
}

input[type="text"]:focus,
select:focus,
textarea:focus {
    outline: 3px solid #ffd700;
    outline-offset: 2px;
    border-color: #4a90e2;
    box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.1);
}
input[type="text"]:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: 3px solid #ffd700;
    outline-offset: 2px;
    border-color: #4a90e2;
    box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.1);
}

label {
    font-size: 1rem;
    color: #1a1a1a;
    font-weight: bold;
    margin-bottom: 8px;
}

/* 基本表格樣式 - 流動排版 */
.grid-section {
    margin: 30px 0;
    width: 100%;
    overflow-x: auto;
    overflow-y: visible;
    -webkit-overflow-scrolling: touch;
}

.grid-section table {
    width: 100%;
    min-width: 100%;
    border-collapse: collapse;
    background-color: #ffffff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    table-layout: auto;
}

.grid-section th,
.grid-section td {
    min-width: 0;
    word-wrap: break-word;
    word-break: break-word;
    overflow-wrap: break-word;
}

.grid-section th {
    background-color: #4a90e2;
    color: #ffffff;
    font-weight: bold;
    padding: 12px;
    text-align: center;
    border: 1px solid #357abd;
}

.grid-section td {
    padding: 12px;
    border: 1px solid #e0e0e0;
    text-align: center;
    font-size: 0.95rem;
    color: #2d2d2d;
}

.grid-section tr:nth-child(even) {
    background-color: #f9f9f9;
}

.grid-section tr:hover {
    background-color: #f0f7ff;
}

/* 分頁樣式 */
.grid-section .pager {
    padding: 15px;
    text-align: center;
    background-color: #f9f9f9;
}

.grid-section .pager a {
    color: #4a90e2;
    text-decoration: none;
    padding: 6px 12px;
    margin: 0 4px;
    border: 1px solid #4a90e2;
    border-radius: 4px;
    transition: all 0.3s ease;
}

.grid-section .pager a:hover {
    background-color: #4a90e2;
    color: #ffffff;
    text-decoration: none;
}

.grid-section .pager a:focus {
    outline: 3px solid #ffd700;
    outline-offset: 2px;
    background-color: rgba(255, 215, 0, 0.2);
}
.grid-section .pager a:focus-visible {
    outline: 3px solid #ffd700;
    outline-offset: 2px;
    background-color: rgba(255, 215, 0, 0.2);
}

.grid-section .pager span {
    padding: 6px 12px;
    margin: 0 4px;
    background-color: #4a90e2;
    color: #ffffff;
    border-radius: 4px;
}

/* 搜尋表單區域 */
.search-section {
    text-align: center;
    margin: 30px 0;
    padding: 20px;
    background-color: rgba(255, 255, 255, 0.8);
    border-radius: 8px;
}

.search-form {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 12px;
}

.search-form label {
    font-size: 1.125em;
    color: #1a1a1a;
    font-weight: bold;
    margin-right: 8px;
}

.search-form input[type="text"] {
    min-width: 0;
    flex: 1 1 auto;
    max-width: 100%;
}

/* 帳號資訊區域 */
.account-info {
    text-align: center;
    margin: 30px 0;
    padding: 20px;
    background-color: rgba(255, 255, 255, 0.8);
    border-radius: 8px;
}

.account-info p {
    font-size: 1rem;
    color: #2d2d2d;
    line-height: 1.6;
    margin-bottom: 20px;
}

.login-buttons {
    display: flex;
    justify-content: center;
    gap: 20px;
    flex-wrap: wrap;
}

.login-buttons a {
    display: inline-block;
    text-decoration: none;
    transition: transform 0.3s ease, opacity 0.3s ease;
}

.login-buttons a:hover {
    transform: translateY(-3px);
    opacity: 0.9;
    text-decoration: none;
}

.login-buttons a:focus {
    outline: 3px solid #ffd700;
    outline-offset: 3px;
    border-radius: 4px;
    text-decoration: none;
    background-color: rgba(255, 215, 0, 0.2);
}
.login-buttons a:focus-visible {
    outline: 3px solid #ffd700;
    outline-offset: 3px;
    border-radius: 4px;
    text-decoration: none;
    background-color: rgba(255, 215, 0, 0.2);
}

.login-buttons img {
    max-width: 100%;
    height: auto;
    display: block;
}

/* Banner 區域 */
.banner {
    text-align: center;
    margin: 30px 0;
}

.banner img {
    max-width: 100%;
    height: auto;
}

/* 尊重動畫偏好 */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* 流動排版 - 針對放大220%的調整（1280px 放大220% ≈ 580px） */
@media (max-width: 580px) {
    .container {
        padding: 12px;
    }

    .page-title {
        padding: 15px 10px;
    }

    .page-title h1 {
        font-size: 1.4rem;
    }

    .section-title {
        font-size: 1.3rem;
    }

    .search-form {
        flex-direction: column;
        align-items: stretch;
    }

    .search-form label {
        margin-bottom: 8px;
        margin-right: 0;
    }

    .search-form input[type="text"] {
        width: 100%;
        max-width: 100%;
    }

    .login-buttons {
        flex-direction: column;
        align-items: center;
    }

    .grid-section {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .grid-section table {
        font-size: 0.85rem;
        display: block;
        overflow-x: auto;
    }

    .grid-section th,
    .grid-section td {
        padding: 8px 6px;
        white-space: normal;
        word-wrap: break-word;
        word-break: break-word;
    }
}

/* 響應式設計 - 平板 */
@media (max-width: 768px) {
    .container {
        padding: 15px;
    }

    .page-title h1 {
        font-size: 1.5rem;
    }

    .section-title {
        font-size: 1.4rem;
    }

    .search-form {
        flex-direction: column;
        align-items: stretch;
    }

    .search-form label {
        margin-bottom: 8px;
        margin-right: 0;
    }

    .search-form input[type="text"] {
        width: 100%;
        max-width: 100%;
    }

    .login-buttons {
        flex-direction: column;
        align-items: center;
    }

    .grid-section {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .grid-section table {
        font-size: 0.85rem;
    }

    .grid-section th,
    .grid-section td {
        padding: 8px;
    }
}

/* 響應式設計 - 手機（320px寬度） */
@media (max-width: 480px) {
    .container {
        padding: 10px;
    }

    .page-title h1 {
        font-size: 1.3rem;
    }

    .section-title {
        font-size: 1.2rem;
    }

    .account-info {
        padding: 15px 10px;
    }

    .account-info p {
        font-size: 0.9rem;
        line-height: 1.5;
    }

    .search-form {
        gap: 8px;
    }

    .grid-section table {
        font-size: 0.8rem;
    }

    .grid-section th,
    .grid-section td {
        padding: 6px 4px;
        font-size: 0.8rem;
    }
}

/* 小視窗流動排版（320px寬度對應） */
@media (max-width: 320px) {
    .container {
        padding: 8px;
    }

    .page-title h1 {
        font-size: 1.2rem;
    }

    .account-info {
        padding: 12px 8px;
    }

    .account-info p {
        font-size: 0.85rem;
    }

    .grid-section table {
        font-size: 0.75rem;
    }

    .grid-section th,
    .grid-section td {
        padding: 5px 3px;
        font-size: 0.75rem;
    }

    .login-buttons {
        gap: 10px;
    }

    .login-buttons img {
        max-width: 90%;
    }
}

/* 標籤樣式 */
.tag {
    background-color: #99CCFF;
    text-align: center;
}

th a {
    color: #003399;
    text-decoration: none;
}

/* 舊有樣式保留（向後相容） */
.account-info .style3 {
    color: #e65100;
    font-weight: bold;
    font-size: 1.125em;
}

.account-info .style5 {
    color: #1a1a1a;
    font-weight: bold;
}
