/* =============================================
   Admin 后台样式
   yb.mcool.vip
   ============================================= */

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

:root {
    --primary: #3370ff;
    --primary-hover: #2860e0;
    --success: #00b578;
    --warning: #ff8f1f;
    --danger: #f53f3f;
    --purple: #7c5cfc;
    --bg: #f5f6fa;
    --bg-card: #ffffff;
    --text: #1d2129;
    --text-secondary: #86909c;
    --text-muted: #c9cdd4;
    --border: #e5e6eb;
    --shadow: 0 2px 8px rgba(0,0,0,0.06);
    --radius: 10px;
    --radius-sm: 6px;
    --sidebar-width: 220px;
    --topbar-height: 60px;
    --transition: 0.2s ease;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB",
                 "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
    font-size: 14px;
    color: var(--text);
    background: var(--bg);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-hover); }
code { background: #f2f3f5; padding: 2px 6px; border-radius: 4px; font-size: 13px; color: #e83e8c; }

/* ---- Layout ---- */
.admin-layout {
    display: flex;
    min-height: 100vh;
}

/* ---- Sidebar ---- */
.sidebar {
    width: var(--sidebar-width);
    background: #1a1a2e;
    color: #c9cdd4;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 100;
    overflow-y: auto;
}

.sidebar-header {
    padding: 20px 16px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #fff;
    font-size: 17px;
    font-weight: 600;
}
.sidebar-logo:hover { color: #fff; }
.logo-icon { font-size: 24px; }

.sidebar-nav {
    flex: 1;
    padding: 12px 0;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 20px;
    color: #a8abb2;
    font-size: 14px;
    transition: all var(--transition);
    border-left: 3px solid transparent;
    text-decoration: none;
}

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

.nav-item.active {
    background: rgba(51,112,255,0.15);
    color: #fff;
    border-left-color: var(--primary);
}

.nav-icon { font-size: 16px; width: 22px; text-align: center; }

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid rgba(255,255,255,0.08);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 0;
}

.user-avatar {
    width: 36px; height: 36px;
    border-radius: 50%;
    object-fit: cover;
    background: #333;
    flex-shrink: 0;
}

.user-meta {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.user-name {
    color: #e5e6eb;
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.user-role {
    font-size: 11px;
    color: #86909c;
}

.logout-btn {
    font-size: 18px;
    color: #86909c;
    padding: 6px;
    text-decoration: none;
    transition: color var(--transition);
}
.logout-btn:hover { color: var(--danger); }

/* ---- Main Content ---- */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-height: 100vh;
}

.topbar {
    height: var(--topbar-height);
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 50;
}

.page-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text);
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 16px;
}

.sys-time {
    font-size: 12px;
    color: var(--text-secondary);
    font-family: "SF Mono", Monaco, "Cascadia Code", monospace;
}

.content-body {
    padding: 24px;
}

/* ---- Dashboard ---- */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: var(--shadow);
    transition: transform var(--transition);
}
.stat-card:hover { transform: translateY(-2px); }

.stat-icon {
    width: 48px; height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    flex-shrink: 0;
}

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

.stat-value {
    font-size: 24px;
    font-weight: 700;
    color: var(--text);
    line-height: 1.2;
}

.stat-label {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 2px;
}

