/* ========== 工单管理系统 - 自定义样式 ========== */

/* ---------- CSS 变量 ---------- */
:root {
    --bg-primary: #0f1117;
    --bg-secondary: #1a1d2e;
    --bg-card: #1e2235;
    --bg-card-hover: #252a40;
    --border-color: #2d3250;
    --text-primary: #e4e6f0;
    --text-secondary: #9499b3;
    --text-muted: #6b7194;
    --accent-blue: #4f8cff;
    --accent-purple: #7c5cfc;
    --accent-green: #34d399;
    --accent-orange: #f59e0b;
    --accent-red: #ef4444;
    --accent-cyan: #22d3ee;
    --gradient-primary: linear-gradient(135deg, #4f8cff 0%, #7c5cfc 100%);
    --gradient-success: linear-gradient(135deg, #34d399 0%, #059669 100%);
    --gradient-warm: linear-gradient(135deg, #f59e0b 0%, #ef4444 100%);
    --shadow-card: 0 4px 24px rgba(0, 0, 0, 0.25);
    --shadow-glow: 0 0 20px rgba(79, 140, 255, 0.15);
    --radius: 12px;
    --radius-sm: 8px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ---------- 全局样式 ---------- */
* {
    box-sizing: border-box;
}

body {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-family: 'Inter', 'Noto Sans SC', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    min-height: 100vh;
    line-height: 1.6;
}

/* 覆盖 Bootstrap 默认文字颜色，适配暗色主题 */
.text-muted {
    color: var(--text-muted) !important;
}

.text-secondary {
    color: var(--text-secondary) !important;
}

.small,
small {
    color: inherit;
}

h1,
h2,
h3,
h4,
h5,
h6 {
    color: var(--text-primary);
}

p {
    color: var(--text-primary);
}

a {
    color: var(--accent-blue);
    text-decoration: none;
    transition: var(--transition);
}

a:hover {
    color: var(--accent-purple);
}

/* ---------- 导航栏 ---------- */
.navbar {
    background: rgba(15, 17, 23, 0.85) !important;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border-color);
    padding: 0.75rem 0;
}

.navbar-brand {
    font-weight: 700;
    font-size: 1.25rem;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.navbar .nav-link {
    color: var(--text-secondary) !important;
    font-weight: 500;
    padding: 0.5rem 1rem !important;
    border-radius: var(--radius-sm);
    transition: var(--transition);
    margin: 0 2px;
}

.navbar .nav-link:hover,
.navbar .nav-link.active {
    color: var(--text-primary) !important;
    background: rgba(79, 140, 255, 0.1);
}

.navbar .nav-link .bi {
    margin-right: 0.35rem;
}

/* ---------- 卡片 ---------- */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    box-shadow: var(--shadow-card);
    transition: var(--transition);
    color: var(--text-primary);
}

.card:hover {
    border-color: rgba(79, 140, 255, 0.3);
}

.card-header {
    background: rgba(255, 255, 255, 0.03) !important;
    border-bottom: 1px solid var(--border-color);
    font-weight: 600;
    padding: 1rem 1.25rem;
    color: var(--text-primary) !important;
}

.card-body {
    padding: 1.25rem;
    color: var(--text-primary);
}

/* 确保所有 Bootstrap 组件继承暗色主题文字 */
.card h1,
.card h2,
.card h3,
.card h4,
.card h5,
.card h6,
.card p,
.card span,
.card div,
.card label {
    color: inherit;
}

/* ---------- 统计卡片 ---------- */
.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 1.5rem;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    border-radius: var(--radius) var(--radius) 0 0;
}

.stat-card.blue::before {
    background: var(--gradient-primary);
}

.stat-card.green::before {
    background: var(--gradient-success);
}

.stat-card.orange::before {
    background: var(--gradient-warm);
}

.stat-card.purple::before {
    background: linear-gradient(135deg, #7c5cfc 0%, #a855f7 100%);
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-glow);
    border-color: rgba(79, 140, 255, 0.3);
}

.stat-card .stat-value {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.stat-card .stat-label {
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
}

.stat-card.blue .stat-value {
    color: var(--accent-blue);
}

.stat-card.green .stat-value {
    color: var(--accent-green);
}

.stat-card.orange .stat-value {
    color: var(--accent-orange);
}

.stat-card.purple .stat-value {
    color: var(--accent-purple);
}

/* ---------- 状态徽章 ---------- */
.badge-open {
    background: rgba(79, 140, 255, 0.15);
    color: var(--accent-blue);
    border: 1px solid rgba(79, 140, 255, 0.3);
}

.badge-closed {
    background: rgba(107, 113, 148, 0.15);
    color: var(--text-secondary);
    border: 1px solid rgba(107, 113, 148, 0.3);
}

.badge-completed {
    background: rgba(52, 211, 153, 0.15);
    color: var(--accent-green);
    border: 1px solid rgba(52, 211, 153, 0.3);
}

.status-badge {
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.35rem 0.75rem;
    border-radius: 20px;
    letter-spacing: 0.025em;
}

/* ---------- 工单列表项 ---------- */
.order-item {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 1.25rem;
    margin-bottom: 0.75rem;
    transition: var(--transition);
    cursor: pointer;
}

.order-item:hover {
    background: var(--bg-card-hover);
    border-color: rgba(79, 140, 255, 0.3);
    transform: translateX(4px);
    box-shadow: var(--shadow-glow);
}

.order-item .order-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.order-item .order-meta {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.order-item .order-meta span {
    margin-right: 1rem;
}

/* ---------- 时间线 ---------- */
.timeline {
    position: relative;
    padding-left: 2rem;
}

.timeline::before {
    content: '';
    position: absolute;
    left: 0.75rem;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--border-color);
}

.timeline-item {
    position: relative;
    padding-bottom: 1.5rem;
}

.timeline-item::before {
    content: '';
    position: absolute;
    left: -1.55rem;
    top: 0.4rem;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--accent-blue);
    border: 2px solid var(--bg-primary);
    z-index: 1;
}

.timeline-item.supplement::before {
    background: var(--accent-orange);
}

.timeline-item .timeline-content {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 1rem;
}

.timeline-item .timeline-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
    font-size: 0.85rem;
}

.timeline-item .timeline-author {
    font-weight: 600;
    color: var(--accent-blue);
}

.timeline-item.supplement .timeline-author {
    color: var(--accent-orange);
}

.timeline-item .timeline-time {
    color: var(--text-muted);
    font-size: 0.8rem;
}

.timeline-item .timeline-type {
    font-size: 0.7rem;
    font-weight: 600;
    padding: 0.2rem 0.5rem;
    border-radius: 10px;
    text-transform: uppercase;
}

.timeline-type.reply {
    background: rgba(79, 140, 255, 0.15);
    color: var(--accent-blue);
}

.timeline-type.supplement {
    background: rgba(245, 158, 11, 0.15);
    color: var(--accent-orange);
}

/* ---------- 表单 ---------- */
.form-control,
.form-select {
    background: var(--bg-secondary) !important;
    border: 1px solid var(--border-color) !important;
    color: var(--text-primary) !important;
    border-radius: var(--radius-sm);
    padding: 0.65rem 1rem;
    transition: var(--transition);
}

.form-control:focus,
.form-select:focus {
    border-color: var(--accent-blue) !important;
    box-shadow: 0 0 0 3px rgba(79, 140, 255, 0.15) !important;
}

.form-control::placeholder {
    color: var(--text-muted) !important;
}

.form-label {
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 0.875rem;
    margin-bottom: 0.4rem;
}

/* ---------- 按钮 ---------- */
.btn-primary {
    background: var(--gradient-primary) !important;
    border: none !important;
    font-weight: 600;
    padding: 0.6rem 1.5rem;
    border-radius: var(--radius-sm);
    transition: var(--transition);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(79, 140, 255, 0.4);
}

.btn-success {
    background: var(--gradient-success) !important;
    border: none !important;
    font-weight: 600;
}

.btn-success:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(52, 211, 153, 0.4);
}

