/* 工厂运维 AI 系统 - 科幻工业风主题 v2
 * 统一配色与组件样式，供所有页面引用
 * 增强版：更多动画、过渡效果、视觉细节
 */

:root {
    --bg: #0b1120;
    --panel: #111827;
    --card: #1f2937;
    --border: #374151;
    --text: #e5e7eb;
    --muted: #9ca3af;
    --accent: #06b6d4;
    --accent2: #3b82f6;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --info: #8b5cf6;
    --radius: 0.5rem;
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    --glow: 0 0 20px rgba(6, 182, 212, 0.15);
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    scrollbar-width: thin;
    scrollbar-color: var(--border) var(--panel);
}

::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: var(--panel);
}
::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
    background: #4b5563;
}

body {
    background-color: var(--bg);
    color: var(--text);
    font-family: 'Microsoft YaHei', system-ui, -apple-system, sans-serif;
    -webkit-font-smoothing: antialiased;
}

/* ========== 背景网格 ========== */
.grid-bg {
    background-image:
        linear-gradient(rgba(6, 182, 212, 0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(6, 182, 212, 0.03) 1px, transparent 1px);
    background-size: 30px 30px;
}

/* ========== 卡片/面板 ========== */
.sci-fi-card,
.sci-fi-panel {
    --card-bg: rgba(17, 24, 39, 0.85);
    background: var(--card-bg);
    border: 1px solid rgba(55, 65, 81, 0.8);
    backdrop-filter: blur(10px);
    box-shadow: 0 0 20px rgba(6, 182, 212, 0.05);
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

/* 卡片顶部光晕装饰 */
.sci-fi-card::before,
.sci-fi-panel::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--accent), transparent);
    opacity: 0.3;
}

.sci-fi-card:hover,
.sci-fi-panel:hover {
    border-color: rgba(6, 182, 212, 0.3);
    box-shadow: 0 0 30px rgba(6, 182, 212, 0.1), 0 4px 20px rgba(0, 0, 0, 0.3);
}

/* ========== 表单控件 ========== */
.sci-fi-input,
.sci-fi-select,
.sci-fi-textarea {
    background: #111827;
    border: 1px solid #374151;
    color: #e5e7eb;
    transition: var(--transition);
    border-radius: var(--radius);
}

.sci-fi-input::placeholder,
.sci-fi-textarea::placeholder {
    color: #6b7280;
}

.sci-fi-input:focus,
.sci-fi-select:focus,
.sci-fi-textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(6, 182, 212, 0.15), 0 0 15px rgba(6, 182, 212, 0.08);
    background: #0f1729;
}

/* 下拉框箭头 */
.sci-fi-select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%239ca3af' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
    background-position: right 0.5rem center;
    background-repeat: no-repeat;
    background-size: 1.5em 1.5em;
    padding-right: 2.5rem;
}

/* ========== 按钮 ========== */
.sci-fi-btn {
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}
.sci-fi-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(6, 182, 212, 0.25);
}
.sci-fi-btn:active {
    transform: translateY(0);
}
.sci-fi-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* 按钮波纹效果 */
.sci-fi-btn::after {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at var(--x, 50%) var(--y, 50%), rgba(255,255,255,0.1), transparent 60%);
    opacity: 0;
    transition: opacity 0.3s;
}
.sci-fi-btn:hover::after {
    opacity: 1;
}

.nav-link {
    transition: var(--transition);
}
.nav-link:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(6, 182, 212, 0.15);
}

/* ========== 文字发光 ========== */
.glow-text {
    text-shadow: 0 0 12px rgba(6, 182, 212, 0.4);
}
.glow-text-success {
    text-shadow: 0 0 12px rgba(16, 185, 129, 0.4);
}
.glow-text-danger {
    text-shadow: 0 0 12px rgba(239, 68, 68, 0.4);
}
.glow-text-warning {
    text-shadow: 0 0 12px rgba(245, 158, 11, 0.4);
}

/* ========== 区块标题 ========== */
.section-title {
    border-left: 3px solid var(--accent);
    padding-left: 12px;
    position: relative;
}
.section-title::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 12px;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, var(--accent), transparent);
    opacity: 0.2;
}

/* ========== 表格 ========== */
.sci-fi-table {
    width: 100%;
    border-collapse: collapse;
}
.sci-fi-table thead {
    background: rgba(17, 24, 39, 0.9);
    color: var(--muted);
}
.sci-fi-table th,
.sci-fi-table td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid rgba(55, 65, 81, 0.5);
}
.sci-fi-table tbody tr {
    transition: var(--transition);
}
.sci-fi-table tbody tr:hover {
    background: rgba(6, 182, 212, 0.05);
}

/* ========== 状态标签 ========== */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.125rem 0.5rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 500;
}

