/* ═══════════════════════════════════════════
   校園優惠券 - 自訂樣式
   移動端優先，綠色主題
   ═══════════════════════════════════════════ */

:root {
    --green: #4CAF50;
    --green-dark: #388E3C;
    --orange: #FF9800;
    --bg: #F5F5F5;
    --card: #FFFFFF;
    --text: #212121;
    --text-secondary: #757575;
    --divider: #EEEEEE;
    --danger: #F44336;
}

/* ═══ 基礎 ═══════════════════════════════════ */

html { font-size: 15px; }
body.front-body {
    background: var(--bg);
    color: var(--text);
    padding-top: 56px;
    padding-bottom: 70px;
    max-width: 100vw;
    overflow-x: hidden;
}

a { text-decoration: none; }

/* ═══ 頂欄 ═══════════════════════════════════ */

.topbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 56px;
    background: #fff;
    z-index: 1000;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.topbar-inner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 100%;
    padding: 0 16px;
    max-width: 480px;
    margin: 0 auto;
}

.topbar-brand {
    font-size: 18px;
    font-weight: 700;
    color: var(--text);
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.topbar-icon {
    font-size: 20px;
    color: var(--text-secondary);
}

.topbar-admin-link {
    font-size: 13px;
    color: var(--text-secondary);
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 2px 8px;
}

/* ═══ 分類欄 ═══════════════════════════════════ */

.category-bar {
    position: sticky;
    top: 56px;
    z-index: 999;
    background: #fff;
    border-bottom: 1px solid var(--divider);
}

.category-scroll {
    display: flex;
    overflow-x: auto;
    gap: 4px;
    padding: 8px 12px;
    max-width: 480px;
    margin: 0 auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}
.category-scroll::-webkit-scrollbar { display: none; }

.category-tag {
    flex-shrink: 0;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 14px;
    color: var(--text-secondary);
    background: #f0f0f0;
    white-space: nowrap;
    transition: all 0.2s;
}
.category-tag.active {
    background: var(--green);
    color: #fff;
    font-weight: 600;
}

/* ═══ 排序欄 ═══════════════════════════════════ */

.sort-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    font-size: 13px;
}

.sort-label { color: var(--text-secondary); }

.sort-link {
    color: var(--text-secondary);
    padding: 4px 10px;
    border-radius: 14px;
    background: #e9e9e9;
    font-size: 13px;
}
.sort-link.active {
    background: var(--green);
    color: #fff;
}

/* ═══ 優惠卡片 ═══════════════════════════════════ */

.coupon-list {
    padding: 0 12px;
    max-width: 480px;
    margin: 0 auto;
}

.coupon-card-link { display: block; margin-bottom: 14px; }

.coupon-card {
    background: var(--card);
    border-radius: 12px;
    padding: 16px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    transition: transform 0.15s;
}
.coupon-card:active { transform: scale(0.98); }

.coupon-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.coupon-shop-name {
    font-size: 16px;
    font-weight: 700;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 8px;
}

.shop-logo-thumb {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.coupon-status {
    font-size: 12px;
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: 500;
}
.status-active { background: #E8F5E9; color: var(--green); }
.status-expiring { background: #FFF3E0; color: var(--orange); }

.coupon-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 6px;
    line-height: 1.3;
}

.coupon-desc {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 10px;
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.coupon-code-inline {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #E8F5E9;
    padding: 8px 12px;
    border-radius: 8px;
    margin-bottom: 10px;
}

.code-label { font-size: 12px; color: var(--green); font-weight: 600; }

.coupon-code-inline code {
    font-size: 16px;
    font-weight: 700;
    color: var(--green-dark);
    background: none;
    flex: 1;
}

.copy-btn {
    font-size: 13px;
    color: var(--green);
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
}

.coupon-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
}

.coupon-category {
    background: #f0f0f0;
    padding: 2px 8px;
    border-radius: 4px;
    color: var(--text-secondary);
}

.coupon-days { color: var(--text-secondary); }
.coupon-days.text-warning { color: var(--orange) !important; }

.coupon-address {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--divider);
}

/* ═══ 底部導航 ═══════════════════════════════════ */

.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: #fff;
    display: flex;
    justify-content: space-around;
    align-items: center;
    box-shadow: 0 -1px 3px rgba(0,0,0,0.08);
    z-index: 1000;
    padding-bottom: env(safe-area-inset-bottom);
}

.bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    font-size: 11px;
    color: var(--text-secondary);
    padding: 4px 16px;
}
.bottom-nav-item.active { color: var(--green); }
.bottom-nav-item i { font-size: 22px; }

/* ═══ 詳情頁 ═══════════════════════════════════ */

.detail-page { padding: 0 16px 16px; max-width: 600px; margin: 0 auto; }

.detail-header { padding: 24px 0 16px; }

.shop-logo-large {
    width: 80px;
    height: 80px;
    margin: 0 auto 12px;
    border-radius: 50%;
    background: #f0f0f0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 40px;
    overflow: hidden;
}
.shop-logo-large img { width: 100%; height: 100%; object-fit: cover; }

.detail-section {
    background: #fff;
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 12px;
}

.detail-label { font-weight: 700; margin-bottom: 8px; font-size: 15px; }

.detail-title { font-size: 20px; font-weight: 700; margin-bottom: 8px; }

.detail-desc { color: var(--text-secondary); line-height: 1.7; }

.detail-text { color: var(--text-secondary); line-height: 1.7; }

