/* ===== 自动播报 · Enterprise Admin Theme ===== */
:root {
    --sidebar-w: 248px;
    --sidebar-bg: #0f172a;
    --sidebar-text: #94a3b8;
    --sidebar-hover: #1e293b;
    --sidebar-active: #2563eb;
    --topbar-h: 64px;
    --main-bg: #f1f5f9;
    --card-bg: #ffffff;
    --text: #0f172a;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --danger: #ef4444;
    --success: #16a34a;
    --radius: 12px;
    --shadow: 0 1px 3px rgba(15, 23, 42, 0.08), 0 4px 12px rgba(15, 23, 42, 0.04);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

body {
    margin: 0;
    font-family: "Segoe UI", -apple-system, BlinkMacSystemFont, "Microsoft YaHei", sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: var(--text);
    background: var(--main-bg);
}

a { color: var(--primary); text-decoration: none; }
.muted { color: var(--text-muted); font-size: 0.875rem; }
.error { color: var(--danger); min-height: 1.2em; word-break: break-word; margin-top: 8px; }
.success { color: var(--success); min-height: 1.2em; word-break: break-word; }
.test-hint { margin: 8px 0 0; font-size: 0.85rem; line-height: 1.45; color: var(--text-muted); }

/* ===== 表单 ===== */
label {
    display: block;
    margin-bottom: 14px;
    font-size: 0.875rem;
    font-weight: 500;
    color: #334155;
}

input:not([type="checkbox"]):not([type="radio"]),
select,
textarea {
    width: 100%;
    margin-top: 6px;
    padding: 10px 12px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: #fff;
    color: var(--text);
    font-size: 14px;
    min-height: 42px;
    transition: border-color 0.15s, box-shadow 0.15s;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

input[type="checkbox"], input[type="radio"] {
    width: 18px; height: 18px; min-height: 18px; min-width: 18px;
    margin: 0; accent-color: var(--primary); cursor: pointer;
}

textarea { min-height: 96px; resize: vertical; line-height: 1.45; }

select {
    background-image: linear-gradient(45deg, transparent 50%, #64748b 50%), linear-gradient(135deg, #64748b 50%, transparent 50%);
    background-position: calc(100% - 16px) calc(50% + 1px), calc(100% - 10px) calc(50% + 1px);
    background-size: 5px 5px, 5px 5px;
    background-repeat: no-repeat;
    padding-right: 32px;
}

/* ===== 按钮 ===== */
.btn {
    display: inline-flex; align-items: center; justify-content: center;
    padding: 10px 16px; min-height: 40px; border-radius: 8px;
    border: none; cursor: pointer; font-size: 0.875rem; font-weight: 500;
    touch-action: manipulation; user-select: none; transition: background 0.15s, transform 0.1s;
}
.btn.primary { background: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-hover); }
.btn.danger { background: var(--danger); color: #fff; }
.btn.ghost { background: #fff; color: var(--text); border: 1px solid var(--border); }
.btn.ghost:hover { background: #f8fafc; }
.btn-sm { min-height: 36px; padding: 8px 14px; font-size: 0.8125rem; }
.btn-block { width: 100%; }
.btn:active { transform: scale(0.98); }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.btn-row .btn { margin: 0; }

.btn-icon {
    display: none; background: none; border: none; font-size: 1.25rem;
    cursor: pointer; padding: 8px; color: var(--text);
}

/* ===== 登录页 ===== */
.login-page { min-height: 100vh; min-height: 100dvh; background: var(--main-bg); }

.login-shell {
    min-height: 100vh; min-height: 100dvh;
    display: grid; grid-template-columns: 1fr 1fr;
}

.login-hero {
    background: linear-gradient(135deg, #0f172a 0%, #1e3a5f 50%, #2563eb 100%);
    color: #fff; display: flex; align-items: center; justify-content: center; padding: 48px;
}

.login-hero-inner { max-width: 400px; }
.login-hero h2 { margin: 16px 0 8px; font-size: 2rem; font-weight: 700; }
.login-hero p { margin: 0 0 32px; opacity: 0.75; }
.login-features { list-style: none; padding: 0; margin: 0; }
.login-features li {
    padding: 10px 0; padding-left: 24px; position: relative; opacity: 0.9;
}
.login-features li::before {
    content: "✓"; position: absolute; left: 0; color: #93c5fd; font-weight: bold;
}

.login-form-wrap {
    display: flex; align-items: center; justify-content: center; padding: 32px;
}

.brand-logo {
    width: 40px; height: 40px; border-radius: 10px;
    background: linear-gradient(135deg, #2563eb, #0ea5e9);
    color: #fff; font-weight: 800; font-size: 1.1rem;
    display: flex; align-items: center; justify-content: center;
}
.brand-logo.lg { width: 56px; height: 56px; font-size: 1.5rem; border-radius: 14px; }

.card {
    background: var(--card-bg); border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: var(--shadow);
}
.login-card { width: 100%; max-width: 420px; padding: 32px; }
.login-card h1 { margin: 0 0 6px; font-size: 1.5rem; font-weight: 700; }

/* ===== Admin 布局 ===== */
body.admin-app {
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
}

.admin-app { overflow: hidden; }

.admin-layout {
    display: flex;
    height: 100vh;
    height: 100dvh;
    min-height: 0;
}

.sidebar {
    width: var(--sidebar-w); flex-shrink: 0;
    background: var(--sidebar-bg); color: var(--sidebar-text);
    display: flex; flex-direction: column;
    border-right: 1px solid rgba(255,255,255,0.06);
    z-index: 200;
    min-height: 0;
    overflow: hidden;
}

.sidebar-brand {
    display: flex; align-items: center; gap: 12px;
    padding: 20px 18px; border-bottom: 1px solid rgba(255,255,255,0.06);
}
.sidebar-brand .brand-logo { flex-shrink: 0; }
.brand-text { display: flex; flex-direction: column; line-height: 1.3; }
.brand-text strong { color: #f1f5f9; font-size: 1rem; }
.brand-text span { font-size: 0.7rem; opacity: 0.55; text-transform: uppercase; letter-spacing: 0.04em; }

.sidebar-nav { flex: 1; min-height: 0; padding: 12px 10px; overflow-y: auto; }

.sidebar-nav .tab {
    display: flex; align-items: center; gap: 10px;
    padding: 11px 14px; margin-bottom: 4px; border-radius: 8px;
    cursor: pointer; font-size: 0.875rem; color: var(--sidebar-text);
    transition: background 0.15s, color 0.15s; user-select: none;
}
.sidebar-nav .tab:hover { background: var(--sidebar-hover); color: #e2e8f0; }
.sidebar-nav .tab.active {
    background: var(--sidebar-active); color: #fff; font-weight: 500;
}
.nav-icon { font-size: 1rem; width: 22px; text-align: center; flex-shrink: 0; }

.sidebar-footer {
    padding: 14px 18px; font-size: 0.75rem;
    border-top: 1px solid rgba(255,255,255,0.06);
}

.main-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
}

.topbar {
    height: var(--topbar-h); flex-shrink: 0;
    display: flex; align-items: center; gap: 16px;
    padding: 0 24px; background: #fff;
    border-bottom: 1px solid var(--border);
    box-shadow: 0 1px 2px rgba(15,23,42,0.04);
}

.topbar-title { flex: 1; min-width: 0; }
.topbar-title h1 { margin: 0; font-size: 1.125rem; font-weight: 700; color: var(--text); }
.topbar-title p { margin: 2px 0 0; font-size: 0.8125rem; }

.topbar-actions { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
.user-badge {
    font-size: 0.8125rem; font-weight: 500; color: var(--text);
    background: #f1f5f9; padding: 6px 12px; border-radius: 999px;
}

.content-area {
    flex: 1;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    padding: 24px;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

.panel { display: none; }
.panel.active { display: block; }

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

.card.section { margin-bottom: 20px; overflow: hidden; }
.card.section.compact { margin-bottom: 16px; }
.card-header {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 16px 20px; border-bottom: 1px solid var(--border); background: #fafbfc;
}
.card-header h3 { margin: 0; font-size: 0.9375rem; font-weight: 600; }
.card-body { padding: 20px; }

.inline-search { margin: 0; flex: 1; max-width: 280px; }
.inline-search input { margin-top: 0; }

.grid2 {
    display: grid; grid-template-columns: 1fr 1fr; gap: 12px;
}

.row-inline {
    display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap;
}
.row-inline label { flex: 1; min-width: 200px; margin-bottom: 0; }
.row-inline .btn { margin-bottom: 0; flex-shrink: 0; }

.checkbox {
    display: flex; align-items: center; gap: 10px;
    margin-bottom: 10px; min-height: 40px; cursor: pointer;
}

/* ===== 用户列表 ===== */
.user-table-wrap { display: flex; flex-direction: column; gap: 8px; }

#user-list .user-item {
    display: flex; flex-wrap: wrap; align-items: center; gap: 12px;
    padding: 14px 16px; background: #f8fafc;
    border: 1px solid var(--border); border-radius: 8px;
    transition: border-color 0.15s;
}
#user-list .user-item:hover { border-color: #cbd5e1; }

#user-list .user-meta { flex: 1 1 160px; font-size: 0.875rem; line-height: 1.4; }
#user-list .user-meta strong { display: block; font-size: 0.9375rem; color: var(--text); margin-bottom: 2px; }

#user-list .user-role-edit {
    display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
    flex: 1 1 240px;
}
#user-list .user-role-edit select { flex: 1; min-width: 120px; margin-top: 0; }
#user-list .user-role-edit .btn { margin: 0; min-height: 40px; }

.user-list-empty { text-align: center; padding: 32px; color: var(--text-muted); }

/* ===== 话术 ===== */
.panel-questions-layout {
    display: grid; grid-template-columns: 1fr 1fr; gap: 20px;
}

.question-list {
    list-style: none; padding: 0; margin: 0;
    max-height: 480px; overflow: auto;
}

.question-list li {
    padding: 12px 14px; border: 1px solid var(--border); border-radius: 8px;
    margin-bottom: 8px; cursor: pointer; font-size: 0.875rem; line-height: 1.45;
    background: #fff; transition: border-color 0.15s, background 0.15s;
}
.question-list li:hover { background: #f8fafc; }
.question-list li.selected { border-color: var(--primary); background: #eff6ff; }

.question-list li .q-item-preset {
    display: block; margin-top: 4px; font-size: 0.8rem; color: var(--text-muted);
}

.action-row { display: flex; gap: 8px; margin-top: 12px; }
.action-row .btn { margin: 0; }

/* ===== 日志 ===== */
.log-list { max-height: 65vh; overflow: auto; }

.log-item {
    padding: 14px 0; border-bottom: 1px solid var(--border);
    font-size: 0.875rem; line-height: 1.5;
}
.log-item:last-child { border-bottom: none; }
.log-item .log-time { font-size: 0.75rem; color: var(--text-muted); margin-bottom: 4px; }
.log-item .log-status {
    display: inline-block; font-size: 0.7rem; font-weight: 600;
    padding: 2px 8px; border-radius: 4px; margin-left: 8px;
}
.log-item .log-status.ok { background: #dcfce7; color: #166534; }
.log-item .log-status.error { background: #fee2e2; color: #991b1b; }
.log-item .log-status.info { background: #dbeafe; color: #1e40af; }

/* ===== 新建用户 API ===== */
.new-user-api {
    margin: 12px 0; padding: 14px; background: #f8fafc;
    border: 1px solid var(--border); border-radius: 8px;
}
.new-user-api summary { cursor: pointer; font-weight: 500; user-select: none; min-height: 36px; display: flex; align-items: center; }
.new-user-api-body { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); }
.new-user-api-body h4 { margin: 16px 0 8px; font-size: 0.8125rem; color: var(--primary); font-weight: 600; }
.new-user-api-body h4:first-child { margin-top: 0; }

/* ===== 响应式 ===== */
@media (max-width: 1024px) {
    .page-grid, .panel-questions-layout { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
    .login-shell { grid-template-columns: 1fr; }
    .login-hero { display: none; }

    .btn-icon { display: block; }

    .sidebar {
        position: fixed; left: 0; top: 0; bottom: 0;
        transform: translateX(-100%); transition: transform 0.25s ease;
    }
    .sidebar.open { transform: translateX(0); box-shadow: 4px 0 24px rgba(0,0,0,0.2); }

    .topbar { padding: 0 16px; }
    .content-area { padding: 16px; }
    .grid2 { grid-template-columns: 1fr; }

    #user-list .user-item { flex-direction: column; align-items: stretch; }
    #user-list .user-role-edit { flex-direction: column; }
    #user-list .user-role-edit select, #user-list .user-role-edit .btn { width: 100%; }
}

@media (min-width: 769px) {
    .mobile-menu { display: none !important; }
}
