/**
 * B2 限免管理 - 前端限免列表页样式
 * 前缀: fb- (Freebie)
 */

/* ====== Reset & Variables ====== */
.fb-wrap *, .fb-wrap *::before, .fb-wrap *::after { box-sizing: border-box; margin: 0; padding: 0; }
.fb-wrap {
    --c-bg: #f5f7fa;
    --c-surface: #fff;
    --c-border: #ebeef5;
    --c-text: #1a1a2e;
    --c-text-2: #5a607f;
    --c-text-3: #8e94b3;
    --c-primary: #4f6ef7;
    --c-primary-light: #eef1fe;
    --c-green: #22c55e;
    --c-green-light: #f0fdf4;
    --c-orange: #f59e0b;
    --c-red: #ef4444;
    --c-red-light: #fef2f2;
    --radius: 14px;
    --radius-sm: 8px;
    --shadow-card: 0 1px 3px rgba(0,0,0,.04), 0 1px 2px rgba(0,0,0,.06);
    --shadow-hover: 0 12px 24px rgba(0,0,0,.08), 0 4px 8px rgba(0,0,0,.04);
    --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    max-width: 1160px;
    margin: 0 auto;
    padding: 28px 20px 60px;
    font-family: var(--font);
    color: var(--c-text);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ====== Hero ====== */
.fb-hero {
    position: relative;
    border-radius: 20px;
    padding: 44px 40px;
    margin-bottom: 32px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    overflow: hidden;
    color: #fff;
}

.fb-hero::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -20%;
    width: 500px;
    height: 500px;
    border-radius: 50%;
    background: rgba(255,255,255,.08);
    pointer-events: none;
}

.fb-hero::after {
    content: '';
    position: absolute;
    bottom: -60%;
    left: -10%;
    width: 400px;
    height: 400px;
    border-radius: 50%;
    background: rgba(255,255,255,.05);
    pointer-events: none;
}

.fb-hero-inner {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
}

.fb-hero h1 {
    font-size: 26px;
    font-weight: 700;
    margin-bottom: 6px;
    letter-spacing: -.02em;
    line-height: 1.3;
}

.fb-hero-desc {
    font-size: 14px;
    opacity: .8;
    line-height: 1.5;
}

.fb-hero-count {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 24px;
    background: rgba(255,255,255,.15);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255,255,255,.2);
    border-radius: 14px;
}

.fb-hero-num {
    font-size: 36px;
    font-weight: 800;
    line-height: 1;
}

.fb-hero-label {
    font-size: 13px;
    opacity: .85;
    line-height: 1.3;
}

.fb-hero-stats {
    display: flex;
    gap: 12px;
    flex-shrink: 0;
}

.fb-hero-num--icon {
    font-size: 20px;
}

.fb-hero-num--icon svg {
    vertical-align: middle;
}

/* ====== Toolbar ====== */
/* Category navigation */
.fb-cat-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
}
.fb-cat-link {
    display: inline-block;
    padding: 6px 16px;
    font-size: 13px;
    font-weight: 500;
    color: var(--c-text-2);
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: 20px;
    text-decoration: none;
    transition: all .2s ease;
}
.fb-cat-link:hover {
    color: var(--c-primary);
    border-color: var(--c-primary);
    background: rgba(102,126,234,.06);
}
.fb-cat-link.active {
    color: #fff;
    background: var(--c-primary);
    border-color: var(--c-primary);
}

.fb-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    gap: 12px;
    flex-wrap: wrap;
}

.fb-tabs {
    display: flex;
    gap: 4px;
    padding: 3px;
    background: var(--c-border);
    border-radius: 10px;
}

.fb-tab {
    padding: 7px 16px;
    border: none;
    background: transparent;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    color: var(--c-text-2);
    transition: all .15s ease;
    font-family: var(--font);
    white-space: nowrap;
}

.fb-tab:hover { color: var(--c-text); }

.fb-tab.active {
    background: var(--c-surface);
    color: var(--c-text);
    box-shadow: 0 1px 3px rgba(0,0,0,.08);
}

.fb-tab-count {
    margin-left: 4px;
    font-size: 11px;
    font-weight: 400;
    color: var(--c-text-3);
}

.fb-summary {
    font-size: 13px;
    color: var(--c-text-3);
}

/* ====== Grid ====== */
.fb-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 40px;
}

/* ====== Card ====== */
.fb-card {
    background: var(--c-surface);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow-card);
    transition: transform .25s ease, box-shadow .25s ease;
    border: 1px solid var(--c-border);
}

