/* ====================================================
   六哥荣耀WIKI · 管理后台专用样式
   ==================================================== */

:root {
    --bg: #121212;
    --card-bg: #1e3a2f;
    --card-bg-hover: #284a3c;
    --text-main: #e0e0e0;
    --text-highlight: #81c784;
    --text-secondary: #99aabb;
    --border-color: #3d725f;
    --radius: 6px;
    --shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    --special-color: #facc15;
    --sidebar-width: 45%; /* 40%~50% 区间 */
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
}

body {
    background: var(--bg);
    color: var(--text-main);
    padding: 20px;
    overflow-x: auto;
    min-height: 100vh;
}

.admin-container {
    max-width: 1400px;
    margin: 0 auto;
}

/* ========== 顶部栏 ========== */
.admin-topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    background: var(--card-bg);
    border-radius: var(--radius);
    border-bottom: 2px solid var(--border-color);
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 12px;
}
.admin-left {
    display: flex;
    align-items: center;
    gap: 12px;
}
.admin-title {
    font-size: 1.4rem;
    color: var(--text-highlight);
    font-weight: bold;
}
.admin-user-info {
    display: flex;
    align-items: baseline;
    gap: 12px;
    flex-wrap: wrap;
}
#adminUserDisplay {
    color: var(--text-highlight);
    font-weight: bold;
    font-size: 0.95rem;
}
.logout-btn {
    background: rgba(248, 113, 113, 0.2);
    color: #f87171;
    border: 1px solid #f87171;
    padding: 6px 14px;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 0.85rem;
    transition: 0.2s;
}
.logout-btn:hover {
    background: rgba(248, 113, 113, 0.4);
}
.hamburger-btn {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-main);
    padding: 6px 12px;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 1.2rem;
    transition: 0.2s;
}
.hamburger-btn:hover {
    background: var(--card-bg-hover);
}

/* ========== ★ 从左向右滑出的侧栏菜单 ★ ========== */
.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    z-index: 9998;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}
.sidebar-overlay.active {
    opacity: 1;
    visibility: visible;
}

.sidebar-menu {
    position: fixed;
    top: 0;
    left: 0; /* 从左边滑出 */
    width: var(--sidebar-width);
    min-width: 280px;
    max-width: 500px;
    height: 100%;
    background: var(--card-bg);
    box-shadow: 8px 0 30px rgba(0, 0, 0, 0.6); /* 阴影在右侧 */
    z-index: 9999;
    transform: translateX(-100%); /* 初始完全隐藏到左边 */
    transition: transform 0.35s cubic-bezier(0.22, 1, 0.36, 1);
    padding: 20px 0;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}
.sidebar-menu.open {
    transform: translateX(0); /* 滑出到可见 */
}

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px 16px 20px;
    border-bottom: 2px solid var(--border-color);
    margin-bottom: 12px;
    flex-shrink: 0;
}
.sidebar-header span {
    font-size: 1.2rem;
    color: var(--text-highlight);
    font-weight: bold;
}
.sidebar-close {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 1.6rem;
    cursor: pointer;
    padding: 0 6px;
    line-height: 1;
    transition: 0.2s;
}
.sidebar-close:hover {
    color: #f87171;
    transform: rotate(90deg);
}

.sidebar-menu ul {
    list-style: none;
    padding: 0 12px;
    margin: 0;
    flex: 1;
}
.sidebar-menu ul li {
    padding: 12px 16px;
    cursor: pointer;
    border-radius: var(--radius);
    transition: 0.2s;
    font-size: 0.95rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 2px;
}
.sidebar-menu ul li:hover {
    background: var(--card-bg-hover);
    color: var(--text-main);
}
.sidebar-menu ul li.active {
    background: var(--text-highlight);
    color: var(--bg);
    font-weight: bold;
}
.sidebar-menu ul li .icon {
    font-size: 1.1rem;
    width: 24px;
    text-align: center;
    flex-shrink: 0;
}
.sidebar-footer {
    padding: 16px 20px 8px 20px;
    border-top: 1px solid var(--border-color);
    color: var(--text-secondary);
    font-size: 0.75rem;
    text-align: center;
    flex-shrink: 0;
    margin-top: 8px;
}

