/* QQ机器人管理平台 - 全局样式 */

:root {
    --primary: #1890ff;
    --primary-dark: #096dd9;
    --primary-light: #e6f7ff;
    --success: #52c41a;
    --warning: #faad14;
    --danger: #ff4d4f;
    --info: #1890ff;
    --text-primary: #262626;
    --text-secondary: #595959;
    --text-muted: #8c8c8c;
    --bg-base: #f0f2f5;
    --bg-white: #ffffff;
    --border-color: #d9d9d9;
    --border-light: #f0f0f0;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.12);
    --radius: 8px;
    --radius-sm: 4px;
    --radius-lg: 12px;
    --sidebar-width: 240px;
    --header-height: 56px;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
    font-size: 14px;
    color: var(--text-primary);
    background: var(--bg-base);
    line-height: 1.6;
}

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

a:hover {
    color: var(--primary-dark);
}

/* ========== 登录页面 ========== */

.login-page {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.login-container {
    background: var(--bg-white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 40px;
    width: 400px;
    max-width: 90vw;
}

.login-header {
    text-align: center;
    margin-bottom: 32px;
}

.login-header .logo {
    font-size: 36px;
    margin-bottom: 8px;
}

.login-header h1 {
    font-size: 22px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.login-header p {
    color: var(--text-muted);
    font-size: 13px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    color: var(--text-secondary);
    font-size: 13px;
}

.form-control {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 14px;
    transition: border-color 0.3s, box-shadow 0.3s;
    outline: none;
    background: var(--bg-white);
}

.form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(24, 144, 255, 0.2);
}

.form-control::placeholder {
    color: #bfbfbf;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 16px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s;
    gap: 6px;
    line-height: 1.5;
}

.btn:disabled {
    opacity: 0.65;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

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

.btn-success {
    background: var(--success);
    color: white;
    border-color: var(--success);
}

.btn-success:hover {
    background: #389e0d;
}

.btn-danger {
    background: var(--danger);
    color: white;
    border-color: var(--danger);
}

.btn-danger:hover {
    background: #cf1322;
}

.btn-warning {
    background: var(--warning);
    color: white;
    border-color: var(--warning);
}

.btn-outline {
    background: transparent;
    color: var(--text-secondary);
    border-color: var(--border-color);
}

.btn-outline:hover {
    color: var(--primary);
    border-color: var(--primary);
}

.btn-sm {
    padding: 4px 12px;
    font-size: 13px;
}

.btn-lg {
    padding: 12px 24px;
    font-size: 16px;
}

.btn-block {
    width: 100%;
}

.login-footer {
    text-align: center;
    margin-top: 20px;
}

.login-footer a {
    font-size: 13px;
    color: var(--text-muted);
}

.alert {
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
    font-size: 13px;
    display: none;
}

.alert.show {
    display: block;
}

.alert-error {
    background: #fff2f0;
    border: 1px solid #ffccc7;
    color: var(--danger);
}

.alert-success {
    background: #f6ffed;
    border: 1px solid #b7eb8f;
    color: var(--success);
}

.alert-info {
    background: var(--primary-light);
    border: 1px solid #91d5ff;
    color: var(--primary);
}

/* ========== 布局 ========== */

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

.sidebar {
    width: var(--sidebar-width);
    background: #001529;
    color: #fff;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    overflow-y: auto;
    transition: width 0.3s;
}

.sidebar-header {
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-header .logo {
    font-size: 24px;
}

.sidebar-header h2 {
    font-size: 16px;
    font-weight: 600;
    white-space: nowrap;
}

.sidebar-menu {
    list-style: none;
    padding: 8px 0;
}

.sidebar-menu li {
    margin: 2px 0;
}

.sidebar-menu a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 20px;
    color: rgba(255,255,255,0.65);
    font-size: 14px;
    transition: all 0.3s;
}

.sidebar-menu a:hover,
.sidebar-menu a.active {
    color: #fff;
    background: var(--primary);
}

.sidebar-menu a .icon {
    font-size: 18px;
    width: 20px;
    text-align: center;
}

.sidebar-footer {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 12px 20px;
    border-top: 1px solid rgba(255,255,255,0.1);
}

.sidebar-footer a {
    display: flex;
    align-items: center;
    gap: 10px;
    color: rgba(255,255,255,0.5);
    font-size: 13px;
    padding: 8px 0;
    transition: color 0.3s;
}

.sidebar-footer a:hover {
    color: #fff;
}

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

.content-header {
    background: var(--bg-white);
    padding: 16px 24px;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 50;
    box-shadow: var(--shadow-sm);
}

.content-header h1 {
    font-size: 18px;
    font-weight: 600;
}

.content-header .header-actions {
    display: flex;
    gap: 12px;
    align-items: center;
}

.content-body {
    padding: 24px;
}

/* ========== 卡片 ========== */

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

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

.card-header h3 {
    font-size: 16px;
    font-weight: 600;
}

.card-body {
    padding: 20px;
}

.card-footer {
    padding: 12px 20px;
    border-top: 1px solid var(--border-light);
    background: #fafafa;
}

/* ========== 统计卡片 ========== */

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--bg-white);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: center;
    gap: 16px;
}

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

.stat-icon.blue { background: #e6f7ff; color: var(--primary); }
.stat-icon.green { background: #f6ffed; color: var(--success); }
.stat-icon.orange { background: #fff7e6; color: var(--warning); }
.stat-icon.red { background: #fff2f0; color: var(--danger); }

.stat-info h4 {
    font-size: 24px;
    font-weight: 700;
    line-height: 1.2;
}

.stat-info p {
    color: var(--text-muted);
    font-size: 13px;
}

/* ========== 表格 ========== */

.table-wrapper {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

thead th {
    background: #fafafa;
    padding: 12px 16px;
    text-align: left;
    font-weight: 600;
    font-size: 13px;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-light);
    white-space: nowrap;
}

tbody td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-light);
    font-size: 14px;
}

tbody tr:hover {
    background: #fafafa;
}

tbody tr:last-child td {
    border-bottom: none;
}

/* ========== 状态标签 ========== */

.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 12px;
    font-weight: 500;
    gap: 4px;
}

.badge-online {
    background: #f6ffed;
    color: var(--success);
}

.badge-offline {
    background: #f5f5f5;
    color: var(--text-muted);
}

.badge-error {
    background: #fff2f0;
    color: var(--danger);
}

.badge-active {
    background: #f6ffed;
    color: var(--success);
}

.badge-disabled {
    background: #fff2f0;
    color: var(--danger);
}

.badge-dot::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
}

/* ========== 模态框 ========== */

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.45);
    z-index: 1000;
    display: none;
    justify-content: center;
    align-items: center;
}

