/* ═══════════════════════════════════════════
   晋元网络 - 后台管理样式 (OpsCenter风格)
   ═══════════════════════════════════════════ */

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    background: #f0f2f5;
    color: #333;
    line-height: 1.6;
}

/* ── 登录页 ── */
.login-page {
    min-height: 100vh;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.login-box {
    background: white;
    border-radius: 8px;
    padding: 40px;
    width: 400px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.1);
}

.login-brand {
    text-align: center;
    margin-bottom: 30px;
}

.login-brand .brand-icon {
    font-size: 40px;
    color: #667eea;
}

.login-brand h1 {
    font-size: 28px;
    color: #667eea;
    margin: 10px 0 8px;
}

.login-brand p {
    color: #999;
    font-size: 14px;
}

/* ── 主布局 ── */
.admin-body {
    display: flex;
    min-height: 100vh;
}

/* ── 侧边栏 ── */
.admin-sidebar {
    width: 240px;
    background: #001529;
    color: white;
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    overflow-y: auto;
    z-index: 200;
}

.sidebar-brand {
    padding: 20px;
    text-align: center;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.sidebar-brand .brand-icon {
    color: #667eea;
    font-size: 24px;
}

.sidebar-brand span:last-child {
    font-size: 20px;
    font-weight: 600;
    color: #667eea;
}

.sidebar-nav {
    padding: 10px 0;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 20px;
    color: rgba(255,255,255,0.65);
    font-size: 14px;
    transition: all 0.3s;
    text-decoration: none;
}

.sidebar-link:hover {
    background: rgba(255,255,255,0.05);
    color: white;
}

.sidebar-link.active {
    background: #667eea;
    color: white;
}

.sidebar-link span:first-child {
    font-size: 18px;
}

.sidebar-divider {
    height: 1px;
    background: rgba(255,255,255,0.1);
    margin: 10px 20px;
}

/* ── 主内容区 ── */
.admin-main {
    flex: 1;
    margin-left: 240px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ── 顶部导航 ── */
.admin-header {
    background: white;
    padding: 0 20px;
    height: 60px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
    position: sticky;
    top: 0;
    z-index: 100;
}

.admin-header h1 {
    font-size: 18px;
    color: #333;
    font-weight: 600;
}

.sidebar-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 22px;
    cursor: pointer;
    padding: 6px 10px;
    border-radius: 4px;
    color: #666;
    margin-right: 10px;
}

.sidebar-toggle:hover {
    background: #f5f5f5;
}

.header-user {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* ── 用户下拉菜单 ── */
.user-dropdown {
    position: relative;
}

.user-trigger {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    background: transparent;
    border: 1px solid #d0d7de;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.user-trigger:hover {
    background: #f6f8fa;
    border-color: #0969da;
}

.user-icon {
    color: #0969da;
    flex-shrink: 0;
}

.user-email {
    font-size: 14px;
    font-weight: 400;
    color: #0969da;
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-arrow {
    color: #0969da;
    transition: transform 0.2s;
    flex-shrink: 0;
}

.user-dropdown:hover .user-arrow {
    transform: rotate(180deg);
}

.dropdown-menu {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    min-width: 180px;
    background: #fff;
    border: 1px solid #d0d7de;
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: all 0.2s ease;
    z-index: 100;
    overflow: hidden;
}

.user-dropdown:hover .dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    color: #24292f;
    font-size: 14px;
    text-decoration: none;
    transition: background 0.15s ease;
    border-bottom: 1px solid #f0f0f0;
}

.dropdown-item:last-child {
    border-bottom: none;
}

.dropdown-item:hover {
    background: #f6f8fa;
    color: #0969da;
}

.dropdown-item svg {
    flex-shrink: 0;
    color: #57606a;
}

.dropdown-item:hover svg {
    color: #0969da;
}

.dropdown-logout:hover {
    background: #fff5f5;
    color: #cf222e;
}

.dropdown-logout:hover svg {
    color: #cf222e;
}

/* ── 内容区 ── */
.admin-content {
    padding: 20px;
    flex: 1;
}

/* ── 页面标题 ── */
.page-header {
    margin-bottom: 20px;
}

.page-header h1 {
    font-size: 24px;
    color: #333;
    margin-bottom: 8px;
}

.page-header p {
    color: #666;
    font-size: 14px;
}

/* ── 统计卡片 ── */
.stats-cards, .stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}

.stat-card {
    background: white;
    padding: 20px;
    border-radius: 4px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.stat-info h3 {
    font-size: 13px;
    color: #666;
    margin-bottom: 8px;
    font-weight: normal;
}

.stat-value {
    font-size: 26px;
    font-weight: bold;
    color: #333;
}

.stat-icon {
    width: 52px;
    height: 52px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
}

.stat-icon.blue { background: #e6f7ff; color: #1890ff; }
.stat-icon.green { background: #f6ffed; color: #52c41a; }
.stat-icon.orange { background: #fff7e6; color: #fa8c16; }
.stat-icon.red { background: #fff1f0; color: #f5222d; }
.stat-icon.purple { background: #f9f0ff; color: #722ed1; }

/* ── 内容卡片 ── */
.content-card, .card {
    background: white;
    border-radius: 4px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}

.content-card h3, .card-title {
    font-size: 16px;
    font-weight: 600;
    color: #333;
    margin-bottom: 16px;
    padding-bottom: 16px;
    border-bottom: 1px solid #f0f0f0;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding-bottom: 16px;
    border-bottom: 1px solid #f0f0f0;
}

.content-grid {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 20px;
}

/* ── 快捷操作 ── */
.quick-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.action-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 18px;
    background: #fafafa;
    border-radius: 4px;
    color: #333;
    font-size: 14px;
    transition: all 0.3s;
    text-decoration: none;
}

.action-btn:hover {
    background: #f0f0f0;
    color: #667eea;
}

/* ── 表格 ── */
.admin-table, table {
    width: 100%;
    border-collapse: collapse;
}

.admin-table th, .admin-table td,
table th, table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid #f0f0f0;
    font-size: 14px;
}

.admin-table th, table th {
    background: #fafafa;
    font-weight: 600;
    color: #333;
}

.admin-table td a, table td a {
    color: #667eea;
    text-decoration: none;
}

.admin-table td a:hover, table td a:hover {
    text-decoration: underline;
}

.admin-table tr:hover, table tr:hover {
    background: #fafafa;
}

.table-container {
    overflow-x: auto;
}

/* ── 表单 ── */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    color: #333;
    font-size: 14px;
}

.form-control, .form-group input, .form-group select, .form-group textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    transition: border-color 0.3s;
    font-family: inherit;
}

.form-control:focus, .form-group input:focus, .form-group select:focus, .form-group textarea:focus {
    outline: none;
    border-color: #667eea;
}

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

select.form-control {
    cursor: pointer;
}

.form-row {
    display: flex;
    gap: 20px;
}

/* ── 按钮 ── */
.btn {
    padding: 8px 16px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.3s;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.btn-primary {
    background: #667eea;
    color: white;
}

.btn-primary:hover {
    background: #5568d3;
}

.btn-default, .btn-outline {
    background: white;
    border: 1px solid #ddd;
    color: #333;
}

.btn-default:hover, .btn-outline:hover {
    border-color: #667eea;
    color: #667eea;
}

.btn-danger {
    background: #ff4d4f;
    color: white;
}

.btn-danger:hover {
    background: #ff7875;
}

.btn-success {
    background: #52c41a;
    color: white;
}

.btn-warning {
    background: #fa8c16;
    color: white;
}

.btn-sm {
    padding: 4px 12px;
    font-size: 12px;
}

.btn-block {
    width: 100%;
    justify-content: center;
    padding: 12px;
    font-size: 16px;
}

/* ── 徽章/状态 ── */
.badge, .status {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 4px;
    font-size: 12px;
}

.badge-success, .status.online, .status.success {
    background: #f6ffed;
    color: #52c41a;
}

.badge-draft, .status.offline, .status.danger {
    background: #fff1f0;
    color: #f5222d;
}

.status.warning {
    background: #fff7e6;
    color: #fa8c16;
}

.status.info {
    background: #e6f7ff;
    color: #1890ff;
}

/* ── 提示 ── */
.alert {
    padding: 12px 16px;
    border-radius: 4px;
    margin-bottom: 20px;
    font-size: 14px;
}

.alert-success {
    background: #f6ffed;
    border: 1px solid #b7eb8f;
    color: #52c41a;
}

.alert-error {
    background: #fff1f0;
    border: 1px solid #ffa39e;
    color: #f5222d;
}

/* ── 分页 ── */
.pagination {
    display: flex;
    gap: 6px;
    margin-top: 20px;
    justify-content: center;
}

.pagination a, .pagination span {
    padding: 8px 14px;
    border-radius: 4px;
    background: white;
    color: #333;
    font-size: 13px;
    text-decoration: none;
    border: 1px solid #ddd;
}

.pagination a:hover {
    background: #667eea;
    color: white;
    border-color: #667eea;
}

.pagination .active {
    background: #667eea;
    color: white;
    border-color: #667eea;
}

.text-accent { color: #667eea; }

/* ── 仪表盘网格 ── */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}

@media (max-width: 992px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
}

/* ── 用户列表 ── */
.user-list {
    display: flex;
    flex-direction: column;
}

.user-item {
    display: flex;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid #f0f0f0;
}

.user-item:last-child {
    border-bottom: none;
}

/* ── API调用列表 ── */
.api-call-list {
    display: flex;
    flex-direction: column;
}

.api-call-item {
    padding: 12px 0;
    border-bottom: 1px solid #f0f0f0;
}

.api-call-item:last-child {
    border-bottom: none;
}

/* ── 操作按钮组 ── */
.action-buttons {
    display: flex;
    gap: 6px;
}

/* ── 响应式 ── */
@media (max-width: 768px) {
    .admin-sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        z-index: 1000;
    }
    
    .admin-sidebar.open {
        transform: translateX(0);
    }
    
    .admin-sidebar::before {
        content: '';
        position: fixed;
        top: 0;
        left: 240px;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.3s;
    }
    
    .admin-sidebar.open::before {
        opacity: 1;
        pointer-events: all;
    }
    
    .admin-main {
        margin-left: 0;
    }
    
    .admin-header {
        padding: 12px 16px;
    }
    
    .sidebar-toggle {
        display: block;
    }
    
    .admin-content {
        padding: 16px;
    }
    
    .stats-cards, .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .content-grid {
        grid-template-columns: 1fr;
    }
    
    .form-row {
        flex-direction: column;
    }
}