/* ========== 面板 ========== */
.panel {
    display: none;
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 20px;
    margin-top: 10px;
    box-shadow: var(--shadow);
}
.panel.active-panel {
    display: block;
}

/* ========== 工具栏 ========== */
.toolbar {
    display: flex;
    justify-content: space-between;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}
.search-input {
    padding: 8px 12px;
    background: #2d3748;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    color: var(--text-main);
    width: 250px;
    outline: none;
}
.search-input:focus {
    border-color: var(--text-highlight);
}
.add-btn {
    background: var(--text-highlight);
    color: var(--bg);
    border: none;
    padding: 8px 16px;
    border-radius: var(--radius);
    cursor: pointer;
    font-weight: bold;
    transition: 0.2s;
}
.add-btn:hover {
    transform: translateY(-2px);
}

/* ========== 表格 ========== */
.table-container {
    overflow-x: auto;
    margin-top: 10px;
}
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
    min-width: 600px;
}
.data-table th,
.data-table td {
    border: 1px solid var(--border-color);
    padding: 8px 10px;
    text-align: left;
    vertical-align: middle;
}
.data-table th {
    background: #2a3a35;
    color: var(--text-highlight);
    font-weight: 600;
    position: sticky;
    top: 0;
    z-index: 5;
}
.data-table tr:hover {
    background: rgba(129, 199, 132, 0.1);
}
.table-img {
    width: 40px;
    height: 40px;
    object-fit: cover;
    border-radius: 4px;
}
.action-buttons {
    white-space: nowrap;
}
.edit-btn,
.delete-btn {
    padding: 4px 10px;
    margin: 0 4px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.75rem;
    transition: 0.2s;
}
.edit-btn {
    background: #4a6a8a;
    color: white;
}
.delete-btn {
    background: #c41e3a;
    color: white;
}
.edit-btn:hover,
.delete-btn:hover {
    opacity: 0.8;
}
.empty-data {
    text-align: center;
    padding: 40px;
    color: var(--text-secondary);
}
.loading {
    text-align: center;
    padding: 30px;
    color: var(--text-secondary);
}

/* ========== 日志过滤器 ========== */
.log-filters {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
    flex-wrap: wrap;
}
.log-filters input,
.log-filters select {
    background: #2d3748;
    border: 1px solid var(--border-color);
    color: var(--text-main);
    padding: 6px 12px;
    border-radius: var(--radius);
}
.log-table {
    max-height: 500px;
    overflow-y: auto;
}
.log-table .data-table th {
    position: sticky;
    top: 0;
    background: #2a3a35;
    z-index: 10;
}
.clear-logs-btn {
    background: #c41e3a;
    color: white;
    border: none;
    padding: 6px 14px;
    border-radius: var(--radius);
    cursor: pointer;
    margin-left: 10px;
}
.clear-logs-btn:hover {
    background: #a01830;
}

/* ========== 杂项管理 ========== */
.misc-section {
    margin-bottom: 30px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 16px;
    padding: 16px;
}
.misc-title {
    font-size: 1.2rem;
    margin-bottom: 16px;
    color: var(--text-highlight);
    border-left: 4px solid var(--special-color);
    padding-left: 12px;
}
.asset-control {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    background: rgba(0, 0, 0, 0.2);
    padding: 15px;
    border-radius: 12px;
    margin: 10px 0;
    align-items: center;
}
.asset-item {
    display: flex;
    align-items: center;
    gap: 8px;
}
.asset-item img {
    width: 24px;
    height: 24px;
    vertical-align: middle;
    margin-right: 6px;
    border-radius: 4px;
}
.asset-item input[type="number"] {
    width: 100px;
    padding: 4px 8px;
    background: #2d3748;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    color: var(--text-main);
}
.save-asset-btn,
.save-frames-btn {
    background: var(--text-highlight);
    border: none;
    padding: 8px 20px;
    border-radius: 30px;
    color: #1a132e;
    font-weight: bold;
    cursor: pointer;
    margin-top: 12px;
    transition: 0.2s;
}
.save-asset-btn:hover,
.save-frames-btn:hover {
    transform: scale(1.02);
    filter: brightness(1.1);
}
.frames-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin: 12px 0;
}
.frame-checkbox-item {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 12px;
    padding: 8px 12px;
}
.btn-sm {
    padding: 4px 12px;
    font-size: 0.8rem;
}