.modal-overlay.show {
    display: flex;
}

.modal {
    background: var(--bg-white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 520px;
    max-width: 90vw;
    max-height: 80vh;
    overflow-y: auto;
}

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

.modal-header h3 {
    font-size: 16px;
    font-weight: 600;
}

.modal-close,
.btn-close {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: var(--text-muted);
    padding: 4px;
    line-height: 1;
}

.modal-close:hover,
.btn-close:hover {
    color: var(--text-primary);
}

.modal-body {
    padding: 24px;
}

.modal-footer {
    padding: 12px 24px;
    border-top: 1px solid var(--border-light);
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

/* ========== 日志 ========== */

.log-list {
    max-height: 400px;
    overflow-y: auto;
}

.log-item {
    padding: 8px 16px;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    align-items: flex-start;
    gap: 12px;
    font-size: 13px;
}

.log-item:last-child {
    border-bottom: none;
}

.log-time {
    color: var(--text-muted);
    white-space: nowrap;
    font-size: 12px;
    min-width: 140px;
}

.log-type {
    font-weight: 500;
    min-width: 50px;
}

.log-type.info { color: var(--primary); }
.log-type.warning { color: var(--warning); }
.log-type.error { color: var(--danger); }
.log-type.bot { color: var(--success); }

.log-message {
    flex: 1;
    word-break: break-all;
}

/* ========== 机器人卡片 ========== */

.bot-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 16px;
}

.bot-card {
    background: var(--bg-white);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 20px;
    border: 1px solid var(--border-light);
    transition: box-shadow 0.3s;
}

.bot-card:hover {
    box-shadow: var(--shadow-md);
}

.bot-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.bot-card-header h4 {
    font-size: 16px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.bot-card-info {
    margin-bottom: 16px;
}

.bot-card-info .info-row {
    display: flex;
    align-items: center;
    padding: 4px 0;
    font-size: 13px;
    color: var(--text-secondary);
}

.bot-card-info .info-row .label {
    min-width: 80px;
    color: var(--text-muted);
}

.bot-card-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* ========== 空状态 ========== */

.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-muted);
}

.empty-state .icon {
    font-size: 48px;
    margin-bottom: 12px;
}

.empty-state p {
    margin-bottom: 16px;
}