.btn-outline-light {
    border-color: var(--border-color) !important;
    color: var(--text-secondary) !important;
}

.btn-outline-light:hover {
    background: var(--bg-card-hover) !important;
    border-color: var(--accent-blue) !important;
    color: var(--text-primary) !important;
}

.btn-outline-danger {
    border-color: rgba(239, 68, 68, 0.3) !important;
    color: var(--accent-red) !important;
}

.btn-outline-danger:hover {
    background: rgba(239, 68, 68, 0.15) !important;
    border-color: var(--accent-red) !important;
}

.btn-warning {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%) !important;
    border: none !important;
    color: #fff !important;
    font-weight: 600;
}

/* ---------- 附件 ---------- */
.attachment-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.attachment-item {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 0.4rem 0.75rem;
    font-size: 0.8rem;
    color: var(--text-secondary);
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.attachment-item:hover {
    border-color: var(--accent-blue);
    color: var(--accent-blue);
}

/* ---------- 认证页面 ---------- */
.auth-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-primary);
    position: relative;
    overflow: hidden;
}

.auth-container::before {
    content: '';
    position: absolute;
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, rgba(79, 140, 255, 0.1), transparent 70%);
    top: -100px;
    right: -100px;
    border-radius: 50%;
}

.auth-container::after {
    content: '';
    position: absolute;
    width: 300px;
    height: 300px;
    background: radial-gradient(circle, rgba(124, 92, 252, 0.08), transparent 70%);
    bottom: -50px;
    left: -50px;
    border-radius: 50%;
}

