/* ============================================
   发贴机后台管理 - 样式表
   ============================================ */

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

:root {
    --primary: #4f46e5;
    --primary-dark: #4338ca;
    --primary-light: #eef2ff;
    --success: #16a34a;
    --warning: #f59e0b;
    --danger: #dc2626;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
    --sidebar-width: 240px;
    --radius: 8px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
    background: var(--gray-100);
    color: var(--gray-800);
    line-height: 1.6;
    min-height: 100vh;
}

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

.login-wrapper {
    width: 100%;
    max-width: 420px;
    padding: 20px;
}

.login-card {
    background: #fff;
    border-radius: 12px;
    padding: 40px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.15);
}

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

.login-header h1 {
    font-size: 26px;
    color: var(--gray-900);
    margin-bottom: 8px;
}

.login-header p {
    color: var(--gray-500);
    font-size: 14px;
}

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

.login-footer {
    margin-top: 24px;
    text-align: center;
    color: var(--gray-400);
    font-size: 12px;
}

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

/* ============ 侧边栏 ============ */
.sidebar {
    width: var(--sidebar-width);
    background: var(--gray-900);
    color: #fff;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    z-index: 100;
    overflow-y: auto;
}

.sidebar-brand {
    padding: 24px 20px 16px;
    border-bottom: 1px solid var(--gray-700);
}

.sidebar-brand h2 {
    font-size: 18px;
    font-weight: 600;
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--gray-700);
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 16px;
    flex-shrink: 0;
}

.user-info {
    overflow: hidden;
}

.user-name {
    font-weight: 600;
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-role {
    font-size: 12px;
    color: var(--gray-400);
}

.sidebar-menu {
    list-style: none;
    padding: 12px 0;
    flex: 1;
}

.sidebar-menu li a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 20px;
    color: var(--gray-300);
    text-decoration: none;
    font-size: 14px;
    transition: all 0.15s;
}

.sidebar-menu li a:hover {
    background: var(--gray-800);
    color: #fff;
}

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

.menu-divider {
    height: 1px;
    background: var(--gray-700);
    margin: 8px 16px;
}

.menu-title {
    padding: 8px 20px 4px;
    font-size: 11px;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.logout-link {
    color: var(--gray-500) !important;
}

.logout-link:hover {
    color: var(--danger) !important;
    background: rgba(220,38,38,0.1) !important;
}

/* ============ 主内容区 ============ */
.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    padding: 24px 32px;
    max-width: 1200px;
    width: 100%;
}

/* ============ 页面头部 ============ */
.page-header {
    margin-bottom: 24px;
}

.page-header h1 {
    font-size: 24px;
    font-weight: 700;
    color: var(--gray-900);
    margin-bottom: 4px;
}

.page-header p {
    color: var(--gray-500);
    font-size: 14px;
}

/* ============ 卡片 ============ */
.card {
    background: #fff;
    border-radius: var(--radius);
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    margin-bottom: 20px;
}

.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--gray-200);
}

.card-header h3 {
    font-size: 15px;
    font-weight: 600;
    color: var(--gray-800);
}

.card-body {
    padding: 20px;
}

.card-body.p-0 {
    padding: 0;
}

/* ============ 统计卡片 ============ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: #fff;
    border-radius: var(--radius);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

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

.stat-info {
    flex: 1;
    min-width: 0;
}

.stat-label {
    font-size: 12px;
    color: var(--gray-500);
    margin-bottom: 4px;
}

.stat-value {
    font-size: 18px;
    font-weight: 700;
    color: var(--gray-900);
}

.stat-small {
    font-size: 13px;
    word-break: break-all;
}

/* ============ 快速操作 ============ */
.quick-actions {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 12px;
}

.action-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 16px;
    background: #fff;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    text-decoration: none;
    color: var(--gray-700);
    font-weight: 500;
    transition: all 0.15s;
}

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

/* ============ 表单 ============ */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: var(--gray-700);
    margin-bottom: 6px;
}

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

.required {
    color: var(--danger);
}

input[type="text"],
input[type="password"],
input[type="url"],
input[type="date"],
input[type="number"],
select,
textarea {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--gray-300);
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    color: var(--gray-800);
    background: #fff;
    transition: border-color 0.15s;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79,70,229,0.1);
}