/* ========== 复选框组 ========== */

.checkbox-group {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 8px;
}

.checkbox-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    padding: 6px 0;
}

.checkbox-item input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--primary);
}

/* ========== 消息测试 ========== */

.message-test {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.message-test textarea {
    width: 100%;
    min-height: 100px;
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-family: monospace;
    resize: vertical;
}

/* ========== Toast 消息 ========== */

.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    padding: 12px 20px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
    animation: slideIn 0.3s ease;
    max-width: 400px;
}

.toast-success {
    background: #f6ffed;
    border: 1px solid #b7eb8f;
    color: #389e0d;
}

.toast-error {
    background: #fff2f0;
    border: 1px solid #ffccc7;
    color: #cf1322;
}

.toast-info {
    background: var(--primary-light);
    border: 1px solid #91d5ff;
    color: var(--primary);
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* ========== 响应式 ========== */

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }
    
    .sidebar.show {
        transform: translateX(0);
    }
    
    .main-content {
        margin-left: 0;
    }
    
    .stats-grid {
        grid-template-columns: 1fr 1fr;
    }
    
    .bot-grid {
        grid-template-columns: 1fr;
    }
    
    .login-container {
        padding: 24px;
    }
    
    .message-test {
        grid-template-columns: 1fr;
    }
}

/* ========== 选择框样式 ========== */

select.form-control {
    appearance: auto;
}

/* ========== Loading ========== */