.auth-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 2.5rem;
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow-card);
    position: relative;
    z-index: 1;
}

.auth-card .auth-title {
    text-align: center;
    margin-bottom: 2rem;
}

.auth-card .auth-title h2 {
    font-weight: 700;
    font-size: 1.5rem;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 0.5rem;
}

.auth-card .auth-title p {
    color: var(--text-muted);
    font-size: 0.875rem;
}

/* ---------- 排行榜 ---------- */
.leaderboard-item {
    display: flex;
    align-items: center;
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    margin-bottom: 0.5rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    transition: var(--transition);
}

.leaderboard-item:hover {
    border-color: rgba(79, 140, 255, 0.3);
}

.leaderboard-rank {
    width: 2rem;
    height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-weight: 700;
    font-size: 0.85rem;
    margin-right: 1rem;
    flex-shrink: 0;
}

.leaderboard-rank.gold {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: #fff;
}

.leaderboard-rank.silver {
    background: linear-gradient(135deg, #94a3b8, #64748b);
    color: #fff;
}

.leaderboard-rank.bronze {
    background: linear-gradient(135deg, #cd7f32, #a0522d);
    color: #fff;
}

.leaderboard-rank.normal {
    background: var(--bg-card);
    color: var(--text-muted);
}

.leaderboard-name {
    flex: 1;
    font-weight: 600;
}

.leaderboard-score {
    font-weight: 700;
    color: var(--accent-green);
}

/* ---------- 分页 ---------- */
.pagination .page-link {
    background: var(--bg-card) !important;
    border-color: var(--border-color) !important;
    color: var(--text-secondary) !important;
    transition: var(--transition);
}

.pagination .page-link:hover {
    background: var(--bg-card-hover) !important;
    border-color: var(--accent-blue) !important;
    color: var(--accent-blue) !important;
}

.pagination .page-item.active .page-link {
    background: var(--gradient-primary) !important;
    border-color: transparent !important;
    color: #fff !important;
}

.pagination .page-item.disabled .page-link {
    background: var(--bg-secondary) !important;
    color: var(--text-muted) !important;
}

/* ---------- 表格 ---------- */
.table {
    color: var(--text-primary);
}

.table thead th {
    background: var(--bg-secondary);
    border-color: var(--border-color);
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 0.85rem;
}

.table tbody td {
    border-color: var(--border-color);
    vertical-align: middle;
}

.table-hover tbody tr:hover {
    background: var(--bg-card-hover);
}

/* ---------- 提示框 ---------- */
.alert {
    border-radius: var(--radius-sm);
    border: none;
    font-size: 0.9rem;
}

.alert-success {
    background: rgba(52, 211, 153, 0.15);
    color: var(--accent-green);
}

.alert-danger {
    background: rgba(239, 68, 68, 0.15);
    color: var(--accent-red);
}

.alert-info {
    background: rgba(34, 211, 238, 0.15);
    color: var(--accent-cyan);
}

.alert-warning {
    background: rgba(245, 158, 11, 0.15);
    color: var(--accent-orange);
}

/* ---------- 筛选栏 ---------- */
.filter-bar {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.filter-bar .btn {
    font-size: 0.85rem;
    padding: 0.4rem 1rem;
    border-radius: 20px;
}

.filter-bar .btn.active {
    background: var(--gradient-primary) !important;
    border-color: transparent !important;
    color: #fff !important;
}

/* ---------- 贡献信息 ---------- */
.contribution-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    background: rgba(52, 211, 153, 0.15);
    color: var(--accent-green);
    border: 1px solid rgba(52, 211, 153, 0.3);
    border-radius: 20px;
    padding: 0.3rem 0.75rem;
    font-weight: 600;
    font-size: 0.85rem;
}

/* ---------- 工单详情头部 ---------- */
.detail-header {
    margin-bottom: 2rem;
}

.detail-header h3 {
    font-weight: 700;
    font-size: 1.5rem;
    margin-bottom: 0.75rem;
}

.detail-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    color: var(--text-muted);
    font-size: 0.85rem;
}

.detail-meta .meta-item {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

/* ---------- 页面标题 ---------- */
.page-header {
    margin-bottom: 2rem;
}

.page-header h2 {
    font-weight: 700;
    font-size: 1.5rem;
    margin-bottom: 0.25rem;
}

.page-header p {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin: 0;
}

/* ---------- 空状态 ---------- */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-muted);
}

