/* ============================================================
   在写 - 电商竞品分析助手  样式
   ============================================================ */

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

:root {
    --primary:        #0E2A47;
    --primary-light:  #1a3a5c;
    --accent:         #C9A961;
    --accent-light:   #d4b97a;
    --success:        #28a745;
    --danger:         #dc3545;
    --warning:        #ffc107;
    --info:           #17a2b8;
    --bg:             #f5f7fa;
    --bg-card:        #ffffff;
    --text:           #2c3e50;
    --text-muted:     #6c757d;
    --border:         #e1e4e8;
    --hover:          #f0f3f6;
    --shadow:         0 1px 3px rgba(0,0,0,.08);
    --shadow-md:      0 2px 8px rgba(0,0,0,.08);
    --radius:         6px;
    --radius-sm:      4px;
    --sidebar-w:      230px;
    --topbar-h:       56px;
}

html, body { height: 100%; }

body {
    font-family: -apple-system, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
    font-size: 14px;
    color: var(--text);
    background: var(--bg);
    line-height: 1.5;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

code { font-family: "SF Mono", Consolas, Menlo, monospace; font-size: 12.5px; padding: 1px 5px; background: #f0f3f6; border-radius: 3px; color: #c7254e; }

.text-muted   { color: var(--text-muted); }
.text-success { color: var(--success); }
.text-danger  { color: var(--danger); }
.text-center  { text-align: center; }

/* ============ 布局 ============ */
.app {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: var(--sidebar-w);
    background: var(--primary);
    color: #fff;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    overflow-y: auto;
}

.main {
    flex: 1;
    margin-left: var(--sidebar-w);
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.topbar {
    height: var(--topbar-h);
    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: 10;
}

.topbar-title { font-size: 16px; font-weight: 600; }
.topbar-right { display: flex; align-items: center; gap: 16px; font-size: 13px; color: var(--text-muted); }
.env-tag {
    background: var(--primary);
    color: #fff;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 12px;
}

.content { padding: 20px 24px; }

/* ============ 侧边栏 ============ */
.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 16px 20px;
    border-bottom: 1px solid rgba(255,255,255,.1);
}
.brand-logo {
    width: 36px; height: 36px;
    background: var(--accent);
    color: var(--primary);
    display: flex; align-items: center; justify-content: center;
    font-weight: 700;
    font-size: 18px;
    border-radius: var(--radius-sm);
}
.brand-title { font-size: 14px; font-weight: 600; line-height: 1.3; }
.brand-sub   { font-size: 11px; color: rgba(255,255,255,.5); }

.nav { flex: 1; padding: 8px 0; }
.nav-group {
    font-size: 11px;
    color: rgba(255,255,255,.4);
    padding: 12px 20px 6px;
    text-transform: uppercase;
    letter-spacing: .5px;
}
.nav-item {
    display: block;
    color: rgba(255,255,255,.8);
    padding: 9px 20px;
    font-size: 13.5px;
    border-left: 3px solid transparent;
    transition: all .15s;
}
.nav-item:hover {
    background: rgba(255,255,255,.05);
    color: #fff;
    text-decoration: none;
}
.nav-item.active {
    background: var(--primary-light);
    color: #fff;
    border-left-color: var(--accent);
}

.sidebar-footer {
    border-top: 1px solid rgba(255,255,255,.1);
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.user-info { display: flex; align-items: center; gap: 8px; min-width: 0; }
.user-avatar {
    width: 32px; height: 32px;
    background: var(--accent);
    color: var(--primary);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-weight: 600;
    flex-shrink: 0;
}
.user-name { font-size: 13px; color: #fff; max-width: 110px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-role { font-size: 11px; color: rgba(255,255,255,.5); }
.btn-logout {
    color: rgba(255,255,255,.6);
    font-size: 18px;
    padding: 4px 8px;
    border-radius: 4px;
}
.btn-logout:hover { color: #fff; background: rgba(255,255,255,.1); text-decoration: none; }

/* ============ 卡片 ============ */
.card {
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 20px;
    overflow: hidden;
}
.card-header {
    padding: 14px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.card-title { padding: 14px 20px; font-weight: 600; font-size: 15px; border-bottom: 1px solid var(--border); }
.card-footer { padding: 12px 20px; border-top: 1px solid var(--border); text-align: right; }

.row { display: flex; gap: 20px; flex-wrap: wrap; }
.col-2 { flex: 1; min-width: 400px; }

/* ============ 统计卡 ============ */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}
.stat-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 18px 20px;
    box-shadow: var(--shadow);
    border-left: 4px solid var(--accent);
}
.stat-label { font-size: 13px; color: var(--text-muted); margin-bottom: 6px; }
.stat-value { font-size: 28px; font-weight: 600; color: var(--primary); }
.stat-sub   { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

/* ============ 表格 ============ */
.data-table {
    width: 100%;
    border-collapse: collapse;
}
.data-table th, .data-table td {
    padding: 10px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}
.data-table th {
    background: #fafbfc;
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .3px;
}
.data-table tr:hover { background: var(--hover); }
.data-table code { font-size: 12px; }

/* ============ 徽章 ============ */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
    background: #e0e0e0;
    color: #555;
}
.badge-success { background: #d4edda; color: #155724; }
.badge-danger  { background: #f8d7da; color: #721c24; }
.badge-warning { background: #fff3cd; color: #856404; }
.badge-info    { background: #d1ecf1; color: #0c5460; }
.badge-primary { background: #cfe2ff; color: #084298; }
.badge-muted   { background: #e9ecef; color: #495057; }

/* ============ 描边按钮 ============ */
.btn-outline {
    background: transparent;
    border: 1px solid var(--primary);
    color: var(--primary);
}
.btn-outline:hover { background: rgba(37,99,235,.08); }

/* ============ 表单 ============ */
.form-group { margin-bottom: 14px; }
.form-group label {
    display: block;
    margin-bottom: 5px;
    font-size: 13px;
    font-weight: 500;
    color: #444;
}
.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-family: inherit;
    background: #fff;
    transition: border-color .15s;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(14,42,71,.1);
}
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-actions { padding: 16px 0; text-align: right; }

/* ============ 按钮 ============ */
.btn {
    display: inline-block;
    padding: 7px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: #fff;
    color: var(--text);
    font-size: 13px;
    cursor: pointer;
    text-decoration: none;
    transition: all .15s;
}
.btn:hover { background: var(--hover); text-decoration: none; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-lg { padding: 10px 22px; font-size: 15px; }
.btn-block { display: block; width: 100%; text-align: center; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-light); border-color: var(--primary-light); color: #fff; }
.btn-success { background: var(--success); border-color: var(--success); color: #fff; }
.btn-danger  { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-warning { background: var(--warning); border-color: var(--warning); color: #212529; }
.btn-info    { background: var(--info); border-color: var(--info); color: #fff; }

/* ============ 弹窗 ============ */
.modal {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,.5);
    display: flex; align-items: center; justify-content: center;
    z-index: 100;
}
.modal-content {
    background: #fff;
    border-radius: var(--radius);
    width: 480px;
    max-width: 90vw;
    max-height: 90vh;
    overflow: auto;
    box-shadow: var(--shadow-md);
}
.modal-header {
    padding: 14px 20px;
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
    font-weight: 600;
}
.modal-close {
    cursor: pointer;
    color: var(--text-muted);
    font-size: 22px;
    line-height: 1;
}
.modal-body { padding: 20px; }
.modal-footer {
    padding: 12px 20px;
    border-top: 1px solid var(--border);
    display: flex; justify-content: flex-end; gap: 8px;
}

/* ============ 警告框 ============ */
.alert {
    padding: 10px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
    font-size: 13.5px;
    border: 1px solid transparent;
}
.alert-success { background: #d4edda; color: #155724; border-color: #c3e6cb; }
.alert-danger  { background: #f8d7da; color: #721c24; border-color: #f5c6cb; }
.alert-warning { background: #fff3cd; color: #856404; border-color: #ffeeba; }
.alert-info    { background: #d1ecf1; color: #0c5460; border-color: #bee5eb; }

/* ============ 标签页 ============ */
.tabs {
    display: flex;
    border-bottom: 2px solid var(--border);
    margin-bottom: 20px;
}
.tab {
    padding: 10px 18px;
    color: var(--text-muted);
    font-size: 14px;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
}
.tab:hover { color: var(--text); text-decoration: none; }
.tab.active {
    color: var(--primary);
    border-bottom-color: var(--accent);
    font-weight: 600;
}

/* ============ 搜索栏 ============ */
.search-bar {
    padding: 14px 20px;
    display: flex;
    gap: 8px;
    align-items: center;
    border-bottom: 1px solid var(--border);
    background: #fafbfc;
    flex-wrap: wrap;
}
.search-bar input,
.search-bar select {
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 13px;
}
.search-bar label { font-size: 13px; color: var(--text-muted); }

/* ============ 列表 ============ */
.check-list, .info-list {
    list-style: none;
    padding: 0;
    margin: 0;
}
.check-list li, .info-list li {
    padding: 8px 20px;
    border-bottom: 1px solid var(--border);
    font-size: 13.5px;
}
.check-list li:last-child, .info-list li:last-child { border-bottom: 0; }
.check-list li.warn { color: var(--warning); background: #fff8e6; }
.check-list li.danger { color: var(--danger); background: #fbe9eb; }

/* ============ 分页 ============ */
.pagination {
    padding: 14px 20px;
    text-align: center;
    display: flex;
    gap: 4px;
    justify-content: center;
    align-items: center;
}
.page-link {
    padding: 4px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 13px;
}
.page-link.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}
.page-link:hover { background: var(--hover); text-decoration: none; }
.page-info { font-size: 12px; color: var(--text-muted); margin-left: 12px; }

/* ============ 登录页 ============ */
.login-page {
    background: linear-gradient(135deg, var(--primary) 0%, #1a3a5c 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.login-box {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(0,0,0,.2);
    padding: 32px;
    width: 400px;
    max-width: 90vw;
}
.login-header { text-align: center; margin-bottom: 24px; }
.login-logo {
    width: 60px; height: 60px;
    background: var(--accent);
    color: var(--primary);
    font-size: 30px; font-weight: 700;
    display: inline-flex; align-items: center; justify-content: center;
    border-radius: 50%;
    margin-bottom: 12px;
}
.login-title { font-size: 18px; color: var(--primary); margin-bottom: 4px; }
.login-sub   { font-size: 12px; color: var(--text-muted); }
.login-form  { margin-top: 8px; }
.login-form .btn { margin-top: 16px; }
.login-footer {
    margin-top: 24px;
    text-align: center;
    color: var(--text-muted);
    font-size: 12px;
    border-top: 1px solid var(--border);
    padding-top: 16px;
}
.login-tip { margin-top: 4px; color: var(--accent); }

.install-box { width: 600px; }
.install-box h1 { color: var(--primary); margin-bottom: 20px; }
.install-box h3 { color: var(--primary); margin: 16px 0 8px; font-size: 14px; border-left: 3px solid var(--accent); padding-left: 8px; }

/* ============ 响应式 ============ */
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); transition: transform .3s; }
    .sidebar.open { transform: translateX(0); }
    .main { margin-left: 0; }
    .row { flex-direction: column; }
    .col-2 { min-width: 0; }
    .form-row { grid-template-columns: 1fr; }
}
