/* ============================================
   电玩选游管理系统 - 后台统一样式
   ============================================ */

/* Reset & Base */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Helvetica, Arial, sans-serif;
    font-size: 14px;
    line-height: 1.6;
    color: #333;
    background: #f0f2f5;
}

a {
    color: #1890ff;
    text-decoration: none;
}

a:hover {
    color: #40a9ff;
}

/* ============================================
   Layout
   ============================================ */
.admin-layout {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 220px;
    background: #001529;
    color: #fff;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
}

.sidebar-logo {
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 16px;
    background: rgba(255, 255, 255, 0.05);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-logo h1 {
    font-size: 16px;
    font-weight: 600;
    color: #fff;
    white-space: nowrap;
    letter-spacing: 1px;
}

.sidebar-nav {
    flex: 1;
    padding: 8px 0;
    overflow-y: auto;
}

.nav-item {
    display: flex;
    align-items: center;
    padding: 12px 24px;
    color: rgba(255, 255, 255, 0.65);
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
    border-left: 3px solid transparent;
    text-decoration: none;
}

.nav-item:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.08);
}

.nav-item.active {
    color: #fff;
    background: #1890ff;
    border-left-color: #fff;
}

.nav-item .nav-icon {
    width: 20px;
    margin-right: 10px;
    text-align: center;
    font-style: normal;
}

/* Main Area */
.main-area {
    flex: 1;
    margin-left: 220px;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Top Header */
.top-header {
    height: 64px;
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
    position: sticky;
    top: 0;
    z-index: 99;
}

.top-header .page-title {
    font-size: 18px;
    font-weight: 600;
    color: #333;
}

.top-header .header-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.top-header .admin-name {
    color: #666;
    font-size: 14px;
}

/* Content */
.content {
    flex: 1;
    padding: 24px;
}

/* ============================================
   Login Page
   ============================================ */
.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.login-box {
    width: 400px;
    background: #fff;
    border-radius: 8px;
    padding: 40px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
}

.login-box h2 {
    text-align: center;
    margin-bottom: 8px;
    font-size: 24px;
    color: #333;
}

.login-box .login-subtitle {
    text-align: center;
    color: #999;
    margin-bottom: 32px;
    font-size: 14px;
}

/* ============================================
   Form Elements
   ============================================ */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-size: 14px;
    color: #555;
    font-weight: 500;
}

.form-control {
    width: 100%;
    height: 40px;
    padding: 6px 12px;
    border: 1px solid #d9d9d9;
    border-radius: 4px;
    font-size: 14px;
    color: #333;
    background: #fff;
    transition: border-color 0.2s;
    outline: none;
}

.form-control:focus {
    border-color: #1890ff;
    box-shadow: 0 0 0 2px rgba(24, 144, 255, 0.15);
}

.form-control::placeholder {
    color: #bfbfbf;
}

select.form-control {
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M6 8L1 3h10z' fill='%23999'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 32px;
}

textarea.form-control {
    height: auto;
    min-height: 80px;
    resize: vertical;
    padding: 8px 12px;
}

/* ============================================
   Buttons
   ============================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 36px;
    padding: 0 16px;
    font-size: 14px;
    line-height: 1;
    border: 1px solid #d9d9d9;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    background: #fff;
    color: #333;
    text-align: center;
    vertical-align: middle;
    user-select: none;
}

.btn:hover {
    border-color: #1890ff;
    color: #1890ff;
}

.btn-primary {
    background: #1890ff;
    border-color: #1890ff;
    color: #fff;
}

.btn-primary:hover {
    background: #40a9ff;
    border-color: #40a9ff;
    color: #fff;
}

.btn-danger {
    background: #ff4d4f;
    border-color: #ff4d4f;
    color: #fff;
}

.btn-danger:hover {
    background: #ff7875;
    border-color: #ff7875;
    color: #fff;
}

.btn-success {
    background: #52c41a;
    border-color: #52c41a;
    color: #fff;
}

.btn-success:hover {
    background: #73d13d;
    border-color: #73d13d;
    color: #fff;
}

.btn-sm {
    height: 28px;
    padding: 0 10px;
    font-size: 12px;
}

.btn-block {
    width: 100%;
}

.btn[disabled] {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ============================================
   Cards
   ============================================ */
