/* ========== 后台管理全局样式 ========== */

.admin-body {
    margin: 0;
    padding: 0;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #f0f2f5;
    color: #333;
    min-height: 100vh;
}

/* 整体布局：左侧导航 + 右侧内容 */
.admin-layout {
    display: flex;
    min-height: 100vh;
}

/* ========== 侧边栏 ========== */
.admin-sidebar {
    width: 220px;
    background: #1a1a2e;
    color: #fff;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    overflow-x: hidden;
    transition: width 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* 侧边栏收起状态 */
.admin-sidebar.collapsed {
    width: 60px;
}

.admin-sidebar-header {
    padding: 1.5rem 1.2rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    white-space: nowrap;
    overflow: hidden;
}

.admin-logo {
    color: #fff;
    text-decoration: none;
    font-size: 1.2rem;
    font-weight: 700;
    letter-spacing: 1px;
    white-space: nowrap;
}

.admin-logo:hover {
    color: #667eea;
}

/* 收起时隐藏 logo 文字 */
.admin-sidebar.collapsed .admin-sidebar-header {
    padding: 1.5rem 0.6rem;
    text-align: center;
}

.admin-sidebar.collapsed .admin-logo {
    font-size: 0;
    letter-spacing: 0;
}

.admin-sidebar.collapsed .admin-logo::before {
    content: "B";
    font-size: 1.3rem;
    font-weight: 700;
    letter-spacing: 0;
}

/* 侧边导航 */
.admin-sidebar-nav {
    display: flex;
    flex-direction: column;
    padding: 0.8rem 0;
    flex: 1;
    position: sticky;
    top: 0;
}

.admin-nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0.7rem 1.2rem;
    color: rgba(255, 255, 255, 0.65);
    text-decoration: none;
    font-size: 0.9rem;
    transition: all 0.2s;
    border-left: 3px solid transparent;
    white-space: nowrap;
    position: relative;
}

.admin-nav-item:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.06);
}

.admin-nav-item.active {
    color: #fff;
    background: rgba(102, 126, 234, 0.15);
    border-left-color: #667eea;
}

.admin-nav-item svg {
    flex-shrink: 0;
    opacity: 0.8;
}

.admin-nav-item.active svg {
    opacity: 1;
}

/* 导航文字 */
.admin-nav-item .nav-text {
    transition: opacity 0.2s, width 0.25s;
    overflow: hidden;
}

/* 收起状态：隐藏文字，居中图标 */
.admin-sidebar.collapsed .admin-nav-item {
    padding: 0.7rem 0;
    justify-content: center;
    border-left: 3px solid transparent;
    gap: 0;
}

.admin-sidebar.collapsed .admin-nav-item .nav-text {
    width: 0;
    opacity: 0;
    overflow: hidden;
}

/* 收起状态悬浮 Tooltip */
.admin-sidebar.collapsed .admin-nav-item::after {
    content: attr(data-title);
    position: absolute;
    left: 100%;
    top: 50%;
    transform: translateY(-50%);
    background: #333;
    color: #fff;
    padding: 0.35rem 0.75rem;
    border-radius: 6px;
    font-size: 0.82rem;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s, transform 0.15s;
    transform: translateY(-50%) translateX(6px);
    z-index: 1000;
    box-shadow: 0 2px 8px rgba(0,0,0,0.25);
}

.admin-sidebar.collapsed .admin-nav-item:hover::after {
    opacity: 1;
    transform: translateY(-50%) translateX(10px);
}

/* 收起/展开按钮 */
.admin-sidebar-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.6rem;
    margin: 0.5rem 0.8rem 1rem;
    cursor: pointer;
    color: rgba(255, 255, 255, 0.45);
    border-radius: 6px;
    transition: all 0.2s;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.admin-sidebar-toggle:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.08);
}

.admin-sidebar-toggle svg {
    transition: transform 0.25s;
}

/* 收起状态：按钮箭头反转 */
.admin-sidebar.collapsed .admin-sidebar-toggle {
    margin: 0.5rem 0.5rem 1rem;
}

.admin-sidebar.collapsed .admin-sidebar-toggle svg {
    transform: rotate(180deg);
}

/* ========== 主内容区 ========== */
.admin-main {
    flex: 1;
    padding: 2rem;
    min-width: 0;
}

/* 欢迎区域 */
.admin-welcome {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    padding: 1.5rem 2rem;
    border-radius: 12px;
    margin-bottom: 1.5rem;
}

.admin-welcome h2 {
    font-size: 1.3rem;
    font-weight: 600;
    margin: 0 0 0.3rem;
}