.loading {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.loading::after {
    content: '';
    width: 16px;
    height: 16px;
    border: 2px solid var(--border-color);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ========== 操作按钮组 ========== */

.action-buttons {
    display: flex;
    gap: 4px;
}

.action-buttons .btn {
    padding: 4px 8px;
    font-size: 12px;
}

/* ========== 官机过审现代化皮肤 ========== */
:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --primary-light: #eef2ff;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --bg-base: #f6f8ff;
    --bg-darker: #f1f5f9;
    --border: #e5e7eb;
}

.modern-login-page {
    background: radial-gradient(circle at 18% 20%, rgba(99,102,241,.35), transparent 28%), radial-gradient(circle at 82% 12%, rgba(14,165,233,.28), transparent 26%), linear-gradient(135deg, #0f172a 0%, #1e1b4b 52%, #312e81 100%) !important;
}

.modern-login-page .login-container {
    border: 1px solid rgba(255,255,255,.32);
    background: rgba(255,255,255,.92);
    backdrop-filter: blur(18px);
    box-shadow: 0 28px 70px rgba(15,23,42,.35);
}

.modern-login-page .login-header .logo {
    width: 64px;
    height: 64px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 22px;
    background: linear-gradient(135deg,#6366f1,#06b6d4);
    box-shadow: 0 16px 30px rgba(99,102,241,.35);
}

.sidebar {
    background: linear-gradient(180deg,#0f172a 0%,#111827 50%,#020617 100%) !important;
    box-shadow: 12px 0 35px rgba(15,23,42,.12);
}

.sidebar-header {
    padding: 22px 20px;
}

.sidebar-header .logo {
    width: 38px;
    height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 14px;
    background: linear-gradient(135deg,#6366f1,#22d3ee);
}

.sidebar-menu a {
    margin: 4px 10px;
    border-radius: 14px;
    padding: 12px 14px;
}

.sidebar-menu a:hover,
.sidebar-menu a.active {
    background: linear-gradient(135deg,#6366f1,#4f46e5);
    box-shadow: 0 10px 24px rgba(99,102,241,.28);
}

.main-content {
    background: radial-gradient(circle at top right, rgba(99,102,241,.10), transparent 26%), var(--bg-base);
}

.content-header {
    margin-bottom: 18px;
}

.content-header h1 {
    letter-spacing: -0.5px;
}

.card,
.stat-card,
.bot-card {
    border: 1px solid rgba(226,232,240,.95);
    border-radius: 22px;
    box-shadow: 0 18px 45px rgba(15,23,42,.07);
    transition: transform .22s ease, box-shadow .22s ease, border-color .22s ease;
}

.card:hover,
.bot-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 24px 60px rgba(15,23,42,.10);
    border-color: rgba(99,102,241,.28);
}

.btn {
    border-radius: 12px;
    font-weight: 700;
}

.btn-primary {
    background: linear-gradient(135deg,#6366f1,#4f46e5);
    border-color: transparent;
    box-shadow: 0 12px 24px rgba(99,102,241,.24);
}

.btn-primary:hover {
    background: linear-gradient(135deg,#4f46e5,#4338ca);
    transform: translateY(-1px);
}

.btn-success {
    background: linear-gradient(135deg,#10b981,#059669);
    border-color: transparent;
    box-shadow: 0 12px 24px rgba(16,185,129,.20);
}

.btn-danger {
    background: linear-gradient(135deg,#ef4444,#dc2626);
    border-color: transparent;
}

.btn-outline {
    background: rgba(255,255,255,.7);
    border-color: #e2e8f0;
}

.form-control {
    border-radius: 12px;
    border-color: #dbe3ef;
}

.form-control:focus {
    border-color: #6366f1;
    box-shadow: 0 0 0 4px rgba(99,102,241,.12);
}

.badge {
    border-radius: 999px;
    padding: 4px 10px;
    font-weight: 700;
}

.modal,
.modal-content {
    border-radius: 24px !important;
}

.toast {
    border-radius: 16px;
    box-shadow: 0 18px 40px rgba(15,23,42,.18);
}

/* ============================================================
 * 移动端完整适配（覆盖之前的简易 @media 规则）
 * ============================================================ */

/* 汉堡按钮：默认隐藏，<=768px 显示 */
.mobile-menu-btn {
    display: none;
    position: fixed;
    top: 12px;
    left: 12px;
    z-index: 1001;
    width: 40px;
    height: 40px;
    border: 0;
    border-radius: 10px;
    background: var(--primary, #6366f1);
    color: #fff;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    box-shadow: 0 6px 18px rgba(99, 102, 241, .35);
}
.mobile-menu-btn:active { transform: scale(.95); }

/* 侧边栏遮罩 */
.sidebar-mask {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .35);
    z-index: 999;
}
body.sidebar-open .sidebar-mask { display: block; }

/* 表格：在小屏外面套一层，可横向滚动 */
.table-wrap, .table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

@media (max-width: 768px) {
    .mobile-menu-btn { display: flex; align-items: center; justify-content: center; }

    /* sidebar 固定全高滑出 */
    .sidebar {
        position: fixed !important;
        top: 0;
        left: 0;
        bottom: 0;
        z-index: 1000;
        width: 260px;
        transform: translateX(-100%);
        transition: transform .25s ease;
        box-shadow: 0 0 28px rgba(0, 0, 0, .12);
    }
    .sidebar.show { transform: translateX(0); }
    .main-content { margin-left: 0 !important; padding: 14px; padding-top: 64px; }

    /* 内容区头部紧凑 */
    .content-header {
        flex-wrap: wrap;
        gap: 8px;
        padding: 12px 14px !important;
    }
    .content-header h1 { font-size: 18px !important; }
    .header-actions { font-size: 12px; }
    .header-actions .btn { padding: 5px 10px; font-size: 12px; }

    /* 卡片紧凑 */
    .card { padding: 12px !important; }
    .card-header { flex-wrap: wrap; gap: 6px; }
    .card-header h3 { font-size: 14px; }

    /* 统计 2 列 */
    .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
    .stat-card { padding: 12px; }
    .stat-card .stat-value, .stat-card .num { font-size: 20px !important; }
    .stat-card .stat-label, .stat-card .lbl { font-size: 11px !important; }

    /* 机器人卡片 1 列 */
    .bot-grid { grid-template-columns: 1fr; }

    /* 所有表格自动横滚 */
    table { font-size: 12px; min-width: 0; }
    th, td { padding: 6px 8px !important; }
    .card > table, .card > .table-wrap > table, table.data-table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
        -webkit-overflow-scrolling: touch;
    }

    /* 表单和按钮 */
    .form-control { font-size: 14px; padding: 8px 10px; }
    .btn { padding: 7px 12px; font-size: 13px; }
    .btn-sm { padding: 5px 9px; font-size: 11px; }
    .action-buttons { flex-wrap: wrap; }

    /* 模态框 */
    .modal-content { width: calc(100% - 24px) !important; max-width: 100% !important; margin: 12px !important; }

    /* 工具栏/筛选 */
    .toolbar, .filter-bar {
        flex-wrap: wrap; gap: 6px;
    }
    .toolbar input, .toolbar select,
    .filter-bar input, .filter-bar select {
        flex: 1 1 calc(50% - 6px); min-width: 0; max-width: none;
    }

    /* 登录页 */
    .login-container { padding: 24px 20px !important; margin: 12px; }
    .login-header h1 { font-size: 20px !important; }
}

@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .content-header h1 { font-size: 16px !important; }
    .card { padding: 10px !important; }
}