.code-box {
    background: #E8F5E9;
    border-radius: 8px;
    padding: 12px;
    margin-top: 12px;
}

.code-box.no-code { background: #FFF8E1; text-align: center; color: #F57F17; }

.code-box-label { font-size: 13px; color: var(--green); margin-bottom: 6px; }

.code-box-value {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.code-box-value code { font-size: 20px; font-weight: 700; color: var(--green-dark); background: none; }

.detail-info-list { display: flex; flex-direction: column; gap: 8px; }

.detail-info-item { font-size: 14px; color: var(--text-secondary); }
.detail-info-item a { color: var(--green); }

.detail-share { padding: 16px 0; }

.share-banner {
    position: fixed;
    bottom: 60px;
    left: 0;
    right: 0;
    background: var(--green);
    color: #fff;
    text-align: center;
    padding: 10px;
    font-size: 14px;
    z-index: 999;
}
.share-banner a { color: #fff; font-weight: 600; }

/* ═══ 搜索頁 ═══════════════════════════════════ */

.search-page { padding: 16px; max-width: 600px; margin: 0 auto; }
.search-form { margin-bottom: 16px; }
.search-result-count { font-size: 14px; color: var(--text-secondary); }

/* ═══ 商戶列表 ═══════════════════════════════════ */

.shop-list { padding: 0 12px; max-width: 480px; margin: 0 auto; }

.shop-card-link { display: block; margin-bottom: 10px; }

.shop-card {
    background: #fff;
    border-radius: 12px;
    padding: 14px;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.05);
}

.shop-icon { font-size: 32px; flex-shrink: 0; }

.shop-info { flex: 1; min-width: 0; }
.shop-name { font-size: 16px; font-weight: 700; display: block; color: var(--text); }
.shop-addr { font-size: 13px; color: var(--text-secondary); display: block; }

.shop-coupon-count {
    font-size: 13px;
    color: var(--green);
    white-space: nowrap;
    font-weight: 600;
}

/* ═══ 空狀態 ═══════════════════════════════════ */

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary);
}

.empty-icon { font-size: 64px; margin-bottom: 16px; }

/* ═══ 關於頁 ═══════════════════════════════════ */
.about-page { padding: 16px; max-width: 600px; margin: 0 auto; }

/* ═══ Toast ═══════════════════════════════════ */

.toast-success {
    position: fixed;
    top: 70px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--green);
    color: #fff;
    padding: 10px 24px;
    border-radius: 8px;
    font-size: 14px;
    z-index: 2000;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

/* ═══ 分頁 ═══════════════════════════════════ */

.pagination-bar {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
    padding: 16px;
    font-size: 14px;
}

.page-link {
    padding: 6px 14px;
    border-radius: 6px;
    background: #fff;
    color: var(--green);
    border: 1px solid var(--divider);
}

.page-info { color: var(--text-secondary); }

/* ═══ 登入頁 ═══════════════════════════════════ */

.login-body {
    background: var(--bg);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-container { width: 100%; max-width: 380px; padding: 20px; }

.login-card {
    background: #fff;
    border-radius: 12px;
    padding: 32px 24px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.08);
}

/* ═══ 後台佈局 ═══════════════════════════════════ */

body.admin-body {
    background: var(--bg);
    padding-top: 48px;
}

.admin-topbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 48px;
    background: #fff;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 16px;
    z-index: 1000;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.admin-layout { display: flex; min-height: calc(100vh - 48px); }

/* 側欄 */
.admin-sidebar {
    width: 200px;
    background: #fff;
    border-right: 1px solid var(--divider);
    flex-shrink: 0;
    padding: 16px 0;
    transition: transform 0.3s;
}

.admin-nav-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    color: var(--text-secondary);
    font-size: 15px;
}
.admin-nav-item:hover { background: #f5f5f5; color: var(--text); }
.admin-nav-item.active { background: #E8F5E9; color: var(--green); font-weight: 600; }

.admin-main {
    flex: 1;
    padding: 20px;
    max-width: 900px;
}

/* 響應式：手機端側欄隱藏 */
@media (max-width: 991px) {
    .admin-sidebar {
        position: fixed;
        left: 0;
        top: 48px;
        bottom: 0;
        transform: translateX(-100%);
        z-index: 999;
        box-shadow: 2px 0 8px rgba(0,0,0,0.1);
    }
    .admin-sidebar.show { transform: translateX(0); }
    .admin-main { padding: 12px; }
}

/* ═══ 後台統計卡片 ═══════════════════════════════════ */

.stat-card {
    background: #fff;
    border-radius: 12px;
    padding: 20px;
    text-align: center;
    box-shadow: 0 1px 4px rgba(0,0,0,0.05);
}

.stat-number { font-size: 32px; font-weight: 700; }

.stat-label { font-size: 13px; color: var(--text-secondary); margin-top: 4px; }

/* ═══ 響應式：平板兩列 ═══════════════════════════════════ */
@media (min-width: 768px) {
    .coupon-list {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 0 14px;
        max-width: 720px;
    }
    .coupon-card-link { margin-bottom: 0; }
    .shop-list {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 10px;
        max-width: 720px;
    }
}

@media (min-width: 992px) {
    .coupon-list {
        grid-template-columns: 1fr 1fr 1fr;
        max-width: 960px;
    }
    .shop-list {
        grid-template-columns: 1fr 1fr 1fr;
        max-width: 960px;
    }
}
