/* ============================================
   神秘事务司 - 样式表
   暗紫幽蓝魔法主题
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@400;600;700&family=Noto+Serif+SC:wght@400;600;700&display=swap');

/* === CSS Variables === */
:root {
    --purple: #8b5cf6;
    --purple-light: #a78bfa;
    --purple-dark: #6d28d9;
    --blue: #4a90d9;
    --blue-light: #7cb3f0;
    --cyan: #22d3ee;
    --parchment: #e2e0f0;
    --parchment-dark: #c8c5dc;
    --ink: #1a1030;
    --ink-light: #3d2a60;
    --bg-dark: #0a0815;
    --bg-card: rgba(18, 12, 38, 0.88);
    --bg-input: rgba(139, 92, 246, 0.06);
    --border-subtle: rgba(139, 92, 246, 0.22);
    --border-glow: rgba(139, 92, 246, 0.5);
    --success: #4ade80;
    --error: #f87171;
    --warning: #fbbf24;
    --shadow-purple: 0 0 30px rgba(139, 92, 246, 0.12);
    --font-display: 'Cinzel', 'Noto Serif SC', serif;
    --font-body: 'Noto Serif SC', 'Georgia', serif;
}

/* === Reset & Base === */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-body);
    background: var(--bg-dark);
    color: var(--parchment);
    min-height: 100vh;
    line-height: 1.6;
    overflow-x: hidden;
}

/* === Animated Background === */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background:
        radial-gradient(ellipse at 20% 50%, rgba(100, 40, 180, 0.25) 0%, transparent 60%),
        radial-gradient(ellipse at 80% 20%, rgba(50, 80, 180, 0.2) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 80%, rgba(34, 211, 238, 0.1) 0%, transparent 60%);
    z-index: -1;
    animation: bgShift 20s ease-in-out infinite alternate;
}

@keyframes bgShift {
    0% {
        opacity: 0.8;
    }

    100% {
        opacity: 1;
    }
}

/* Floating particles */
body::after {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image:
        radial-gradient(2px 2px at 10% 20%, rgba(139, 92, 246, 0.3), transparent),
        radial-gradient(2px 2px at 30% 70%, rgba(74, 144, 217, 0.2), transparent),
        radial-gradient(1px 1px at 50% 40%, rgba(34, 211, 238, 0.35), transparent),
        radial-gradient(2px 2px at 70% 60%, rgba(139, 92, 246, 0.15), transparent),
        radial-gradient(1px 1px at 90% 30%, rgba(167, 139, 250, 0.3), transparent);
    z-index: -1;
    animation: sparkle 8s ease-in-out infinite alternate;
}

@keyframes sparkle {
    0% {
        transform: translateY(0);
        opacity: 0.6;
    }

    100% {
        transform: translateY(-15px);
        opacity: 1;
    }
}

/* === Container === */
.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 40px 20px;
}

.container-wide {
    max-width: 1100px;
    margin: 0 auto;
    padding: 40px 20px;
}

/* === Header === */
.page-header {
    text-align: center;
    margin-bottom: 36px;
}

.page-header .header-icon {
    font-size: 3.5rem;
    margin-bottom: 12px;
    display: block;
    animation: iconFloat 3s ease-in-out infinite;
}

@keyframes iconFloat {

    0%,
    100% {
        transform: translateY(0) scale(1);
    }

    50% {
        transform: translateY(-8px) scale(1.05);
    }
}

.page-header h1 {
    font-family: var(--font-display);
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--purple-light);
    text-shadow: 0 0 20px rgba(139, 92, 246, 0.3);
    letter-spacing: 3px;
    margin-bottom: 8px;
}

.page-header .subtitle {
    font-size: 0.85rem;
    color: rgba(226, 224, 240, 0.45);
    letter-spacing: 1px;
}

/* === Card === */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: 16px;
    padding: 32px 28px;
    backdrop-filter: blur(20px);
    box-shadow: var(--shadow-purple);
    position: relative;
    overflow: hidden;
    margin-bottom: 28px;
}

.card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--purple), var(--blue), transparent);
    opacity: 0.6;
}

/* === Tab Switcher === */
.tab-bar {
    display: flex;
    gap: 4px;
    background: rgba(139, 92, 246, 0.06);
    border-radius: 12px;
    padding: 4px;
    margin-bottom: 28px;
    border: 1px solid var(--border-subtle);
}

.tab-btn {
    flex: 1;
    padding: 12px 16px;
    border: none;
    border-radius: 10px;
    background: transparent;
    color: rgba(226, 224, 240, 0.5);
    font-family: var(--font-display);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    letter-spacing: 1px;
}

