/* -----------------------------------------------------------
   GiftVote — 振興醫院 (CHGH) Design System
   Based on Bootstrap 5.3.3; CDN-first with local fallback.
----------------------------------------------------------- */

:root {
    --bs-primary: #003366;
    --bs-primary-rgb: 0, 51, 102;
    --bs-secondary: #C19A6B;
    --bs-secondary-rgb: 193, 154, 107;
    --bs-success: #558B2F;
    --bs-success-rgb: 85, 139, 47;
    --bs-danger: #A31D1D;
    --bs-danger-rgb: 163, 29, 29;
    --bs-warning: #E6A23C;
    --bs-light: #F9F7F2;
    --bs-light-rgb: 249, 247, 242;
    --bs-dark: #2C2C2C;
    --bs-dark-rgb: 44, 44, 44;

    --bs-body-bg: var(--bs-light);
    --bs-body-color: var(--bs-dark);
    --bs-link-color: var(--bs-primary);
    --bs-link-hover-color: #002244;

    --ch-font-sans: 'Noto Sans TC', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --ch-font-serif: 'Noto Serif TC', "Times New Roman", Times, serif;

    --bs-font-sans-serif: var(--ch-font-sans);
    --bs-body-font-family: var(--ch-font-sans);

    --bs-border-radius: 0.5rem;
    --bs-border-radius-lg: 0.75rem;
    --bs-border-radius-sm: 0.25rem;
    --ch-box-shadow: 0 4px 12px rgba(0, 51, 102, 0.08);
    --ch-box-shadow-hover: 0 8px 24px rgba(0, 51, 102, 0.12);
}

html {
    font-size: 15px;
    position: relative;
    min-height: 100%;
}
@media (min-width: 768px) {
    html { font-size: 16px; }
}

body {
    background-color: var(--bs-light);
    color: var(--bs-dark);
    font-family: var(--ch-font-sans);
    line-height: 1.6;
    background-image:
        radial-gradient(circle at 15% 12%, rgba(193, 154, 107, 0.05) 0%, transparent 35%),
        radial-gradient(circle at 85% 88%, rgba(0, 51, 102, 0.04) 0%, transparent 40%);
    background-attachment: fixed;
    min-height: 100vh;
}

h1, h2, h3, h4, h5, h6,
.h1, .h2, .h3, .h4, .h5, .h6 {
    font-family: var(--ch-font-serif);
    font-weight: 700;
    color: var(--bs-primary);
    letter-spacing: 0.02em;
}

/* 導覽列 */
.navbar-chgh {
    background-color: #fff;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}
.navbar-chgh .navbar-brand {
    font-family: var(--ch-font-serif);
    font-weight: 700;
    color: var(--bs-primary);
    letter-spacing: 0.04em;
}
.navbar-chgh .navbar-brand .brand-accent { color: var(--bs-secondary); }
.navbar-chgh .nav-link {
    color: var(--bs-dark);
    font-weight: 500;
    position: relative;
}
.navbar-chgh .nav-link.active,
.navbar-chgh .nav-link:hover { color: var(--bs-primary); }
.navbar-chgh .nav-link::after {
    content: '';
    position: absolute;
    width: 0;
    height: 2px;
    bottom: -2px;
    left: 50%;
    background-color: var(--bs-secondary);
    transition: all 0.3s ease;
}
.navbar-chgh .nav-link:hover::after,
.navbar-chgh .nav-link.active::after { width: 100%; left: 0; }

/* 飯店式卡片 */
.ch-card {
    border: none;
    border-radius: var(--bs-border-radius-lg);
    background: #fff;
    box-shadow: var(--ch-box-shadow);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    overflow: hidden;
}
.ch-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--ch-box-shadow-hover);
}
.ch-card .card-header {
    background-color: #fff;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    font-family: var(--ch-font-serif);
    color: var(--bs-primary);
    font-weight: 700;
    padding: 1.25rem 1.5rem;
}

/* 引用區塊 */
.ch-blockquote {
    border-left: 4px solid var(--bs-secondary);
    background: #fff;
    padding: 1.5rem 2rem;
    margin: 1.5rem 0;
    font-family: var(--ch-font-serif);
    font-size: 1.1rem;
    color: var(--bs-primary);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.03);
    border-radius: 0 0.5rem 0.5rem 0;
}

/* 表單 */
.form-control:focus,
.form-select:focus {
    border-color: var(--bs-secondary);
    box-shadow: 0 0 0 0.25rem rgba(193, 154, 107, 0.25);
}