textarea {
    resize: vertical;
    min-height: 100px;
}

input[type="range"] {
    width: 100%;
    margin-bottom: 8px;
}

select {
    cursor: pointer;
}

.select-sm {
    padding: 4px 8px;
    font-size: 12px;
    width: auto;
}

.form-hint {
    display: block;
    margin-top: 4px;
    font-size: 12px;
    color: var(--gray-400);
}

.form-actions {
    display: flex;
    gap: 10px;
    margin-top: 8px;
}

/* ============ 按钮 ============ */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border: 1px solid var(--gray-300);
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    background: #fff;
    color: var(--gray-700);
    transition: all 0.15s;
    font-family: inherit;
}

.btn:hover {
    background: var(--gray-50);
}

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

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

.btn-secondary {
    background: #fff;
    color: var(--gray-600);
}

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

.btn-danger:hover {
    background: #fef2f2;
    color: var(--danger);
}

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

.btn-block {
    width: 100%;
    justify-content: center;
}

/* ============ 提示 ============ */
.alert {
    padding: 12px 16px;
    border-radius: 6px;
    margin-bottom: 16px;
    font-size: 14px;
}

.alert-success {
    background: #f0fdf4;
    color: #166534;
    border: 1px solid #bbf7d0;
}

.alert-error {
    background: #fef2f2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

.alert-warning {
    background: #fffbeb;
    color: #92400e;
    border: 1px solid #fde68a;
}

.alert a {
    color: inherit;
    font-weight: 600;
}

/* ============ 表格 ============ */
.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th {
    background: var(--gray-50);
    padding: 12px 16px;
    font-size: 13px;
    font-weight: 600;
    color: var(--gray-600);
    text-align: left;
    border-bottom: 2px solid var(--gray-200);
    white-space: nowrap;
}

.data-table td {
    padding: 10px 16px;
    font-size: 14px;
    border-bottom: 1px solid var(--gray-100);
    vertical-align: middle;
}

.data-table tr:hover td {
    background: var(--gray-50);
}

.data-table .actions {
    white-space: nowrap;
}

.data-table .actions form {
    display: inline;
    margin: 0 2px;
}

.thread-top {
    background: #fefce8;
}

.thread-subject {
    max-width: 300px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.expired {
    background: #fef2f2 !important;
}

/* ============ 徽章 ============ */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
}

.badge-admin {
    background: #ede9fe;
    color: #6d28d9;
}

.badge-user {
    background: #e0f2fe;
    color: #0369a1;
}

.badge-top {
    background: #fef3c7;
    color: #92400e;
}

.badge-closed {
    background: #fee2e2;
    color: #991b1b;
}

/* ============ 信息表 ============ */
.info-table {
    width: 100%;
    border-collapse: collapse;
}

.info-table td {
    padding: 8px 12px;
    font-size: 14px;
    border-bottom: 1px solid var(--gray-100);
}

.info-label {
    width: 120px;
    color: var(--gray-500);
    font-size: 13px;
    white-space: nowrap;
}

/* ============ 分页 ============ */
.pagination {
    display: flex;
    gap: 4px;
    margin-top: 16px;
    justify-content: center;
}

.page-link {
    padding: 6px 12px;
    border: 1px solid var(--gray-300);
    border-radius: 4px;
    text-decoration: none;
    color: var(--gray-600);
    font-size: 13px;
    transition: all 0.15s;
}

.page-link:hover {
    background: var(--gray-100);
}

.page-link.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

/* ============ 工具栏 ============ */
.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.toolbar-left {
    display: flex;
    gap: 10px;
}

.toolbar select {
    width: auto;
    min-width: 140px;
}

/* ============ 工具类 ============ */
.text-center { text-align: center; }
.text-small { font-size: 12px; }
.text-muted { color: var(--gray-400); }
.text-danger { color: var(--danger); }
code {
    background: var(--gray-100);
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 13px;
    color: var(--danger);
    word-break: break-all;
}

/* ============ 响应式 ============ */
@media (max-width: 768px) {
    .sidebar {
        width: 100%;
        position: relative;
        height: auto;
    }
    
    .main-content {
        margin-left: 0;
        padding: 16px;
    }
    
    .app {
        flex-direction: column;
    }
    
    .stats-grid {
        grid-template-columns: 1fr 1fr;
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
}