.empty-state .empty-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.empty-state p {
    font-size: 1rem;
}

/* ---------- 错误页面 ---------- */
.error-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.error-page .error-code {
    font-size: 6rem;
    font-weight: 800;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    line-height: 1;
}

/* ---------- 响应式 ---------- */
@media (max-width: 768px) {
    .stat-card {
        margin-bottom: 1rem;
    }

    .auth-card {
        margin: 1rem;
        padding: 1.5rem;
    }

    .detail-meta {
        flex-direction: column;
        gap: 0.5rem;
    }
}

/* ---------- 滚动条 ---------- */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* ---------- 文件上传区域 ---------- */
.file-upload-area {
    border: 2px dashed var(--border-color);
    border-radius: var(--radius);
    padding: 1.5rem;
    text-align: center;
    transition: var(--transition);
    cursor: pointer;
}

.file-upload-area:hover {
    border-color: var(--accent-blue);
    background: rgba(79, 140, 255, 0.05);
}

.file-upload-area .upload-icon {
    font-size: 2rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.file-upload-area p {
    color: var(--text-muted);
    font-size: 0.85rem;
    margin: 0;
}

/* ---------- 动画 ---------- */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in-up {
    animation: fadeInUp 0.5s ease forwards;
}

.fade-in-up:nth-child(1) {
    animation-delay: 0.05s;
}

.fade-in-up:nth-child(2) {
    animation-delay: 0.1s;
}

.fade-in-up:nth-child(3) {
    animation-delay: 0.15s;
}

.fade-in-up:nth-child(4) {
    animation-delay: 0.2s;
}

.fade-in-up:nth-child(5) {
    animation-delay: 0.25s;
}

/* ---------- 附件预览 ---------- */
.preview-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: flex-start;
}

.preview-thumb {
    position: relative;
    width: 120px;
    height: 90px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    border: 1px solid var(--border-color);
    cursor: pointer;
    transition: var(--transition);
}

.preview-thumb:hover {
    border-color: var(--accent-blue);
    transform: scale(1.05);
    box-shadow: var(--shadow-glow);
}

.preview-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.preview-thumb-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: var(--transition);
    color: #fff;
    font-size: 1.25rem;
}

.preview-thumb:hover .preview-thumb-overlay {
    opacity: 1;
}

.preview-filename {
    font-size: 0.75rem;
    color: var(--text-secondary);
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin-top: 0.25rem;
}

/* 预览模态框 */
.preview-modal {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
    display: flex;
    flex-direction: column;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.preview-modal.active {
    opacity: 1;
    visibility: visible;
}

.preview-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.preview-modal-title {
    color: #fff;
    font-weight: 600;
    font-size: 0.95rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 60%;
}

.preview-modal-close {
    background: none;
    border: none;
    color: #fff;
    font-size: 1.25rem;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-sm);
    transition: var(--transition);
}

.preview-modal-close:hover {
    background: rgba(255, 255, 255, 0.1);
}

.preview-modal-body {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    overflow: auto;
}

.text-preview-content {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 1.5rem;
    color: var(--text-primary);
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 0.85rem;
    line-height: 1.7;
    max-width: 900px;
    width: 100%;
    max-height: 80vh;
    overflow: auto;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.text-preview-loading {
    color: var(--text-muted);
    font-size: 1rem;
}