.card {
    background: #fff;
    border-radius: 6px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    padding: 24px;
    margin-bottom: 24px;
}

.card-title {
    font-size: 16px;
    font-weight: 600;
    color: #333;
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 1px solid #f0f0f0;
}

/* Stat Cards */
.stat-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin-bottom: 24px;
}

.stat-card {
    background: #fff;
    border-radius: 6px;
    padding: 24px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    display: flex;
    align-items: center;
    gap: 16px;
}

.stat-icon {
    width: 56px;
    height: 56px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    color: #fff;
    flex-shrink: 0;
}

.stat-icon.blue { background: #1890ff; }
.stat-icon.green { background: #52c41a; }
.stat-icon.orange { background: #fa8c16; }
.stat-icon.purple { background: #722ed1; }

.stat-info .stat-value {
    font-size: 28px;
    font-weight: 700;
    color: #333;
    line-height: 1.2;
}

.stat-info .stat-label {
    font-size: 14px;
    color: #999;
    margin-top: 4px;
}

/* ============================================
   Tables
   ============================================ */
.table-wrapper {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.data-table th,
.data-table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid #f0f0f0;
    vertical-align: middle;
}

.data-table th {
    background: #fafafa;
    font-weight: 600;
    color: #555;
    white-space: nowrap;
}

.data-table tbody tr:hover {
    background: #f5f7fa;
}

.data-table .actions {
    display: flex;
    gap: 8px;
    white-space: nowrap;
}

/* Status Tags */
.tag {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 22px;
    padding: 0 8px;
    font-size: 12px;
    line-height: 1;
    border-radius: 3px;
    white-space: nowrap;
}

.tag-success {
    background: #f6ffed;
    color: #52c41a;
    border: 1px solid #b7eb8f;
}

.tag-danger {
    background: #fff2f0;
    color: #ff4d4f;
    border: 1px solid #ffa39e;
}

.tag-info {
    background: #e6f7ff;
    color: #1890ff;
    border: 1px solid #91d5ff;
}

/* ============================================
   Toolbar
   ============================================ */
.toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    flex-wrap: wrap;
    gap: 12px;
}

.toolbar-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.search-box {
    position: relative;
}

.search-box .form-control {
    width: 240px;
    padding-left: 32px;
}

.search-box .search-icon {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: #bfbfbf;
    font-style: normal;
}

/* ============================================
   Modal
   ============================================ */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal-overlay.active {
    display: flex;
}

.modal {
    background: #fff;
    border-radius: 8px;
    width: 520px;
    max-width: 90vw;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 6px 30px rgba(0, 0, 0, 0.2);
    animation: modalIn 0.2s ease;
}

@keyframes modalIn {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    border-bottom: 1px solid #f0f0f0;
}

.modal-header h3 {
    font-size: 16px;
    font-weight: 600;
    color: #333;
}

.modal-close {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: none;
    font-size: 18px;
    color: #999;
    cursor: pointer;
    border-radius: 4px;
    line-height: 1;
}

.modal-close:hover {
    background: #f5f5f5;
    color: #333;
}

.modal-body {
    padding: 24px;
    overflow-y: auto;
    flex: 1;
}

.modal-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    padding: 12px 24px;
    border-top: 1px solid #f0f0f0;
}

/* ============================================
   Alert / Message
   ============================================ */
.alert {
    padding: 10px 16px;
    border-radius: 4px;
    margin-bottom: 16px;
    font-size: 14px;
    line-height: 1.6;
}

.alert-error {
    background: #fff2f0;
    border: 1px solid #ffa39e;
    color: #ff4d4f;
}

.alert-success {
    background: #f6ffed;
    border: 1px solid #b7eb8f;
    color: #52c41a;
}

/* Toast Notification */
.toast-container {
    position: fixed;
    top: 24px;
    right: 24px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    padding: 12px 20px;
    border-radius: 4px;
    background: #fff;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
    font-size: 14px;
    color: #333;
    animation: toastIn 0.3s ease;
    max-width: 360px;
}

.toast-success {
    border-left: 4px solid #52c41a;
}

.toast-error {
    border-left: 4px solid #ff4d4f;
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateX(40px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* ============================================
   Link Box (for token copy)
   ============================================ */
.link-box {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 12px;
}

.link-box .form-control {
    flex: 1;
    background: #f5f5f5;
    color: #666;
    font-size: 13px;
}

/* ============================================
   Confirm Dialog
   ============================================ */
.confirm-content {
    text-align: center;
    padding: 16px 0;
}

.confirm-content .confirm-icon {
    font-size: 48px;
    color: #faad14;
    margin-bottom: 16px;
}

.confirm-content .confirm-text {
    font-size: 16px;
    color: #333;
    margin-bottom: 4px;
}

.confirm-content .confirm-sub {
    font-size: 14px;
    color: #999;
}

/* ============================================
   Capacity Bar
   ============================================ */
.capacity-bar {
    display: flex;
    align-items: center;
    gap: 8px;
}

.capacity-bar .bar-track {
    flex: 1;
    height: 8px;
    background: #f0f0f0;
    border-radius: 4px;
    overflow: hidden;
    min-width: 80px;
}

.capacity-bar .bar-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.3s;
}

.bar-fill.normal { background: #52c41a; }
.bar-fill.warning { background: #faad14; }
.bar-fill.danger { background: #ff4d4f; }

.capacity-bar .bar-text {
    font-size: 12px;
    color: #666;
    white-space: nowrap;
}

/* ============================================
   Pagination
   ============================================ */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    margin-top: 20px;
}

.pagination .page-btn {
    min-width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #d9d9d9;
    border-radius: 4px;
    background: #fff;
    color: #333;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
    padding: 0 6px;
}

.pagination .page-btn:hover {
    border-color: #1890ff;
    color: #1890ff;
}

.pagination .page-btn.active {
    background: #1890ff;
    border-color: #1890ff;
    color: #fff;
}

.pagination .page-btn[disabled] {
    opacity: 0.4;
    cursor: not-allowed;
}

/* ============================================
   Hamburger Button
   ============================================ */
.hamburger-btn {
    display: none;
    width: 40px;
    height: 40px;
    border: none;
    background: none;
    cursor: pointer;
    padding: 8px;
    margin-right: 8px;
    border-radius: 4px;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.hamburger-btn:hover {
    background: #f5f5f5;
}

.hamburger-btn .hamburger-icon {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 5px;
    width: 22px;
}

.hamburger-btn .hamburger-icon span {
    display: block;
    width: 100%;
    height: 2px;
    background: #333;
    border-radius: 1px;
    transition: all 0.3s;
}

/* ============================================
   Sidebar Overlay Backdrop
   ============================================ */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 99;
}

.sidebar-overlay.active {
    display: block;
}

/* ============================================
   Responsive
   ============================================ */
@media (max-width: 768px) {
    /* --- Hamburger Button --- */
    .hamburger-btn {
        display: flex;
    }

    /* --- Sidebar: 默认隐藏，点击覆盖显示 --- */
    .sidebar {
        width: 220px;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        z-index: 200;
    }

    .sidebar.mobile-open {
        transform: translateX(0);
    }

    .sidebar-logo h1 {
        display: block;
    }

    .nav-item {
        padding: 12px 24px;
        justify-content: flex-start;
    }

    .nav-item .nav-icon {
        margin-right: 10px;
    }

    .nav-item span:not(.nav-icon) {
        display: inline;
    }

    /* --- Main Area --- */
    .main-area {
        margin-left: 0;
    }

    .top-header {
        padding: 0 12px;
    }

    .top-header .page-title {
        font-size: 16px;
    }

    /* --- Content --- */
    .content {
        padding: 12px;
    }

    .card {
        padding: 16px;
        margin-bottom: 16px;
    }

    /* --- Stat Cards: 两列布局 --- */
    .stat-cards {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }

    .stat-card {
        padding: 16px;
        gap: 12px;
    }

    .stat-icon {
        width: 44px;
        height: 44px;
        font-size: 20px;
        border-radius: 10px;
    }

    .stat-info .stat-value {
        font-size: 22px;
    }

    /* --- Toolbar --- */
    .toolbar {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    .toolbar-left {
        flex-direction: column;
        gap: 8px;
    }

    .search-box .form-control {
        width: 100%;
    }

    /* --- Buttons: 最小44px点击区域 --- */
    .btn {
        min-height: 44px;
    }

    .btn-sm {
        min-height: 36px;
        padding: 0 12px;
    }

    /* --- Form Controls --- */
    .form-control {
        width: 100%;
        min-height: 44px;
    }

    .search-box .form-control {
        width: 100%;
    }

    /* --- Modal: 宽度95% --- */
    .modal {
        width: 95% !important;
        max-width: 95vw;
        max-height: 90vh;
    }

    .modal-body {
        padding: 16px;
    }

    .modal-header {
        padding: 12px 16px;
    }

    .modal-footer {
        padding: 10px 16px;
    }

    /* --- Table wrapper: 确保横向滚动 --- */
    .table-wrapper {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin: 0 -16px;
        padding: 0 16px;
    }

    .data-table th,
    .data-table td {
        padding: 10px 12px;
        font-size: 13px;
    }

    /* --- Login --- */
    .login-box {
        width: 95%;
        padding: 24px;
    }

    /* --- Toast --- */
    .toast-container {
        right: 12px;
        left: 12px;
        top: 12px;
    }

    .toast {
        max-width: 100%;
    }

    /* --- Pagination --- */
    .pagination {
        flex-wrap: wrap;
    }

    .pagination .page-btn {
        min-width: 36px;
        height: 36px;
    }
}

/* 超小屏幕 (≤480px): 统计卡片改单列 */
@media (max-width: 480px) {
    .stat-cards {
        grid-template-columns: 1fr;
    }

    .top-header .admin-name {
        font-size: 12px;
    }

    .card {
        padding: 12px;
    }

    .content {
        padding: 8px;
    }
}

/* ============================================
   Utility
   ============================================ */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: #999; }
.text-danger { color: #ff4d4f; }
.text-success { color: #52c41a; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.gap-8 { gap: 8px; }
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }

/* ============================================
   Image Viewer Overlay
   ============================================ */
.image-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 2000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.image-overlay.active {
    display: flex;
}

.image-overlay__container {
    position: relative;
    background: #fff;
    border-radius: 12px;
    padding: 12px;
    max-width: 90vw;
    max-height: 85vh;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    animation: imageOverlayIn 0.2s ease;
}

@keyframes imageOverlayIn {
    from {
        opacity: 0;
        transform: scale(0.92);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.image-overlay__img {
    max-width: 100%;
    max-height: calc(85vh - 24px);
    border-radius: 6px;
    object-fit: contain;
    display: block;
}

.image-overlay__close {
    position: absolute;
    top: -14px;
    right: -14px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: #fff;
    color: #555;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    transition: background 0.2s, color 0.2s;
    line-height: 1;
}

.image-overlay__close:hover {
    background: #333;
    color: #fff;
}

/* Game Thumbnail */
.game-thumb {
    width: 36px;
    height: 36px;
    object-fit: cover;
    border-radius: 6px;
    border: 1px solid #e5e7eb;
    vertical-align: middle;
}

.cover-placeholder {
    font-size: 16px;
    color: #9ca3af;
    vertical-align: middle;
}