.fb-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-hover);
    border-color: transparent;
}

/* Thumbnail */
.fb-img {
    position: relative;
    aspect-ratio: 4 / 3;
    overflow: hidden;
    display: block;
    background: #f0f2f5;
}

.fb-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform .4s ease;
}

.fb-card:hover .fb-img img { transform: scale(1.06); }

.fb-img-empty {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(145deg, #f0f2f5, #e4e7ec);
}

.fb-img-empty svg { width: 36px; height: 36px; color: #c5c9d6; }

/* Overlay on hover */
.fb-img-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, rgba(0,0,0,.55) 0%, transparent 60%);
    opacity: 0;
    transition: opacity .25s ease;
    pointer-events: none;
}

.fb-card:hover .fb-img-overlay { opacity: 1; }

/* CTA button on hover */
.fb-img-cta {
    position: absolute;
    bottom: 12px;
    left: 50%;
    transform: translateX(-50%) translateY(8px);
    padding: 7px 20px;
    background: #fff;
    color: var(--c-text);
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
    opacity: 0;
    transition: all .25s ease;
    z-index: 3;
    text-decoration: none;
    pointer-events: none;
    letter-spacing: .02em;
}

.fb-card:hover .fb-img-cta {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
    pointer-events: auto;
}

/* Badge */
.fb-label {
    position: absolute;
    top: 10px;
    left: 10px;
    z-index: 3;
    display: flex;
    gap: 5px;
}

.fb-tag {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: .02em;
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}

.fb-tag svg { width: 10px; height: 10px; flex-shrink: 0; }

.fb-tag-free {
    background: rgba(34,197,94,.88);
    color: #fff;
}

.fb-tag-urgent {
    background: rgba(239,68,68,.88);
    color: #fff;
    animation: fb-pulse 2s ease-in-out infinite;
}

.fb-tag-new {
    background: rgba(79,110,247,.88);
    color: #fff;
}

.fb-label-right {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 3;
}

@keyframes fb-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: .7; }
}

/* Card body */
.fb-info {
    padding: 14px;
}

.fb-name {
    margin: 0 0 10px;
    font-size: 14px;
    font-weight: 600;
    line-height: 1.5;
    height: 3em;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.fb-name a {
    color: var(--c-text);
    text-decoration: none;
    transition: color .15s ease;
}

.fb-name a:hover { color: var(--c-primary); }

/* Time bar */
.fb-time-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 6px;
}

.fb-time-bar {
    flex: 1;
    height: 4px;
    background: #f0f2f5;
    border-radius: 2px;
    overflow: hidden;
}

.fb-time-fill {
    height: 100%;
    border-radius: 2px;
    transition: width .3s ease;
}

.fb-time-fill.green { background: var(--c-green); }
.fb-time-fill.orange { background: var(--c-orange); }
.fb-time-fill.red { background: var(--c-red); }

.fb-time-text {
    flex-shrink: 0;
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
}

.fb-time-text.green { color: var(--c-green); }
.fb-time-text.orange { color: #d97706; }
.fb-time-text.red { color: var(--c-red); }

/* Card footer meta */
.fb-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 11px;
    color: var(--c-text-3);
}

.fb-foot-item {
    display: inline-flex;
    align-items: center;
    gap: 3px;
}

.fb-foot-item svg { width: 12px; height: 12px; flex-shrink: 0; }

/* ====== Empty / Paused State ====== */
.fb-state {
    text-align: center;
    padding: 80px 24px;
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: var(--radius);
}

.fb-state-icon {
    width: 72px;
    height: 72px;
    margin: 0 auto 20px;
    background: var(--c-primary-light);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.fb-state-icon svg { width: 32px; height: 32px; color: var(--c-primary); }
.fb-state-icon.warn { background: var(--c-red-light); }
.fb-state-icon.warn svg { color: var(--c-red); }

.fb-state h3 {
    font-size: 17px;
    font-weight: 600;
    color: var(--c-text);
    margin-bottom: 8px;
}

.fb-state p {
    font-size: 14px;
    color: var(--c-text-2);
    margin-bottom: 24px;
    line-height: 1.6;
}

.fb-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 22px;
    background: var(--c-primary);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    font-family: var(--font);
    transition: background .15s ease, transform .15s ease;
}