.tab-btn:hover {
    color: var(--parchment);
    background: rgba(139, 92, 246, 0.08);
}

.tab-btn.active {
    background: linear-gradient(135deg, var(--purple-dark), var(--purple));
    color: #fff;
    box-shadow: 0 2px 12px rgba(139, 92, 246, 0.35);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* === Usage Instructions === */
.usage-hint {
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.08), rgba(74, 144, 217, 0.06));
    border: 1px solid rgba(139, 92, 246, 0.18);
    border-radius: 12px;
    padding: 16px 20px;
    margin-bottom: 24px;
    font-size: 0.82rem;
    color: rgba(226, 224, 240, 0.7);
    line-height: 1.8;
    position: relative;
    overflow: hidden;
}

.usage-hint::before {
    content: '📖';
    font-size: 1.1rem;
    margin-right: 8px;
}

.usage-hint strong {
    color: var(--purple-light);
    font-weight: 600;
}

/* === Data Table === */
.table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: 12px;
    border: 1px solid var(--border-subtle);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
}

.data-table th {
    background: rgba(139, 92, 246, 0.12);
    color: var(--purple-light);
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 0.78rem;
    letter-spacing: 1px;
    text-transform: uppercase;
    padding: 14px 16px;
    text-align: left;
    white-space: nowrap;
    border-bottom: 1px solid var(--border-subtle);
}

.data-table td {
    padding: 12px 16px;
    border-bottom: 1px solid rgba(139, 92, 246, 0.08);
    color: rgba(226, 224, 240, 0.85);
    vertical-align: top;
}

.data-table tbody tr {
    transition: background 0.2s ease;
}

.data-table tbody tr:hover {
    background: rgba(139, 92, 246, 0.06);
}

.data-table tbody tr:last-child td {
    border-bottom: none;
}

/* 激活码特殊样式 */
.code-cell {
    font-family: 'Courier New', 'Consolas', monospace;
    color: var(--cyan);
    font-weight: 600;
    font-size: 0.85rem;
    letter-spacing: 0.5px;
    white-space: nowrap;
}

/* 描述列 */
.desc-cell {
    min-width: 180px;
    max-width: 320px;
    line-height: 1.7;
}

/* 备注列 */
.remark-cell {
    font-size: 0.82rem;
    color: rgba(226, 224, 240, 0.55);
    min-width: 100px;
}

/* === Bulletin Board === */
.bulletin-board {
    background: linear-gradient(145deg, rgba(139, 92, 246, 0.08), rgba(18, 12, 38, 0.6));
    border: 1px solid rgba(139, 92, 246, 0.2);
    border-radius: 16px;
    padding: 28px;
    margin-top: 32px;
    display: flex;
    align-items: center;
    gap: 24px;
    position: relative;
    overflow: hidden;
}

.bulletin-board::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--warning), transparent);
    opacity: 0.5;
}

.bulletin-content {
    flex: 1;
}

.bulletin-title {
    font-family: var(--font-display);
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--warning);
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 8px;
    letter-spacing: 1px;
}

.bulletin-text {
    font-size: 0.82rem;
    line-height: 1.8;
    color: rgba(226, 224, 240, 0.7);
}

.bulletin-text strong {
    color: var(--error);
}

.bulletin-qr {
    flex-shrink: 0;
    width: 120px;
    height: 120px;
    border-radius: 12px;
    border: 2px solid rgba(139, 92, 246, 0.25);
    overflow: hidden;
    background: rgba(255, 255, 255, 0.05);
    display: flex;
    align-items: center;
    justify-content: center;
}

.bulletin-qr img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.bulletin-qr .placeholder {
    font-size: 0.7rem;
    color: rgba(226, 224, 240, 0.3);
    text-align: center;
    padding: 10px;
}

/* === Form Elements === */
.form-group {
    margin-bottom: 22px;
}

.form-group label {
    display: block;
    font-family: var(--font-display);
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--purple-light);
    margin-bottom: 8px;
    letter-spacing: 1px;
    text-transform: uppercase;
}

.form-group .label-hint {
    font-family: var(--font-body);
    font-size: 0.73rem;
    color: rgba(226, 224, 240, 0.4);
    font-weight: 400;
    text-transform: none;
    letter-spacing: 0;
    margin-left: 8px;
}

.form-input,
.form-textarea,
.form-select {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-input);
    border: 1px solid var(--border-subtle);
    border-radius: 10px;
    color: var(--parchment);
    font-family: var(--font-body);
    font-size: 0.92rem;
    transition: all 0.3s ease;
    outline: none;
}