/* ---- Panels ---- */
.dashboard-panels {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.panel {
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 24px;
    overflow: hidden;
}

.panel-wide { grid-column: span 2; }

.panel-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.panel-header h3 { font-size: 15px; font-weight: 600; }
.panel-badge { font-size: 12px; color: var(--text-secondary); background: var(--bg); padding: 2px 8px; border-radius: 12px; }

.panel-body { padding: 20px; }

/* ---- Info Table ---- */
.info-table {
    width: 100%;
    border-collapse: collapse;
}

.info-table td {
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
}

.info-table td:first-child {
    color: var(--text-secondary);
    width: 120px;
    font-weight: 500;
}

.info-table td:last-child {
    color: var(--text);
    font-family: "SF Mono", Monaco, "Cascadia Code", monospace;
    font-size: 12px;
}

/* ---- Data Table ---- */
.table-responsive { overflow-x: auto; }

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.data-table thead {
    background: #fafbfc;
}

.data-table th {
    padding: 12px 16px;
    text-align: left;
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 12px;
    text-transform: uppercase;
    white-space: nowrap;
    border-bottom: 2px solid var(--border);
}

.data-table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.data-table tbody tr:hover { background: #fafbfc; }

.ellipsis {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 200px;
}

/* ---- Badges ---- */
.badge {
    display: inline-block;
    padding: 3px 10px;
    font-size: 12px;
    font-weight: 500;
    border-radius: 20px;
    background: #f2f3f5;
    color: var(--text-secondary);
}

.badge-sm { padding: 2px 8px; font-size: 11px; }
.badge-success { background: #e8ffea; color: var(--success); }
.badge-danger { background: #ffece8; color: var(--danger); }
.badge-warning { background: #fff7e8; color: var(--warning); }

/* ---- Buttons ---- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 16px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
    text-decoration: none;
    font-family: inherit;
}

.btn-primary {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); color: #fff; }

.btn-outline {
    background: var(--bg-card);
    color: var(--text);
    border-color: var(--border);
}
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }

.btn-danger {
    background: #fff;
    color: var(--danger);
    border-color: #ffece8;
}
.btn-danger:hover { background: var(--danger); color: #fff; border-color: var(--danger); }

.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-lg { padding: 12px 28px; font-size: 16px; }
.btn-group { display: flex; gap: 6px; }

/* ---- Forms ---- */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 13px; font-weight: 500; color: var(--text); margin-bottom: 6px; }
.form-hint { font-size: 12px; color: var(--text-secondary); }
.form-control { width: 100%; padding: 9px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 14px; color: var(--text); background: var(--bg-card); transition: border-color var(--transition); font-family: inherit; }
.form-control:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 2px rgba(51,112,255,0.15); }
.form-control.form-sm { padding: 5px 8px; font-size: 12px; }
textarea.form-control { resize: vertical; font-family: "SF Mono", Monaco, "Cascadia Code", monospace; font-size: 13px; }
select.form-control { cursor: pointer; }
.form-row { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.flex-1 { flex: 1; min-width: 150px; }
.inline-form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.form-actions { margin-top: 24px; display: flex; gap: 12px; }

/* ---- Switch ---- */
.switch {
    position: relative; display: inline-block; width: 46px; height: 26px;
}
.switch input { opacity: 0; width: 0; height: 0; }
.switch-slider {
    position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0;
    background: #ccc; border-radius: 26px; transition: .3s;
}
.switch-slider::before {
    content: ""; position: absolute; height: 20px; width: 20px;
    left: 3px; bottom: 3px; background: #fff; border-radius: 50%; transition: .3s;
}
.switch input:checked + .switch-slider { background: var(--success); }
.switch input:checked + .switch-slider::before { transform: translateX(20px); }

/* ---- Alerts ---- */
.alert { padding: 12px 16px; border-radius: var(--radius-sm); margin-bottom: 16px; font-size: 14px; }
.alert-success { background: #e8ffea; color: #00b578; border: 1px solid #b7ebc1; }
.alert-danger { background: #ffece8; color: #f53f3f; border: 1px solid #ffcdc7; }

/* ---- Empty State ---- */
.empty-state {
    text-align: center; padding: 40px 20px; color: var(--text-muted); font-size: 14px;
}

/* ---- User List ---- */
.user-list { display: flex; flex-direction: column; gap: 8px; }
.user-item {
    display: flex; align-items: center; gap: 10px; padding: 8px 0;
    border-bottom: 1px solid var(--border);
}
.user-item:last-child { border-bottom: none; }
.u-avatar { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; background: #f2f3f5; flex-shrink: 0; }
.u-info { flex: 1; min-width: 0; }
.u-name { font-size: 13px; font-weight: 500; display: block; }
.u-time { font-size: 11px; color: var(--text-secondary); }

.user-cell { display: flex; align-items: center; gap: 8px; }

/* ---- Table List (for database) ---- */
.table-list { display: flex; flex-direction: column; }
.table-item {
    display: flex; align-items: center; gap: 10px; padding: 12px 20px;
    color: var(--text); border-bottom: 1px solid var(--border); text-decoration: none;
    transition: background var(--transition);
}
.table-item:last-child { border-bottom: none; }
.table-item:hover { background: #f7f8fa; }
.table-item.active { background: #e8f0fe; color: var(--primary); font-weight: 500; }

/* ---- File links ---- */
.file-link { color: var(--text); text-decoration: none; }
.file-link.dir { color: var(--primary); font-weight: 500; }
.file-link:hover { text-decoration: underline; }
.nav-back { color: var(--text-secondary); text-decoration: none; font-size: 13px; }
.nav-back:hover { color: var(--primary); }

/* ---- Pagination ---- */
.pagination {
    display: flex; align-items: center; justify-content: center; gap: 12px;
    padding: 16px 20px; border-top: 1px solid var(--border);
}
.page-info { font-size: 13px; color: var(--text-secondary); }

/* ---- Modal ---- */
.modal {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    display: flex; align-items: center; justify-content: center; z-index: 1000;
}
.modal-overlay {
    position: absolute; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
}
.modal-box {
    position: relative; background: var(--bg-card); border-radius: var(--radius);
    width: 90%; max-width: 520px; box-shadow: 0 20px 60px rgba(0,0,0,0.2);
    z-index: 1;
}
.modal-large { max-width: 800px; }
.modal-header {
    padding: 16px 20px; border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
}
.modal-header h3 { font-size: 16px; }
.modal-close { background: none; border: none; font-size: 18px; cursor: pointer; color: var(--text-secondary); }
.modal-body { padding: 20px; }
.modal-footer {
    padding: 16px 20px; border-top: 1px solid var(--border);
    display: flex; justify-content: flex-end; gap: 10px;
}

/* ---- Code Editor ---- */
.code-editor {
    font-family: "SF Mono", Monaco, "Cascadia Code", "Consolas", monospace;
    font-size: 13px; line-height: 1.5; tab-size: 4;
    background: #1e1e2e; color: #cdd6f4; border: none; border-radius: 8px;
}

/* ---- SQL Console ---- */
.sql-input {
    font-family: "SF Mono", Monaco, "Cascadia Code", monospace; font-size: 13px;
    background: #1e1e2e; color: #cdd6f4; border: none; border-radius: 8px;
}
.sql-input:focus { box-shadow: 0 0 0 2px rgba(51,112,255,0.3); }

/* ---- Responsive ---- */
@media (max-width: 1200px) {
    .dashboard-grid { grid-template-columns: repeat(2, 1fr); }
    .dashboard-panels { grid-template-columns: 1fr; }
    .panel-wide { grid-column: span 1; }
}

@media (max-width: 768px) {
    .sidebar { width: 60px; }
    .sidebar-logo .logo-text,
    .nav-label,
    .user-meta { display: none; }
    .main-content { margin-left: 60px; }
    .dashboard-grid { grid-template-columns: 1fr; }
    .topbar { padding: 0 12px; }
    .content-body { padding: 12px; }
    .form-row { flex-direction: column; }
}