.fb-btn:hover { background: #3b5de7; transform: translateY(-1px); }
.fb-btn svg { width: 16px; height: 16px; }

/* ====== Pagination ====== */
.fb-pager {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 6px;
    margin-bottom: 40px;
}

.fb-pg {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 0 10px;
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: var(--radius-sm);
    color: var(--c-text-2);
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    transition: all .15s ease;
}

.fb-pg:hover {
    border-color: var(--c-primary);
    color: var(--c-primary);
}

.fb-pg.current {
    background: var(--c-primary);
    border-color: var(--c-primary);
    color: #fff;
}

.fb-pg.nav { padding: 0 14px; gap: 4px; }
.fb-pg.nav svg { width: 14px; height: 14px; }

.fb-dots {
    padding: 0 4px;
    color: var(--c-text-3);
    font-size: 13px;
}

.fb-pager-info {
    text-align: center;
    font-size: 12px;
    color: var(--c-text-3);
    margin-bottom: 40px;
}

/* ====== Notice ====== */
.fb-notice {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    background: var(--c-primary-light);
    border: 1px solid #dde3fd;
    border-radius: var(--radius);
    padding: 18px 20px;
    font-size: 13px;
    line-height: 1.7;
    color: var(--c-text-2);
}

.fb-notice-icon {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    color: var(--c-primary);
    margin-top: 2px;
}

.fb-notice-body strong {
    display: block;
    font-size: 14px;
    color: var(--c-text);
    margin-bottom: 4px;
}

/* ====== Back to top ====== */
.fb-top {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 40px;
    height: 40px;
    background: var(--c-text);
    color: #fff;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all .2s ease;
    z-index: 999;
    box-shadow: 0 4px 12px rgba(0,0,0,.15);
}

.fb-top.show { opacity: 1; visibility: visible; }
.fb-top:hover { transform: translateY(-2px); }
.fb-top svg { width: 18px; height: 18px; }

/* ====== Responsive ====== */
@media (max-width: 1100px) {
    .fb-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 768px) {
    .fb-wrap { padding: 16px 14px 48px; }
    .fb-hero { padding: 32px 24px; border-radius: 16px; }
    .fb-hero-inner { flex-direction: column; text-align: center; }
    .fb-hero h1 { font-size: 22px; }
    .fb-hero-count { padding: 12px 20px; }
    .fb-hero-num { font-size: 28px; }
    .fb-hero-stats { flex-direction: column; }
    .fb-cat-nav { overflow-x: auto; -webkit-overflow-scrolling: touch; flex-wrap: nowrap; gap: 6px; }
    .fb-cat-link { flex-shrink: 0; }
    .fb-toolbar { flex-direction: column; align-items: stretch; }
    .fb-tabs { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .fb-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
}

@media (max-width: 480px) {
    .fb-grid { gap: 10px; }
    .fb-info { padding: 10px; }
    .fb-name { font-size: 13px; height: 2.9em; }
    .fb-time-text { font-size: 10px; }
    .fb-foot { font-size: 10px; }
}

/* ====== Dark Mode ====== */
html.dark .fb-wrap {
    --c-bg: #292a2d;
    --c-surface: #323335;
    --c-border: rgba(114, 114, 114, 0.15);
    --c-text: #e0e0e0;
    --c-text-2: #adb5bd;
    --c-text-3: #888;
    --c-primary: #2882c5;
    --c-primary-light: rgba(40, 130, 197, 0.12);
    --c-green-light: rgba(34, 197, 94, 0.1);
    --c-red-light: rgba(239, 68, 68, 0.1);
    --shadow-card: 0 1px 3px rgba(0,0,0,.12), 0 1px 2px rgba(0,0,0,.16);
    --shadow-hover: 0 12px 24px rgba(0,0,0,.2), 0 4px 8px rgba(0,0,0,.12);
}
html.dark .fb-hero {
    background: linear-gradient(135deg, #1a3a5c 0%, #2882c5 100%);
}
html.dark .fb-img { background: #272a2b; }
html.dark .fb-img-empty {
    background: linear-gradient(145deg, #272a2b, #212425);
}
html.dark .fb-img-empty svg { color: #555; }
html.dark .fb-img-cta {
    background: #323335;
    color: #e0e0e0;
}
html.dark .fb-time-bar { background: #272a2b; }
html.dark .fb-notice {
    background: rgba(40, 130, 197, 0.08);
    border-color: rgba(40, 130, 197, 0.2);
}
html.dark .fb-top {
    background: #2882c5;
    box-shadow: 0 4px 12px rgba(0,0,0,.3);
}
html.dark .fb-btn:hover { background: #1e6fa8; }