.form-textarea {
    min-height: 100px;
    resize: vertical;
    line-height: 1.6;
}

.form-input::placeholder,
.form-textarea::placeholder {
    color: rgba(226, 224, 240, 0.3);
}

.form-input:focus,
.form-textarea:focus,
.form-select:focus {
    border-color: var(--purple);
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.1), 0 0 15px rgba(139, 92, 246, 0.1);
    background: rgba(139, 92, 246, 0.08);
}

/* === Buttons === */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    border: none;
    border-radius: 10px;
    font-family: var(--font-display);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    letter-spacing: 1px;
    position: relative;
    overflow: hidden;
}

.btn::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: width 0.5s, height 0.5s;
}

.btn:active::after {
    width: 300px;
    height: 300px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--purple-dark), var(--purple));
    color: #fff;
    width: 100%;
    padding: 16px 24px;
    font-size: 1.05rem;
    letter-spacing: 3px;
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--purple), var(--purple-light));
    box-shadow: 0 4px 25px rgba(139, 92, 246, 0.4);
    transform: translateY(-2px);
}

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.btn-secondary {
    background: rgba(139, 92, 246, 0.1);
    color: var(--purple-light);
    border: 1px solid var(--border-subtle);
    padding: 8px 16px;
    font-size: 0.8rem;
}

.btn-secondary:hover {
    background: rgba(139, 92, 246, 0.2);
    border-color: var(--purple);
}

.btn-icon {
    width: 36px;
    height: 36px;
    padding: 0;
    border-radius: 8px;
    font-size: 1.1rem;
    min-width: 36px;
}

.btn-danger {
    background: rgba(248, 113, 113, 0.15);
    color: var(--error);
    border: 1px solid rgba(248, 113, 113, 0.3);
}

.btn-danger:hover {
    background: rgba(248, 113, 113, 0.25);
}

.btn-success {
    background: rgba(74, 222, 128, 0.15);
    color: var(--success);
    border: 1px solid rgba(74, 222, 128, 0.3);
}

.btn-success:hover {
    background: rgba(74, 222, 128, 0.25);
}

.btn-add {
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.15), rgba(74, 144, 217, 0.15));
    color: var(--purple-light);
    border: 1px dashed var(--border-subtle);
    width: 100%;
    padding: 14px;
    font-size: 0.88rem;
    margin-top: 16px;
    letter-spacing: 2px;
}

.btn-add:hover {
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.25), rgba(74, 144, 217, 0.25));
    border-color: var(--purple);
    border-style: solid;
}

/* === Admin Action Buttons === */
.action-buttons {
    display: flex;
    gap: 6px;
    justify-content: center;
}

.btn-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 8px;
    border: 1px solid var(--border-subtle);
    background: transparent;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.95rem;
    padding: 0;
}

.btn-action:hover {
    background: rgba(139, 92, 246, 0.15);
    border-color: var(--purple);
    transform: scale(1.1);
}

.btn-action.btn-delete:hover {
    background: rgba(248, 113, 113, 0.15);
    border-color: var(--error);
}

/* === Login Card === */
.login-card {
    max-width: 400px;
    margin: 0 auto;
}