.level-紧急 { background: rgba(239, 68, 68, 0.15); color: #fca5a5; border: 1px solid rgba(239, 68, 68, 0.3); }
.level-重要 { background: rgba(249, 115, 22, 0.15); color: #fdba74; border: 1px solid rgba(249, 115, 22, 0.3); }
.level-警告 { background: rgba(234, 179, 8, 0.15); color: #fde047; border: 1px solid rgba(234, 179, 8, 0.3); }
.level-提示 { background: rgba(59, 130, 246, 0.15); color: #93c5fd; border: 1px solid rgba(59, 130, 246, 0.3); }

.status-未处理 { background: rgba(239, 68, 68, 0.15); color: #fca5a5; border: 1px solid rgba(239, 68, 68, 0.3); }
.status-已处理 { background: rgba(16, 185, 129, 0.15); color: #86efac; border: 1px solid rgba(16, 185, 129, 0.3); }
.status-已恢复 { background: rgba(156, 163, 175, 0.15); color: #d1d5db; border: 1px solid rgba(156, 163, 175, 0.3); }

/* ========== 诊断结构化展示 ========== */
.diagnosis-box {
    background: rgba(17, 24, 39, 0.6);
    border: 1px solid rgba(55, 65, 81, 0.6);
    border-radius: var(--radius);
    transition: var(--transition);
}
.diagnosis-box:hover {
    border-color: rgba(6, 182, 212, 0.3);
}

.diagnosis-section {
    border-left: 3px solid var(--accent2);
    padding-left: 12px;
    margin-bottom: 12px;
}
.diagnosis-section h4 {
    color: var(--accent);
    font-weight: 600;
    font-size: 0.85rem;
    margin-bottom: 4px;
}
.diagnosis-section ol,
.diagnosis-section ul {
    margin: 0;
    padding-left: 18px;
    font-size: 0.85rem;
    color: #d1d5db;
}
.diagnosis-section li {
    margin-bottom: 4px;
    line-height: 1.5;
}

/* ========== 日志终端 ========== */
.terminal {
    background: #020617;
    border: 1px solid #1f2937;
    color: #e5e7eb;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
}
.log-line {
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    white-space: pre-wrap;
    word-break: break-all;
}

/* ========== 动画 ========== */
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}
.loading-spinner {
    border: 3px solid rgba(255, 255, 255, 0.2);
    border-top: 3px solid var(--accent);
    border-radius: 50%;
    width: 20px;
    height: 20px;
    animation: spin 1s linear infinite;
}

@keyframes pulse-dot {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}
.status-dot {
    animation: pulse-dot 2s infinite;
}

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}
.toast {
    animation: slideIn 0.3s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}
.fade-in {
    animation: fadeIn 0.3s ease-out;
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}
.fade-in-up {
    animation: fadeInUp 0.4s ease-out both;
}

@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}
.loading-skeleton {
    background: linear-gradient(90deg, #1f2937 25%, #374151 50%, #1f2937 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 4px;
}

@keyframes scaleIn {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}
.scale-in {
    animation: scaleIn 0.2s ease-out;
}

/* ========== 模态框 ========== */
.sci-fi-modal {
    background: rgba(17, 24, 39, 0.95);
    border: 1px solid rgba(55, 65, 81, 0.8);
    backdrop-filter: blur(10px);
    box-shadow: 0 0 40px rgba(6, 182, 212, 0.15);
    animation: scaleIn 0.2s ease-out;
}

/* ========== 代码/提示文本 ========== */
code {
    background: rgba(6, 182, 212, 0.1);
    color: var(--accent);
    padding: 0.125rem 0.375rem;
    border-radius: 0.25rem;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 0.875em;
}

/* ========== 顶部栏固定 ========== */
.fixed-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 20;
}

/* ========== 设备卡片网格 ========== */
.device-grid-card {
    transition: var(--transition);
    cursor: pointer;
    position: relative;
}
.device-grid-card:hover {
    transform: translateY(-4px);
    border-color: rgba(6, 182, 212, 0.4);
    box-shadow: 0 8px 30px rgba(6, 182, 212, 0.12);
}
.device-grid-card:active {
    transform: translateY(-2px);
}

/* ========== 统计数字动画 ========== */
.stat-number {
    font-variant-numeric: tabular-nums;
    transition: var(--transition);
}

/* ========== 响应式调整 ========== */
@media (max-width: 768px) {
    .sci-fi-table th,
    .sci-fi-table td {
        padding: 0.5rem 0.75rem;
    }
    .hide-mobile {
        display: none !important;
    }
}

/* ========== 工具类 ========== */
.text-gradient {
    background: linear-gradient(135deg, var(--accent), var(--accent2));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.border-gradient {
    border-image: linear-gradient(135deg, var(--accent), var(--accent2)) 1;
}

/* 标签页切换动画 */
.tab-transition {
    transition: opacity 0.2s ease, transform 0.2s ease;
}
.tab-enter {
    opacity: 0;
    transform: translateY(5px);
}
.tab-active {
    opacity: 1;
    transform: translateY(0);
}
