/* ===================================================
   远程控制中心 - 白色主题样式
   侧边栏 + 标签栏 + 内容区布局
   =================================================== */

/* CSS变量 */
:root {
    --sidebar-width: 240px;
    --sidebar-collapsed: 0px;
    --topbar-height: 56px;
    --tab-height: 42px;
    --primary: #4a6cf7;
    --primary-light: #eef1ff;
    --primary-dark: #3b5de7;
    --success: #34c759;
    --warning: #ff9500;
    --danger: #ff3b30;
    --info: #5ac8fa;
    --text-primary: #1d1d1f;
    --text-secondary: #6e6e73;
    --text-tertiary: #aeaeb2;
    --bg-body: #f5f7fa;
    --bg-card: #ffffff;
    --bg-sidebar: #ffffff;
    --bg-tab: #ffffff;
    --border: #e5e5ea;
    --border-light: #f0f0f3;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 16px rgba(0,0,0,0.06);
    --shadow-lg: 0 8px 32px rgba(0,0,0,0.08);
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
}

/* 重置 */
*, *::before, *::after {
    box-sizing: border-box; margin: 0; padding: 0;
}
html, body {
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "PingFang SC", "Microsoft YaHei", sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: var(--text-primary);
    background: var(--bg-body);
    -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }
input, button, select, textarea { font-family: inherit; }

/* ======== 整体布局 ======== */
.app-layout {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* ======== 侧边栏 ======== */
.sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    height: 100vh;
    position: relative;
    z-index: 100;
    transition: width 0.25s ease;
}
.sidebar-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 18px 20px 16px;
    border-bottom: 1px solid var(--border-light);
}
.sidebar-logo {
    width: 34px; height: 34px;
    background: linear-gradient(135deg, var(--primary), #6c63ff);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.sidebar-logo svg { width: 18px; height: 18px; fill: #fff; }
.sidebar-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
}

/* 导航菜单 */
.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 12px 12px;
}
.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.nav-section-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 16px 12px 6px;
}
.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
    margin-bottom: 2px;
    text-decoration: none;
}
.nav-item svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    opacity: 0.7;
}
.nav-item:hover {
    background: var(--primary-light);
    color: var(--primary);
}
.nav-item:hover svg { opacity: 1; }
.nav-item.active {
    background: var(--primary-light);
    color: var(--primary);
    font-weight: 600;
}
.nav-item.active svg { opacity: 1; }

/* 侧边栏底部 */
.sidebar-footer {
    padding: 12px 16px;
    border-top: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
}
.user-avatar {
    width: 32px; height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), #6c63ff);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 700;
    flex-shrink: 0;
}
.user-details {
    display: flex;
    flex-direction: column;
}
.user-name { font-size: 13px; font-weight: 600; color: var(--text-primary); }
.user-role { font-size: 11px; color: var(--text-tertiary); text-transform: capitalize; }
.logout-btn {
    width: 32px; height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-tertiary);
    transition: all 0.15s;
}
.logout-btn:hover {
    background: #f5f5f7;
    color: var(--danger);
}
.logout-btn svg { width: 18px; height: 18px; }

/* ======== 主内容区 ======== */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    overflow: hidden;
}

/* ======== 顶部栏 ======== */
.topbar {
    height: var(--topbar-height);
    min-height: var(--topbar-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
}
.topbar-left {
    display: flex;
    align-items: center;
    gap: 12px;
}
.menu-toggle {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    color: var(--text-secondary);
}
.menu-toggle svg { width: 22px; height: 22px; }
.breadcrumb {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
}
.topbar-right {
    display: flex;
    align-items: center;
    gap: 8px;
}
.icon-btn {
    width: 36px; height: 36px;
    border: none;
    background: transparent;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    transition: all 0.15s;
}
.icon-btn:hover {
    background: var(--bg-body);
    color: var(--text-primary);
}
.icon-btn svg { width: 20px; height: 20px; }

/* ======== 标签栏 ======== */
.tab-bar {
    height: var(--tab-height);
    min-height: var(--tab-height);
    display: flex;
    align-items: center;
    padding: 0 12px;
    background: var(--bg-tab);
    border-bottom: 1px solid var(--border);
    overflow-x: auto;
    gap: 2px;
}
.tab-bar::-webkit-scrollbar { height: 0; }
.tab-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    border-radius: 8px 8px 0 0;
    font-size: 13px;
    color: var(--text-secondary);
    cursor: pointer;
    white-space: nowrap;
    position: relative;
    transition: all 0.15s;
    border: 1px solid transparent;
    border-bottom: none;
    margin-bottom: -1px;
    user-select: none;
}
.tab-item svg {
    width: 16px; height: 16px;
    opacity: 0.6;
}
.tab-item:hover {
    color: var(--text-primary);
    background: var(--bg-body);
}
.tab-item.active {
    color: var(--primary);
    background: #fff;
    border-color: var(--border);
    font-weight: 500;
}
.tab-item.active svg { opacity: 1; }
.tab-close {
    font-size: 16px;
    line-height: 1;
    margin-left: 4px;
    opacity: 0;
    transition: opacity 0.15s;
    color: var(--text-tertiary);
}
.tab-item:hover .tab-close { opacity: 1; }
.tab-close:hover { color: var(--danger); }