/* === File Upload === */
.file-upload-area {
    border: 2px dashed var(--border-subtle);
    border-radius: 12px;
    padding: 28px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.file-upload-area:hover {
    border-color: var(--purple);
    background: rgba(139, 92, 246, 0.05);
}

.file-upload-area.has-file {
    border-color: var(--success);
    background: rgba(74, 222, 128, 0.05);
}

.file-upload-area input[type="file"] {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

.file-upload-icon {
    font-size: 2rem;
    margin-bottom: 8px;
    display: block;
}

.file-upload-text {
    font-size: 0.82rem;
    color: rgba(226, 224, 240, 0.5);
}

.file-upload-text .highlight {
    color: var(--purple-light);
    font-weight: 600;
}

/* === QR Preview (Admin) === */
.qr-management {
    margin-top: 32px;
    padding-top: 28px;
    border-top: 1px solid var(--border-subtle);
}

.qr-management-title {
    font-family: var(--font-display);
    font-size: 1rem;
    color: var(--purple-light);
    margin-bottom: 16px;
    letter-spacing: 1px;
}

.qr-preview-area {
    display: flex;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
}

.qr-preview {
    width: 140px;
    height: 140px;
    border-radius: 12px;
    border: 2px solid var(--border-subtle);
    overflow: hidden;
    background: rgba(255, 255, 255, 0.05);
    display: flex;
    align-items: center;
    justify-content: center;
}

.qr-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.qr-upload-controls {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* === Modal === */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(10, 8, 21, 0.85);
    backdrop-filter: blur(8px);
    z-index: 1000;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.modal-overlay.show {
    display: flex;
    animation: fadeIn 0.2s ease;
}

.modal-card {
    background: rgba(18, 12, 38, 0.95);
    border: 1px solid var(--border-subtle);
    border-radius: 16px;
    padding: 28px;
    max-width: 520px;
    width: 100%;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5), 0 0 40px rgba(139, 92, 246, 0.1);
    position: relative;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--purple), var(--blue), transparent);
    opacity: 0.6;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.modal-header h3 {
    font-family: var(--font-display);
    font-size: 1.05rem;
    color: var(--purple-light);
    letter-spacing: 1px;
}

.modal-close {
    background: transparent;
    border: 1px solid var(--border-subtle);
    color: var(--parchment);
    cursor: pointer;
    font-size: 1rem;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.modal-close:hover {
    background: rgba(248, 113, 113, 0.15);
    border-color: var(--error);
}

.modal-body-text {
    font-size: 0.88rem;
    color: rgba(226, 224, 240, 0.7);
    line-height: 1.7;
}

.modal-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    margin-top: 24px;
}

/* === Loading === */
.loading-overlay {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 60px 20px;
    color: rgba(226, 224, 240, 0.5);
    font-size: 0.88rem;
}

.spinner {
    width: 24px;
    height: 24px;
    border: 3px solid rgba(139, 92, 246, 0.2);
    border-top-color: var(--purple);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    display: inline-block;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* === Empty State === */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: rgba(226, 224, 240, 0.4);
}

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

/* === Toast === */
.toast {
    position: fixed;
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    padding: 12px 28px;
    border-radius: 12px;
    font-size: 0.85rem;
    font-weight: 600;
    z-index: 9999;
    opacity: 0;
    transition: all 0.3s ease;
    pointer-events: none;
    white-space: nowrap;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.toast.success {
    background: rgba(74, 222, 128, 0.15);
    color: var(--success);
    border: 1px solid rgba(74, 222, 128, 0.3);
    backdrop-filter: blur(10px);
}

.toast.error {
    background: rgba(248, 113, 113, 0.15);
    color: var(--error);
    border: 1px solid rgba(248, 113, 113, 0.3);
    backdrop-filter: blur(10px);
}

/* === Footer === */
.page-footer {
    text-align: center;
    padding: 40px 20px 20px;
    font-size: 0.72rem;
    color: rgba(226, 224, 240, 0.2);
    letter-spacing: 1px;
}

/* === Section Title === */
.section-title {
    font-family: var(--font-display);
    font-size: 1.1rem;
    color: var(--purple-light);
    margin-bottom: 20px;
    letter-spacing: 1px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.section-title::after {
    content: '';
    flex: 1;
    height: 1px;
    background: linear-gradient(90deg, var(--border-subtle), transparent);
}

/* === Admin Stats Row === */
.stats-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 12px;
    margin-bottom: 28px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: 12px;
    padding: 18px;
    text-align: center;
    backdrop-filter: blur(10px);
}

.stat-value {
    font-family: var(--font-display);
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--purple-light);
    margin-bottom: 4px;
}

.stat-label {
    font-size: 0.72rem;
    color: rgba(226, 224, 240, 0.4);
    letter-spacing: 1px;
    text-transform: uppercase;
}

/* === Admin Search Bar === */
.search-bar {
    display: flex;
    gap: 12px;
    margin-bottom: 24px;
    flex-wrap: wrap;
    align-items: center;
}

.search-bar .form-input {
    flex: 1;
    min-width: 200px;
}

/* === Responsive === */
@media (max-width: 640px) {
    .container {
        padding: 24px 14px;
    }

    .card {
        padding: 24px 18px;
    }

    .page-header h1 {
        font-size: 1.4rem;
        letter-spacing: 2px;
    }

    .tab-btn {
        font-size: 0.78rem;
        padding: 10px 12px;
    }

    .data-table th,
    .data-table td {
        padding: 10px 12px;
        font-size: 0.82rem;
    }

    .bulletin-board {
        flex-direction: column;
        text-align: center;
        padding: 24px 20px;
    }

    .bulletin-qr {
        width: 140px;
        height: 140px;
    }

    .usage-hint {
        font-size: 0.78rem;
        padding: 14px 16px;
    }

    .modal-card {
        padding: 22px 18px;
    }

    .stats-row {
        grid-template-columns: repeat(2, 1fr);
    }

    .search-bar {
        flex-direction: column;
    }

    .search-bar .form-input {
        min-width: auto;
    }
}