/* ========== 表单 ========== */
.form-field {
    margin-bottom: 12px;
}
.form-field label {
    display: block;
    margin-bottom: 4px;
    font-size: 0.9rem;
    color: var(--text-highlight);
}
.form-field input,
.form-field select,
.form-field textarea {
    width: 100%;
    padding: 8px 12px;
    background: #2d3748;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    color: var(--text-main);
    outline: none;
}
.form-field input:focus,
.form-field select:focus,
.form-field textarea:focus {
    border-color: var(--text-highlight);
}
.form-field textarea {
    resize: vertical;
}
.form-field input[type="checkbox"] {
    width: auto;
    margin-top: 6px;
    transform: scale(1.2);
}

/* ========== 模态框 ========== */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10000;
    display: none;
    align-items: center;
    justify-content: center;
}
.modal.show {
    display: flex;
}
.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(4px);
    cursor: pointer;
}
.modal-content {
    position: relative;
    background: var(--bg);
    border-radius: 12px;
    width: 90%;
    max-width: 600px;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow);
    animation: modalSlideIn 0.3s ease;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
}
@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}
.modal-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--card-bg);
    border-radius: 12px 12px 0 0;
    flex-shrink: 0;
}
.modal-header h3 {
    color: var(--text-highlight);
    font-size: 1.3rem;
}
.modal-close {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 1.2rem;
    cursor: pointer;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    transition: 0.2s;
}
.modal-close:hover {
    background: rgba(248, 113, 113, 0.2);
    color: #f87171;
    transform: rotate(90deg);
}
.modal-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}
.form-buttons {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 20px;
    padding-top: 15px;
    border-top: 1px solid var(--border-color);
}
.cancel-btn {
    background: transparent;
    border: 1px solid var(--border-color);
    padding: 8px 20px;
    border-radius: var(--radius);
    color: var(--text-main);
    cursor: pointer;
}
.save-btn {
    background: var(--text-highlight);
    border: none;
    padding: 8px 20px;
    border-radius: var(--radius);
    color: var(--bg);
    font-weight: bold;
    cursor: pointer;
}
.save-btn:hover {
    filter: brightness(1.1);
}

/* ========== 通知 ========== */
.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    background: var(--card-bg);
    padding: 12px 20px;
    border-radius: var(--radius);
    z-index: 10001;
    transition: all 0.3s ease;
    transform: translateY(-100px);
    opacity: 0;
    box-shadow: var(--shadow);
    border-left: 4px solid;
    display: flex;
    align-items: center;
    gap: 8px;
    max-width: 90%;
}
.notification.show {
    transform: translateY(0);
    opacity: 1;
}
.notification.success {
    border-left-color: #4ade80;
    color: #4ade80;
}
.notification.error {
    border-left-color: #f87171;
    color: #f87171;
}
.notification.info {
    border-left-color: #3b82f6;
    color: #3b82f6;
}

/* ========== 响应式 ========== */
@media (max-width: 768px) {
    body {
        padding: 10px;
    }
    .admin-topbar {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 8px;
    }
    .admin-title {
        font-size: 1.1rem;
    }
    .admin-user-info {
        gap: 8px;
    }
    #adminUserDisplay {
        font-size: 0.8rem;
    }
    .sidebar-menu {
        width: 90%;
        min-width: 0;
        max-width: 90%;
    }
    .toolbar {
        flex-direction: column;
        align-items: stretch;
    }
    .search-input {
        width: 100%;
    }
    .data-table th,
    .data-table td {
        padding: 6px;
        font-size: 0.7rem;
    }
    .table-img {
        width: 30px;
        height: 30px;
    }
    .modal-content {
        width: 95%;
        max-height: 95vh;
    }
    .asset-control {
        flex-direction: column;
        align-items: stretch;
    }
    .asset-item {
        flex-wrap: wrap;
    }
    .log-filters {
        flex-direction: column;
    }
    .log-filters input,
    .log-filters select {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .admin-topbar {
        flex-direction: column;
        align-items: stretch;
    }
    .admin-user-info {
        justify-content: flex-end;
    }
    .hamburger-btn {
        align-self: flex-start;
    }
    .sidebar-menu ul li {
        font-size: 0.85rem;
        padding: 10px 14px;
    }
}