/* ======== 内容区 ======== */
.content-area {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    background: var(--bg-body);
}
.content-area::-webkit-scrollbar { width: 6px; }
.content-area::-webkit-scrollbar-thumb { background: var(--border); border-radius: 6px; }

/* ======== 卡片组件 ======== */
.card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-light);
}
.card-header {
    padding: 18px 24px;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.card-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
}
.card-body {
    padding: 24px;
}
.card-footer {
    padding: 14px 24px;
    border-top: 1px solid var(--border-light);
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

/* ======== 统计卡片 ======== */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}
.stat-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 22px 24px;
    border: 1px solid var(--border-light);
    box-shadow: var(--shadow-sm);
}
.stat-card .stat-label {
    font-size: 13px;
    color: var(--text-tertiary);
    margin-bottom: 6px;
}
.stat-card .stat-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
}
.stat-card .stat-footer {
    font-size: 12px;
    color: var(--text-tertiary);
    margin-top: 8px;
}
.stat-card .stat-icon {
    float: right;
    width: 40px; height: 40px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.stat-card .stat-icon svg { width: 22px; height: 22px; }
.stat-card .stat-icon.blue { background: var(--primary-light); color: var(--primary); }
.stat-card .stat-icon.green { background: #e8f8ee; color: var(--success); }
.stat-card .stat-icon.orange { background: #fff4e5; color: var(--warning); }
.stat-card .stat-icon.red { background: #fff0ef; color: var(--danger); }

/* ======== 表格样式 ======== */
.table-wrap {
    overflow-x: auto;
}
table {
    width: 100%;
    border-collapse: collapse;
}
table th {
    text-align: left;
    padding: 12px 16px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-body);
}
table td {
    padding: 12px 16px;
    font-size: 14px;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border-light);
}
table tr:hover td {
    background: #fafbfc;
}

/* ======== 按钮样式 ======== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 18px;
    border: none;
    border-radius: var(--radius-md);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
    text-decoration: none;
    line-height: 1.4;
}
.btn svg { width: 16px; height: 16px; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); box-shadow: 0 2px 8px rgba(74,108,247,0.3); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #2db84e; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-info { background: var(--info); color: #fff; }
.btn-outline { background: transparent; color: var(--text-secondary); border: 1px solid var(--border); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.btn-sm { padding: 5px 12px; font-size: 12px; }
.btn-lg { padding: 12px 28px; font-size: 15px; }

/* ======== 表单样式 ======== */
.form-group { margin-bottom: 18px; }
.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
}
.form-control {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    background: #fff;
    box-sizing: border-box;
}
.form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(74,108,247,0.1);
}
.form-control::placeholder { color: var(--text-tertiary); }
select.form-control { appearance: none; background-image: url("data:image/svg+xml,..."); }
textarea.form-control { resize: vertical; min-height: 80px; }
.form-row { display: flex; gap: 16px; }
.form-row .form-group { flex: 1; }

