/* ── Reset & Base ─────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; }
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
    background: #f0f2f5;
    color: #333;
    line-height: 1.6;
    min-height: 100vh;
}
a { color: #1890ff; text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; height: auto; }

/* ── Public Page ─────────────────────────────────────────────── */
.container {
    max-width: 720px;
    margin: 0 auto;
    padding: 20px 16px;
}
.hero {
    text-align: center;
    padding: 48px 0 32px;
}
.hero h1 {
    font-size: 2rem;
    font-weight: 700;
    color: #1a1a2e;
    margin-bottom: 8px;
}
.subtitle {
    font-size: 1.1rem;
    color: #666;
}

/* Announcements */
.announcements { margin-bottom: 32px; }
.announcement-card {
    border-radius: 12px;
    padding: 20px 24px;
    margin-bottom: 16px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}
.ann-header { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.ann-header h3 { font-size: 1.1rem; color: #1a1a2e; }
.pin-badge {
    font-size: 0.8rem;
    background: #fff3cd;
    color: #856404;
    padding: 2px 8px;
    border-radius: 4px;
    white-space: nowrap;
}
.ann-content { font-size: 0.95rem; color: #444; }

/* QR Codes */
.section-title {
    font-size: 1.3rem;
    margin-bottom: 20px;
    text-align: center;
    color: #1a1a2e;
}
.qr-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 20px;
}
.qr-card {
    background: #fff;
    border-radius: 16px;
    padding: 24px;
    text-align: center;
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    transition: transform 0.2s, box-shadow 0.2s;
}
.qr-card:hover { transform: translateY(-4px); box-shadow: 0 8px 24px rgba(0,0,0,0.12); }
.qr-image-wrapper {
    width: 200px;
    height: 200px;
    margin: 0 auto 16px;
    border-radius: 12px;
    overflow: hidden;
    border: 2px solid #f0f0f0;
}
.qr-image-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.qr-card h3 { font-size: 1.1rem; margin-bottom: 4px; }
.qr-desc { font-size: 0.85rem; color: #888; }
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: #999;
    font-size: 1.1rem;
}

/* Instructions */
.instructions {
    background: #fff;
    border-radius: 12px;
    padding: 24px;
    margin-top: 32px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}
.instructions-content { color: #555; }

/* Footer */
footer {
    text-align: center;
    padding: 32px 0;
    color: #999;
    font-size: 0.85rem;
}

/* ── Flash Messages ──────────────────────────────────────────── */
.flash-messages { margin-bottom: 16px; }
.flash {
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 8px;
    font-size: 0.9rem;
    transition: opacity 0.3s;
}
.flash-success { background: #d4edda; color: #155724; border: 1px solid #c3e6cb; }
.flash-error   { background: #f8d7da; color: #721c24; border: 1px solid #f5c6cb; }
.flash-info    { background: #d1ecf1; color: #0c5460; border: 1px solid #bee5eb; }

/* ── Login Page ──────────────────────────────────────────────── */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}
.login-box {
    background: #fff;
    padding: 40px 36px;
    border-radius: 16px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}
.login-box h1 { text-align: center; margin-bottom: 24px; font-size: 1.5rem; }
.back-link { display: block; text-align: center; margin-top: 16px; font-size: 0.9rem; }

/* ── Admin Layout ────────────────────────────────────────────── */
.admin-body { background: #f0f2f5; }
.admin-layout { display: flex; min-height: 100vh; }
.sidebar {
    width: 240px;
    background: #1a1a2e;
    color: #fff;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
}
.sidebar-header { padding: 20px 16px; border-bottom: 1px solid rgba(255,255,255,0.1); }
.sidebar-header h2 { font-size: 1.2rem; }
.sidebar-nav { flex: 1; padding: 12px 0; }
.sidebar-footer { border-top: 1px solid rgba(255,255,255,0.1); padding: 8px 0; }
.nav-item {
    display: block;
    padding: 12px 20px;
    color: rgba(255,255,255,0.7);
    font-size: 0.95rem;
    transition: all 0.2s;
    border-left: 3px solid transparent;
}
.nav-item:hover { color: #fff; background: rgba(255,255,255,0.05); text-decoration: none; }
.nav-item.active { color: #fff; background: rgba(255,255,255,0.1); border-left-color: #1890ff; }
.main-content {
    flex: 1;
    margin-left: 240px;
    padding: 24px 32px;
    min-width: 0;
}

/* ── Page Header ─────────────────────────────────────────────── */
.page-header { margin-bottom: 24px; }
.page-header h1 { font-size: 1.5rem; font-weight: 600; }

/* ── Stats Grid ──────────────────────────────────────────────── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; margin-bottom: 32px; }
.stat-card {
    background: #fff;
    border-radius: 12px;
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}
.stat-icon { font-size: 2rem; }
.stat-number { font-size: 2rem; font-weight: 700; color: #1a1a2e; }
.stat-label { font-size: 0.9rem; color: #888; }

/* ── Cards ───────────────────────────────────────────────────── */
.card {
    background: #fff;
    border-radius: 12px;
    margin-bottom: 24px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    overflow: hidden;
}
.card-header {
    padding: 16px 24px;
    border-bottom: 1px solid #f0f0f0;
}
.card-header h3 { font-size: 1rem; font-weight: 600; }
.card-body { padding: 20px 24px; }

/* ── Forms ───────────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    font-size: 0.9rem;
    color: #555;
}
.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid #d9d9d9;
    border-radius: 8px;
    font-size: 0.95rem;
    transition: border-color 0.2s;
    font-family: inherit;
}
.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #1890ff;
    box-shadow: 0 0 0 2px rgba(24,144,255,0.1);
}
.form-row { display: flex; gap: 12px; align-items: flex-end; }
.flex-1 { flex: 1; }
.input-sm {
    padding: 6px 10px;
    border: 1px solid #d9d9d9;
    border-radius: 6px;
    font-size: 0.85rem;
}
.input-sm:focus { outline: none; border-color: #1890ff; }
.color-input { width: 60px; height: 38px; padding: 2px; cursor: pointer; border: 1px solid #d9d9d9; border-radius: 6px; }
.checkbox-label { display: inline-flex; align-items: center; gap: 6px; margin-right: 16px; font-size: 0.9rem; cursor: pointer; }

/* ── Buttons ─────────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
    text-decoration: none;
}
.btn:hover { text-decoration: none; transform: translateY(-1px); }
.btn-primary { background: #1890ff; color: #fff; }
.btn-primary:hover { background: #40a9ff; }
.btn-secondary { background: #f0f0f0; color: #333; }
.btn-secondary:hover { background: #d9d9d9; }
.btn-danger { background: #ff4d4f; color: #fff; }
.btn-danger:hover { background: #ff7875; }
.btn-outline { background: transparent; border: 1px solid #d9d9d9; color: #555; }
.btn-outline:hover { border-color: #1890ff; color: #1890ff; }
.btn-block { display: block; width: 100%; }
.btn-sm { padding: 6px 12px; font-size: 0.8rem; }

/* ── Item List ───────────────────────────────────────────────── */
.item-list { display: flex; flex-direction: column; gap: 12px; }
.item-row {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px;
    border: 1px solid #f0f0f0;
    border-radius: 10px;
    transition: background 0.2s;
    flex-wrap: wrap;
}
.item-row:hover { background: #fafafa; }
.item-inactive { opacity: 0.6; }
.item-preview {
    width: 64px;
    height: 64px;
    border-radius: 8px;
    overflow: hidden;
    flex-shrink: 0;
    border: 1px solid #eee;
}
.item-preview img { width: 100%; height: 100%; object-fit: cover; }
.item-color-bar { width: 6px; height: 48px; border-radius: 3px; flex-shrink: 0; }
.item-info { flex: 1; min-width: 0; }
.item-info strong { display: block; margin-bottom: 2px; }
.item-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.inline-edit { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.ann-preview { font-size: 0.85rem; margin: 4px 0; word-break: break-all; }
.edit-details { display: inline-block; }
.edit-form { margin-top: 12px; display: flex; flex-direction: column; gap: 8px; }

/* ── Badges ──────────────────────────────────────────────────── */
.badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 10px;
    font-size: 0.75rem;
    font-weight: 500;
}
.badge-success { background: #d4edda; color: #155724; }
.badge-muted { background: #e9ecef; color: #6c757d; }
.text-muted { color: #999; font-size: 0.85rem; }

/* ── Quick Actions ───────────────────────────────────────────── */
.quick-actions { margin-top: 8px; }
.quick-actions h2 { font-size: 1.1rem; margin-bottom: 16px; }
.action-buttons { display: flex; gap: 12px; flex-wrap: wrap; }

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 768px) {
    .sidebar { width: 60px; }
    .sidebar-header h2, .nav-item { font-size: 0; }
    .nav-item { padding: 16px 0; text-align: center; font-size: 1.2rem; }
    .main-content { margin-left: 60px; padding: 16px; }
    .qr-grid { grid-template-columns: 1fr; }
    .form-row { flex-direction: column; }
    .item-row { flex-direction: column; align-items: flex-start; }
    .inline-edit { flex-direction: column; width: 100%; }
    .inline-edit .input-sm { width: 100%; }
}
