/* 百寶袋后台管理 - enterprise_hub 风格 */
:root {
    --primary: #01A4EA;
    --primary-dark: #0188C2;
    --primary-light: #E5F6FD;
    --danger: #E70012;
    --danger-light: #FDE5E7;
    --success: #27ae60;
    --warning: #E68A00;
    --bg: #F4F9F9;
    --slate-50: #f8fafc;
    --slate-100: #f1f5f9;
    --slate-200: #e2e8f0;
    --slate-500: #64748b;
    --slate-700: #334155;
    --slate-800: #1e293b;
    --sidebar-w: 240px;
    --radius: 12px;
    --radius-lg: 24px;
    --shadow: 0 2px 12px rgba(1,164,234,.08);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'PingFang TC', 'Microsoft JhengHei', sans-serif;
    background: var(--bg);
    color: #2c3e50;
    min-height: 100vh;
}

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

/* ---- 登录页 ---- */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg);
    padding: 20px;
}

.login-card {
    background: white;
    border-radius: var(--radius-lg);
    padding: 48px 40px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 8px 32px rgba(1,164,234,.12);
    border: 1px solid var(--slate-100);
    text-align: center;
}

.login-card .logo {
    width: 64px;
    height: 64px;
    margin: 0 auto 16px;
    background: var(--primary-light);
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.login-card .logo svg { width: 32px; height: 32px; color: var(--primary); }
.login-back { margin-top: 20px; font-size: .85rem; }
.login-back a { display: inline-flex; align-items: center; gap: 6px; color: var(--primary); font-weight: 600; }
.login-back a:hover { text-decoration: none; opacity: .85; }
.login-card h1 { color: var(--slate-800); font-size: 1.5rem; font-weight: 900; margin-bottom: 4px; }
.login-card .sub { color: var(--slate-500); font-size: .9rem; margin-bottom: 32px; font-weight: 500; }

.form-group { margin-bottom: 20px; text-align: left; }
.form-group label { display: block; font-size: .875rem; font-weight: 600; margin-bottom: 6px; color: #555; }
.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 16px;
    border: 1px solid var(--slate-200);
    border-radius: var(--radius);
    font-size: .95rem;
    font-family: inherit;
    outline: none;
    background: var(--slate-50);
    transition: all .2s;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: var(--primary);
    background: #fff;
    box-shadow: 0 0 0 3px rgba(1,164,234,.15);
}
.form-group textarea { resize: vertical; min-height: 80px; }

.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius);
    font-size: .9rem;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: all .2s;
}
.btn-primary { background: var(--primary); color: white; box-shadow: 0 2px 8px rgba(1,164,234,.25); }
.btn-primary:hover { background: var(--primary-dark); }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #C9000F; }
.btn-secondary { background: #ecf0f1; color: #555; }
.btn-secondary:hover { background: #dde4e6; }
.btn-sm { padding: 6px 12px; font-size: .8rem; }
.btn-block { width: 100%; justify-content: center; }

.alert {
    padding: 12px 16px;
    border-radius: var(--radius);
    margin-bottom: 20px;
    font-size: .9rem;
}
.alert-error { background: #fdecea; color: #c0392b; border: 1px solid #f5c6cb; }
.alert-success { background: #d4edda; color: #155724; border: 1px solid #c3e6cb; }

/* ---- 后台布局 ---- */
.admin-layout { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sidebar-w);
    background: linear-gradient(180deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    padding: 24px 0;
    flex-shrink: 0;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    overflow-y: auto;
}

.sidebar-brand {
    padding: 0 20px 24px;
    border-bottom: 1px solid rgba(255,255,255,.15);
    margin-bottom: 16px;
}
.sidebar-brand .logo {
    width: 48px;
    height: 48px;
    background: rgba(255,255,255,.15);
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 8px;
}
.sidebar-brand .logo svg { width: 24px; height: 24px; }
.sidebar-brand h2 { font-size: 1.1rem; margin-top: 4px; }
.sidebar-brand p { font-size: .75rem; opacity: .7; margin-top: 2px; }

.sidebar-nav a svg { width: 18px; height: 18px; flex-shrink: 0; opacity: .9; }

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 20px;
    color: rgba(255,255,255,.85);
    text-decoration: none;
    font-size: .9rem;
    transition: background .2s;
}
.sidebar-nav a:hover,
.sidebar-nav a.active {
    background: rgba(255,255,255,.15);
    color: white;
    text-decoration: none;
}

.main-content {
    margin-left: var(--sidebar-w);
    flex: 1;
    padding: 32px;
    min-width: 0;
}

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 28px;
    flex-wrap: wrap;
    gap: 12px;
}
.page-header h1 { font-size: 1.5rem; color: var(--primary-dark); }

/* ---- 统计卡片 ---- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 32px;
}
.stat-card {
    background: white;
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
    text-align: center;
}
.stat-card .num { font-size: 2rem; font-weight: 800; color: var(--primary); }
.stat-card .label { font-size: .85rem; color: #888; margin-top: 4px; }

/* ---- 表格 ---- */
.card {
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    border: 1px solid var(--slate-100);
    overflow: hidden;
}
.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid #f0f4f8;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
}
.card-header h2 { font-size: 1rem; font-weight: 700; }
.card-body { padding: 20px; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { padding: 12px 16px; text-align: left; border-bottom: 1px solid #f0f4f8; }
th { background: #f8fbfd; font-weight: 600; color: #555; font-size: .8rem; text-transform: uppercase; letter-spacing: .5px; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: #f8fbfd; }

.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 50px;
    font-size: .75rem;
    font-weight: 600;
}
.badge-active { background: #d4edda; color: #155724; }
.badge-inactive { background: #f8d7da; color: #721c24; }
.badge-system { background: #e3f2fd; color: #1565c0; }
.badge-tool { background: #fff3e0; color: #e65100; }
.badge-url { background: #e8f5e9; color: #2e7d32; }

.actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* ---- 模态框 ---- */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.4);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.modal-overlay.open { display: flex; }
.modal {
    background: white;
    border-radius: 16px;
    width: 100%;
    max-width: 560px;
    max-height: calc(100vh - 32px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0,0,0,.2);
}
.modal form {
    display: flex;
    flex-direction: column;
    min-height: 0;
}
.modal-header {
    padding: 14px 18px 12px;
    border-bottom: 1px solid #f0f4f8;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}
.modal-header h3 { font-size: 1rem; font-weight: 700; }
.modal-close {
    background: none;
    border: none;
    font-size: 1.4rem;
    cursor: pointer;
    color: #aaa;
    line-height: 1;
}
.modal-body { padding: 24px; }
.modal-body-compact {
    padding: 14px 18px 10px;
    overflow-y: auto;
}
.modal-body-compact .form-group {
    margin-bottom: 10px;
}
.modal-body-compact .form-group label {
    font-size: .8rem;
    margin-bottom: 4px;
}
.modal-body-compact .form-group input,
.modal-body-compact .form-group select {
    padding: 7px 10px;
    font-size: .875rem;
}
.modal-body-compact .form-row {
    gap: 10px;
}
.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid #f0f4f8;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    flex-shrink: 0;
    background: #fff;
}
.modal-footer-split {
    padding: 10px 18px;
    justify-content: space-between;
    align-items: center;
}
.footer-check {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: .875rem;
    font-weight: 600;
    color: var(--slate-700);
    cursor: pointer;
    margin: 0;
}
.footer-check input { width: auto; margin: 0; }
.footer-actions { display: flex; gap: 8px; }
.footer-actions .btn { padding: 8px 16px; font-size: .85rem; }

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

/* Lucide 图标 */
.icon-cell {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: var(--primary-light);
    border-radius: 12px;
    color: var(--primary);
}
.icon-cell svg { width: 20px; height: 20px; }

.icon-picker {
    display: grid;
    grid-template-columns: repeat(10, 1fr);
    gap: 5px;
    margin-top: 6px;
    max-height: 72px;
    overflow-y: auto;
}
.icon-picker.is-collapsed { display: none; }
.icon-picker-bar {
    display: flex;
    align-items: center;
    gap: 10px;
}
.icon-picker-preview {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    background: var(--primary-light);
    color: var(--primary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.icon-picker-preview svg { width: 18px; height: 18px; }
.btn-icon-toggle {
    padding: 6px 12px;
    border: 1px solid var(--slate-200);
    border-radius: 8px;
    background: var(--slate-50);
    color: var(--slate-700);
    font-size: .8rem;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: all .15s;
}
.btn-icon-toggle:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-light);
}
.form-group-icon { margin-bottom: 8px !important; }
.icon-picker-btn {
    padding: 5px;
    border: none;
    border-radius: 8px;
    background: var(--slate-50);
    color: var(--slate-500);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all .15s;
    width: 30px;
    height: 30px;
}
.icon-picker-btn svg { width: 16px; height: 16px; }
.icon-picker-btn:hover { background: var(--slate-200); color: var(--slate-700); }
.icon-picker-btn.active {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 1px 4px rgba(1,164,234,.3);
}

@media (max-width: 768px) {
    .icon-picker { grid-template-columns: repeat(5, 1fr); }
    .sidebar { display: none; }
    .main-content { margin-left: 0; padding: 16px; }
    .form-row { grid-template-columns: 1fr; }
}