/* ======== 标签/徽章 ======== */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
}
.badge-success { background: #e8f8ee; color: #1a8a3a; }
.badge-warning { background: #fff4e5; color: #b25e00; }
.badge-danger { background: #fff0ef; color: #c41e1e; }
.badge-info { background: #e8f4fd; color: #0077b5; }
.badge-default { background: var(--bg-body); color: var(--text-secondary); }

/* ======== 空状态 ======== */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-tertiary);
}
.empty-state svg {
    width: 56px; height: 56px;
    opacity: 0.3;
    margin-bottom: 16px;
}
.empty-state p { font-size: 14px; }

/* ======== 加载动画 ======== */
.spinner {
    width: 32px; height: 32px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    display: inline-block;
}
@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ======== 弹窗 ======== */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.3);
    backdrop-filter: blur(2px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
}
.modal-overlay.show {
    opacity: 1;
    pointer-events: auto;
}
.modal-box {
    background: #fff;
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 520px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
}
.modal-header {
    padding: 20px 24px 16px;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.modal-title { font-size: 16px; font-weight: 600; }
.modal-close {
    width: 28px; height: 28px;
    border: none;
    background: transparent;
    font-size: 20px;
    cursor: pointer;
    border-radius: 6px;
    color: var(--text-tertiary);
    display: flex;
    align-items: center;
    justify-content: center;
}
.modal-close:hover { background: var(--bg-body); color: var(--text-primary); }
.modal-body { padding: 20px 24px; }
.modal-footer {
    padding: 14px 24px;
    border-top: 1px solid var(--border-light);
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

/* ======== 提示信息 ======== */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius-md);
    font-size: 13px;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.alert svg { width: 18px; height: 18px; flex-shrink: 0; }
.alert-info { background: #e8f4fd; color: #0077b5; border: 1px solid #d0ebf9; }
.alert-success { background: #e8f8ee; color: #1a8a3a; border: 1px solid #d4f5d8; }
.alert-warning { background: #fff4e5; color: #b25e00; border: 1px solid #ffe8c8; }
.alert-danger { background: #fff0ef; color: #c41e1e; border: 1px solid #ffdbdb; }

/* ======== 分页 ======== */
.pagination {
    display: flex;
    gap: 4px;
    justify-content: center;
    margin-top: 20px;
}
.pagination a, .pagination span {
    padding: 6px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 13px;
    color: var(--text-secondary);
    text-decoration: none;
    transition: all 0.15s;
}
.pagination a:hover { border-color: var(--primary); color: var(--primary); }
.pagination .active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ======== 工具类 ======== */
.text-center { text-align: center; }
.text-right { text-align: right; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 16px; }
.mt-4 { margin-top: 24px; }
.mb-1 { margin-bottom: 4px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 16px; }
.mb-4 { margin-bottom: 24px; }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.gap-1 { gap: 4px; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 16px; }

/* ======== API文档样式 ======== */
.docs-container { max-width: 860px; margin: 0 auto; }
.doc-section {
    background: #fff;
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-bottom: 16px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
}
.doc-section h3 {
    font-size: 18px;
    margin-bottom: 16px;
    color: var(--text-primary);
}
.doc-section p {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.7;
}
.doc-section ol {
    padding-left: 20px;
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.8;
}
.doc-section li { margin-bottom: 8px; }
.doc-section code {
    background: var(--bg-secondary);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 13px;
    color: var(--primary);
}
.code-block {
    background: #1e1e1e;
    border-radius: var(--radius-md);
    padding: 16px;
    overflow-x: auto;
    margin: 12px 0;
}
.code-block pre {
    margin: 0;
    font-family: 'Monaco', 'Menlo', monospace;
    font-size: 13px;
    line-height: 1.6;
    color: #d4d4d4;
    white-space: pre;
}
.api-item {
    background: #fafafa;
    border-radius: var(--radius-md);
    padding: 20px;
    margin-bottom: 16px;
    border: 1px solid var(--border);
}
.api-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
}
.api-method {
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.api-method.post { background: #e8f4fd; color: #0077b5; }
.api-method.get { background: #e8f8ee; color: #1a8a3a; }
.api-path {
    font-family: 'Monaco', 'Menlo', monospace;
    font-size: 14px;
    color: var(--text-primary);
}
.api-description {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 16px;
}
.api-item h4 {
    font-size: 14px;
    margin-bottom: 8px;
    color: var(--text-primary);
}
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ======== 响应式 ======== */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: calc(-1 * var(--sidebar-width));
        top: 0;
        bottom: 0;
        z-index: 200;
        box-shadow: none;
        transition: left 0.25s ease;
        border-right: none;
    }
    .sidebar.open {
        left: 0;
        box-shadow: var(--shadow-lg);
    }
    .menu-toggle { display: flex; }
    .content-area { padding: 16px; }
    .stat-grid { grid-template-columns: repeat(2, 1fr); }
    .form-row { flex-direction: column; gap: 0; }
}

@media (max-width: 480px) {
    .stat-grid { grid-template-columns: 1fr; }
    .card-body { padding: 16px; }
}