.admin-welcome p {
    font-size: 0.9rem;
    opacity: 0.85;
    margin: 0;
}

.admin-username {
    font-weight: 700;
}

.admin-welcome-actions {
    display: flex;
    gap: 0.8rem;
}

.admin-btn {
    display: inline-flex;
    align-items: center;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 500;
    transition: all 0.2s;
}

.admin-btn-outline {
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.5);
    background: rgba(255, 255, 255, 0.1);
}

.admin-btn-outline:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: #fff;
}

.admin-btn-ghost {
    color: rgba(255, 255, 255, 0.7);
}

.admin-btn-ghost:hover {
    color: #fff;
}

/* ========== 统计卡片 ========== */
.admin-stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.admin-stat-card {
    background: #fff;
    border-radius: 12px;
    padding: 1.3rem 1.2rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
    transition: transform 0.2s, box-shadow 0.2s;
}

.admin-stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.admin-stat-icon {
    width: 50px;
    height: 50px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.admin-stat-info {
    display: flex;
    flex-direction: column;
}

.admin-stat-num {
    font-size: 1.6rem;
    font-weight: 700;
    line-height: 1.2;
    color: #1a1a2e;
}

.admin-stat-label {
    font-size: 0.8rem;
    color: #999;
    margin-top: 2px;
}

/* 卡片颜色变体 */
.stat-primary .admin-stat-icon { background: rgba(102, 126, 234, 0.12); color: #667eea; }
.stat-warning .admin-stat-icon { background: rgba(255, 193, 7, 0.12); color: #f0a500; }
.stat-success .admin-stat-icon { background: rgba(40, 167, 69, 0.12); color: #28a745; }
.stat-info .admin-stat-icon    { background: rgba(23, 162, 184, 0.12); color: #17a2b8; }
.stat-purple .admin-stat-icon  { background: rgba(118, 75, 162, 0.12); color: #764ba2; }
.stat-pink .admin-stat-icon    { background: rgba(232, 67, 147, 0.12); color: #e84393; }
.stat-orange .admin-stat-icon  { background: rgba(253, 126, 20, 0.12); color: #fd7e14; }
.stat-teal .admin-stat-icon    { background: rgba(32, 201, 151, 0.12); color: #20c997; }

/* ========== 通用区块 ========== */
.admin-section {
    background: #fff;
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
    margin-bottom: 1.5rem;
}

.admin-section-title {
    font-size: 1.05rem;
    font-weight: 600;
    color: #1a1a2e;
    margin: 0 0 1rem;
    padding-bottom: 0.6rem;
    border-bottom: 2px solid #f0f0f0;
}

/* 快捷操作 */
.admin-quick-actions {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 0.8rem;
}

.admin-quick-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    padding: 1.2rem 0.8rem;
    border-radius: 10px;
    border: 1px solid #eee;
    color: #555;
    text-decoration: none;
    font-size: 0.85rem;
    transition: all 0.2s;
}

.admin-quick-btn:hover {
    background: #f8f9ff;
    border-color: #667eea;
    color: #667eea;
    transform: translateY(-1px);
}

.admin-quick-btn svg {
    opacity: 0.7;
}

.admin-quick-btn:hover svg {
    opacity: 1;
}

/* ========== 页面标题栏 ========== */
.admin-page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.admin-page-title {
    font-size: 1.3rem;
    font-weight: 700;
    color: #1a1a2e;
    margin: 0;
}

/* ========== 工具栏 ========== */
.admin-toolbar {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.admin-toolbar-search {
    display: flex;
    align-items: center;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    overflow: hidden;
    transition: border-color 0.2s;
}

.admin-toolbar-search:focus-within {
    border-color: #667eea;
}

.admin-toolbar-search input {
    border: none;
    outline: none;
    padding: 0.5rem 0.8rem;
    font-size: 0.88rem;
    background: transparent;
    min-width: 200px;
}

.admin-toolbar-search button {
    border: none;
    background: none;
    padding: 0.5rem 0.6rem;
    cursor: pointer;
    color: #999;
    display: flex;
    align-items: center;
}

.admin-toolbar select {
    padding: 0.5rem 0.8rem;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    font-size: 0.88rem;
    background: #fff;
    outline: none;
    cursor: pointer;
}

.admin-toolbar select:focus {
    border-color: #667eea;
}

/* ========== 按钮 ========== */
.admin-btn-primary {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 0.5rem 1rem;
    background: #667eea;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 0.88rem;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.2s;
}

.admin-btn-primary:hover {
    background: #5a6fd6;
}

.admin-btn-secondary {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 0.5rem 1rem;
    background: #fff;
    color: #555;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    font-size: 0.88rem;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s;
}

.admin-btn-secondary:hover {
    border-color: #667eea;
    color: #667eea;
}

.admin-btn-danger {
    display: inline-flex;
    align-items: center;
    padding: 0.4rem 0.8rem;
    background: none;
    color: #e74c3c;
    border: 1px solid #e74c3c;
    border-radius: 6px;
    font-size: 0.82rem;
    cursor: pointer;
    transition: all 0.2s;
}

.admin-btn-danger:hover {
    background: #e74c3c;
    color: #fff;
}

.admin-btn-sm {
    padding: 0.35rem 0.7rem;
    font-size: 0.82rem;
    border-radius: 6px;
}

/* ========== 表格 ========== */
.admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.admin-table th {
    text-align: left;
    padding: 0.8rem 1rem;
    background: #f8f9fa;
    color: #666;
    font-weight: 600;
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 2px solid #f0f0f0;
}

.admin-table td {
    padding: 0.8rem 1rem;
    border-bottom: 1px solid #f5f5f5;
    color: #333;
    vertical-align: middle;
}

.admin-table tr:hover td {
    background: #fafbff;
}

.admin-table .actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.admin-table .actions a,
.admin-table .actions button {
    padding: 0.3rem 0.6rem;
    border-radius: 4px;
    font-size: 0.8rem;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
    background: none;
}

.admin-table .actions .btn-edit {
    color: #667eea;
    background: rgba(102, 126, 234, 0.08);
}

.admin-table .actions .btn-edit:hover {
    background: rgba(102, 126, 234, 0.18);
}

.admin-table .actions .btn-delete {
    color: #e74c3c;
    background: rgba(231, 76, 60, 0.08);
}

.admin-table .actions .btn-delete:hover {
    background: rgba(231, 76, 60, 0.18);
}

/* ========== 状态标签 ========== */
.admin-badge {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    border-radius: 10px;
    font-size: 0.75rem;
    font-weight: 500;
}

.admin-badge-success {
    background: rgba(40, 167, 69, 0.1);
    color: #28a745;
}

.admin-badge-warning {
    background: rgba(255, 193, 7, 0.15);
    color: #d48806;
}

.admin-badge-danger {
    background: rgba(231, 76, 60, 0.1);
    color: #e74c3c;
}

.admin-badge-info {
    background: rgba(102, 126, 234, 0.1);
    color: #667eea;
}

/* ========== 表单 ========== */
.admin-form {
    max-width: 600px;
}

.admin-form-group {
    margin-bottom: 1.2rem;
}

.admin-form-label {
    display: block;
    font-size: 0.88rem;
    font-weight: 600;
    color: #444;
    margin-bottom: 0.4rem;
}

.admin-form-input,
.admin-form-select,
.admin-form-textarea {
    width: 100%;
    padding: 0.6rem 0.8rem;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    font-size: 0.9rem;
    color: #333;
    background: #fff;
    outline: none;
    transition: border-color 0.2s;
}

.admin-form-input:focus,
.admin-form-select:focus,
.admin-form-textarea:focus {
    border-color: #667eea;
}

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

.admin-form-actions {
    display: flex;
    gap: 0.8rem;
    margin-top: 1.5rem;
}

.admin-form-hint {
    font-size: 0.8rem;
    color: #999;
    margin-top: 0.3rem;
}

/* ========== 模态框 ========== */
.admin-modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

.admin-modal-overlay.show {
    display: flex;
}

.admin-modal {
    background: #fff;
    border-radius: 12px;
    padding: 1.5rem;
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.admin-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.2rem;
    padding-bottom: 0.8rem;
    border-bottom: 1px solid #f0f0f0;
}

.admin-modal-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: #1a1a2e;
    margin: 0;
}

.admin-modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: #999;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

.admin-modal-close:hover {
    color: #333;
}

/* ========== 空状态 ========== */
.admin-empty {
    text-align: center;
    padding: 3rem 2rem;
    color: #999;
}

.admin-empty svg {
    margin-bottom: 1rem;
    opacity: 0.3;
}

.admin-empty p {
    font-size: 0.95rem;
}

/* ========== 消息提示 ========== */
.admin-toast {
    position: fixed;
    top: 2rem;
    right: 2rem;
    padding: 0.8rem 1.2rem;
    border-radius: 8px;
    color: #fff;
    font-size: 0.9rem;
    z-index: 2000;
    opacity: 0;
    transform: translateY(-10px);
    transition: all 0.3s;
}

.admin-toast.show {
    opacity: 1;
    transform: translateY(0);
}

.admin-toast-success { background: #28a745; }
.admin-toast-error { background: #e74c3c; }

/* 关于页等表单提交结果内联提示（页面内可见，不依赖 toast） */
.admin-feedback-msg {
    margin: 0 0 1rem 0;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    font-size: 0.95rem;
    display: none;
    transition: opacity 0.25s;
}
.admin-feedback-msg.show {
    display: block;
}
.admin-feedback-msg.admin-feedback-success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}
.admin-feedback-msg.admin-feedback-error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

/* ========== 表格响应式容器 ========== */
.admin-table-wrap {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* ========== 响应式 ========== */

/* 窄屏：侧边栏转为顶部水平导航（≤1024px） */
@media (max-width: 1024px) {
    .admin-layout {
        flex-direction: column;
    }

    /* 覆盖 collapsed 和默认状态的宽度，移除桌面端的 min-height */
    .admin-sidebar,
    .admin-sidebar.collapsed {
        width: 100% !important;
        height: auto;
        min-height: auto !important;
        position: relative;
        flex-direction: row;
        align-items: center;
        overflow-y: visible;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Logo 区域：窄屏下紧凑横排 */
    .admin-sidebar-header,
    .admin-sidebar.collapsed .admin-sidebar-header {
        padding: 0.6rem 1rem;
        border-bottom: none;
        border-right: 1px solid rgba(255, 255, 255, 0.08);
        flex-shrink: 0;
    }

    /* 确保 logo 文字在窄屏下正常显示（覆盖 collapsed 隐藏） */
    .admin-sidebar.collapsed .admin-logo {
        font-size: 1rem;
        letter-spacing: 1px;
    }

    .admin-sidebar.collapsed .admin-logo::before {
        content: none;
    }

    /* 导航项水平排列 */
    .admin-sidebar-nav {
        flex-direction: row;
        flex-wrap: nowrap;
        padding: 0;
        flex: 1;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .admin-nav-item,
    .admin-sidebar.collapsed .admin-nav-item {
        border-left: none !important;
        border-bottom: 2px solid transparent;
        padding: 0.6rem 0.75rem;
        font-size: 0.82rem;
        white-space: nowrap;
        gap: 5px;
        justify-content: center;
    }

    .admin-nav-item.active,
    .admin-sidebar.collapsed .admin-nav-item.active {
        border-bottom-color: #667eea;
        border-left-color: transparent !important;
    }

    /* 窄屏下始终显示导航文字 */
    .admin-sidebar.collapsed .admin-nav-item .nav-text {
        width: auto;
        opacity: 1;
        overflow: visible;
    }

    /* 隐藏收起按钮和 tooltip */
    .admin-sidebar-toggle {
        display: none !important;
    }

    .admin-sidebar.collapsed .admin-nav-item::after {
        display: none;
    }

    .admin-main {
        padding: 1.2rem;
    }

    .admin-welcome {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }

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

/* 更窄屏幕：进一步紧凑（≤768px） */
@media (max-width: 768px) {
    /* 顶部导航栏换行适配 */
    .admin-sidebar,
    .admin-sidebar.collapsed {
        flex-wrap: wrap;
    }

    .admin-sidebar-header,
    .admin-sidebar.collapsed .admin-sidebar-header {
        border-right: none;
        width: 100%;
        padding: 0.5rem 0.8rem;
        border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    }

    .admin-sidebar-nav {
        flex-wrap: wrap;
        padding: 0.3rem 0.3rem;
    }

    .admin-nav-item,
    .admin-sidebar.collapsed .admin-nav-item {
        padding: 0.45rem 0.55rem;
        font-size: 0.78rem;
        flex: 0 0 auto;
    }

    .admin-nav-item svg {
        width: 15px;
        height: 15px;
    }

    .admin-main {
        padding: 0.8rem;
    }

    /* 表格移动端紧凑 */
    .admin-table th,
    .admin-table td {
        padding: 0.5rem 0.6rem;
        font-size: 0.82rem;
    }

    .admin-table .actions {
        flex-wrap: wrap;
        gap: 0.3rem;
    }

    .admin-table .actions a,
    .admin-table .actions button {
        padding: 0.35rem 0.6rem;
        font-size: 0.75rem;
        min-height: 32px;
        display: inline-flex;
        align-items: center;
    }
}