/* 按鈕 */
.btn {
    font-weight: 500;
    letter-spacing: 0.5px;
    padding: 0.5rem 1.25rem;
    border-radius: var(--bs-border-radius);
}
.btn-primary {
    background: linear-gradient(180deg, var(--bs-primary) 0%, #002244 100%);
    border: none;
}
.btn-secondary {
    background: linear-gradient(180deg, #C19A6B 0%, #a07a4d 100%);
    border: none;
    color: #fff;
}
.btn-outline-primary {
    border-color: var(--bs-primary);
    color: var(--bs-primary);
}

/* 表格 */
.ch-table thead {
    background-color: var(--bs-primary);
    color: #fff;
}
.ch-table thead th {
    font-weight: 500;
    border: none;
    vertical-align: middle;
}
.ch-table tbody tr:nth-of-type(odd) {
    background-color: rgba(0, 51, 102, 0.02);
}

/* ============ 投票頁專屬 ============ */
.vote-hero {
    background: linear-gradient(135deg, #003366 0%, #00254d 60%, #001a38 100%);
    color: #fff;
    border-radius: var(--bs-border-radius-lg);
    padding: 3rem 2.5rem;
    position: relative;
    overflow: hidden;
    box-shadow: var(--ch-box-shadow);
}
.vote-hero::after {
    content: '';
    position: absolute;
    top: -40%;
    right: -10%;
    width: 320px;
    height: 320px;
    background: radial-gradient(circle, rgba(193, 154, 107, 0.25) 0%, transparent 70%);
    border-radius: 50%;
}
.vote-hero h1 { color: #fff; }
.vote-hero .lead { color: rgba(255, 255, 255, 0.85); }
.vote-hero .hero-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(193, 154, 107, 0.2);
    border: 1px solid rgba(193, 154, 107, 0.5);
    color: #e8d6bd;
    padding: 0.35rem 1rem;
    border-radius: 2rem;
    font-size: 0.875rem;
    margin-bottom: 1rem;
}

/* 禮物卡片 */
.gift-card {
    appearance: none;
    color: inherit;
    padding: 0;
    border: 2px solid transparent;
    border-radius: var(--bs-border-radius-lg);
    background: #fff;
    box-shadow: var(--ch-box-shadow);
    transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    height: 100%;
    position: relative;
    opacity: 0;
    animation: giftFadeIn 0.5s ease forwards;
}
.gift-card:hover {
    transform: translateY(-6px);
    box-shadow: var(--ch-box-shadow-hover);
}
.gift-card.selected {
    border-color: var(--bs-secondary);
    box-shadow: 0 8px 24px rgba(193, 154, 107, 0.3);
}
.gift-card .gift-img-wrap {
    aspect-ratio: 4 / 3;
    background: linear-gradient(135deg, #f0ebe2 0%, #e6ddd0 100%);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}
.gift-gallery-trigger {
    appearance: none;
    border: 0;
    padding: 0;
    background: transparent;
    width: 100%;
    height: 100%;
    position: relative;
    cursor: zoom-in;
}
.gift-gallery-trigger:focus-visible,
.gift-select-btn:focus-visible {
    outline: 3px solid rgba(193, 154, 107, 0.55);
    outline-offset: -3px;
}
.gift-card .gift-img-wrap img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.4s ease;
}
.gift-card:hover .gift-img-wrap img { transform: scale(1.05); }
.gift-zoom-hint,
.gift-image-count {
    position: absolute;
    bottom: 0.75rem;
    background: rgba(0, 33, 67, 0.82);
    color: #fff;
    border-radius: 2rem;
    padding: 0.3rem 0.65rem;
    font-size: 0.78rem;
    line-height: 1;
}
.gift-zoom-hint { left: 0.75rem; }
.gift-image-count { right: 0.75rem; }
.gift-card .gift-img-placeholder {
    color: var(--bs-secondary);
    font-size: 3rem;
    opacity: 0.5;
}
.gift-card .gift-body {
    padding: 1.1rem 1.25rem 1.25rem;
    display: flex;
    flex-direction: column;
    flex: 1;
}
.gift-card .gift-name {
    font-family: var(--ch-font-serif);
    font-weight: 700;
    color: var(--bs-primary);
    font-size: 1.1rem;
    margin-bottom: 0.35rem;
}
.gift-card .gift-desc {
    color: #6c757d;
    font-size: 0.875rem;
    margin-bottom: 0;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.gift-select-btn {
    min-height: 44px;
    margin-top: auto !important;
}

/* 選取勾選標記 */
.gift-check {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #fff;
    border: 2px solid rgba(0, 51, 102, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    color: transparent;
    transition: all 0.2s ease;
    z-index: 2;
}
.gift-card.selected .gift-check {
    background: var(--bs-secondary);
    border-color: var(--bs-secondary);
    color: #fff;
    transform: scale(1.1);
}

/* 圖片燈箱 */
.gallery-modal-content {
    border: 0;
    border-radius: 1rem;
    overflow: hidden;
}
.gallery-stage {
    min-height: min(70vh, 720px);
    background: #111820;
    border-radius: 0.75rem;
    display: grid;
    grid-template-columns: 52px minmax(0, 1fr) 52px;
    align-items: center;
    overflow: hidden;
}
.gallery-stage img {
    width: 100%;
    height: min(70vh, 720px);
    object-fit: contain;
}
.gallery-nav {
    width: 44px;
    height: 44px;
    margin: 4px;
    border: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.14);
    color: #fff;
    font-size: 1.4rem;
}
.gallery-nav:hover,
.gallery-nav:focus-visible {
    background: rgba(255, 255, 255, 0.28);
}
.gallery-counter {
    text-align: center;
    color: #6c757d;
    padding-top: 0.75rem;
    font-variant-numeric: tabular-nums;
}

/* 管理端多圖片 */
.admin-image-list {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    min-height: 56px;
    align-items: center;
}
.admin-image-thumb {
    position: relative;
    width: 64px;
    height: 64px;
}
.admin-image-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 0.5rem;
    border: 1px solid rgba(0, 51, 102, 0.12);
}
.admin-image-thumb form {
    position: absolute;
    top: -7px;
    right: -7px;
}
.admin-image-thumb button {
    width: 26px;
    height: 26px;
    padding: 0;
    border: 2px solid #fff;
    border-radius: 50%;
    background: var(--bs-danger);
    color: #fff;
    font-size: 0.7rem;
}
.admin-image-input {
    max-width: 260px;
}

@keyframes giftFadeIn {
    from { opacity: 0; transform: translateY(16px); }
    to { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        scroll-behavior: auto !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

@media (max-width: 575.98px) {
    .gallery-stage {
        min-height: 55vh;
        grid-template-columns: 44px minmax(0, 1fr) 44px;
    }
    .gallery-stage img {
        height: 55vh;
    }
    .vote-actionbar .container {
        gap: 0.75rem;
    }
    .vote-actionbar .btn {
        padding-inline: 0.8rem;
        font-size: 0.95rem;
    }
}

/* 底部固定投票列 */
.vote-actionbar {
    position: sticky;
    bottom: 0;
    background: rgba(255, 255, 255, 0.97);
    backdrop-filter: blur(8px);
    border-top: 1px solid rgba(0, 51, 102, 0.1);
    box-shadow: 0 -4px 16px rgba(0, 51, 102, 0.06);
    padding: 1rem 0;
    z-index: 100;
}
.vote-counter {
    font-family: var(--ch-font-serif);
    font-weight: 700;
    color: var(--bs-primary);
}
.vote-counter .current {
    color: var(--bs-secondary);
    font-size: 1.5rem;
}

/* 結果頁長條 */
.result-bar-track {
    background: rgba(0, 51, 102, 0.06);
    border-radius: 2rem;
    height: 12px;
    overflow: hidden;
}
.result-bar-fill {
    background: linear-gradient(90deg, var(--bs-secondary) 0%, #d4b487 100%);
    height: 100%;
    border-radius: 2rem;
    transition: width 0.8s ease;
}
.result-rank {
    font-family: var(--ch-font-serif);
    font-weight: 700;
    width: 2.5rem;
    text-align: center;
    color: var(--bs-secondary);
}
.result-rank.top1 { color: #C19A6B; font-size: 1.4rem; }

/* 工號輸入大型框 */
.employee-input {
    font-size: 1.15rem;
    padding: 0.85rem 1.1rem;
    letter-spacing: 0.05em;
    text-align: center;
}

footer.ch-footer {
    background: #fff;
    border-top: 1px solid rgba(0, 51, 102, 0.08);
    color: #6c757d;
    font-size: 0.875rem;
}
.stat-tile {
    background: #fff;
    border-radius: var(--bs-border-radius-lg);
    box-shadow: var(--ch-box-shadow);
    padding: 1.5rem;
    text-align: center;
}
.stat-tile .stat-num {
    font-family: var(--ch-font-serif);
    font-weight: 700;
    font-size: 2.2rem;
    color: var(--bs-primary);
    line-height: 1;
}
.stat-tile .stat-label {
    color: #6c757d;
    font-size: 0.875rem;
    margin-top: 0.35rem;
}
