/**
 * SCADA系统样式 - 奶白色科技风
 */

:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #06b6d4;
    --bg-light: #f8f9fa;
    --bg-white: #ffffff;
    --text-dark: #1f2937;
    --text-muted: #6b7280;
    --border: #e5e7eb;
    --shadow: 0 1px 3px rgba(0,0,0,0.1);
    --shadow-lg: 0 10px 25px rgba(0,0,0,0.1);
    --radius: 12px;
}

* { box-sizing: border-box; }

body {
    font-family: 'PingFang SC', 'Microsoft YaHei', sans-serif;
    background: linear-gradient(135deg, #f0f4f8 0%, #e2e8f0 100%);
    color: var(--text-dark);
    min-height: 100vh;
}

/* 导航栏 */
.navbar-scada {
    background: linear-gradient(90deg, #1e3a5f 0%, #2563eb 100%) !important;
    box-shadow: var(--shadow-lg);
}

.navbar-brand {
    font-weight: 700;
    font-size: 1.25rem;
}

/* 主内容区 */
.main-content {
    padding: 2rem 0;
    min-height: calc(100vh - 200px);
}

/* 页面标题 */
.page-header {
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid var(--border);
    position: relative;
}

.page-header::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 80px;
    height: 2px;
    background: var(--primary);
}

.page-title {
    font-weight: 700;
    color: var(--text-dark);
    font-size: 1.5rem;
}

/* 卡片样式 */
.card-scada {
    background: var(--bg-white);
    border: none;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    transition: all 0.3s ease;
    overflow: hidden;
}

.card-scada:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px);
}

.card-scada .card-header {
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    border-bottom: 1px solid var(--border);
    padding: 1rem 1.25rem;
    font-weight: 600;
}

.card-scada .card-body {
    padding: 1.25rem;
}

/* 模块卡片 */
.module-card {
    text-decoration: none;
    color: inherit;
    display: block;
}

.module-icon-wrap {
    width: 72px;
    height: 72px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.75rem;
    margin: 0 auto 1rem;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.module-icon-wrap::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: inherit;
    filter: blur(15px);
    opacity: 0.5;
    z-index: -1;
}

.module-card:hover .module-icon-wrap {
    transform: scale(1.1) rotate(3deg);
}

.icon-events { background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%); color: white; }
.icon-devices { background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%); color: white; }
.icon-measurement { background: linear-gradient(135deg, #10b981 0%, #059669 100%); color: white; }
.icon-production { background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%); color: white; }
.icon-config { background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%); color: white; }
.icon-ai { background: linear-gradient(135deg, #ec4899 0%, #db2777 100%); color: white; }

.module-title {
    font-weight: 600;
    color: var(--text-dark);
    margin-bottom: 0.25rem;
}

.module-desc {
    font-size: 0.875rem;
    color: var(--text-muted);
}

/* 统计卡片 */
.stat-card {
    background: var(--bg-white);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
}

.stat-card.primary::before { background: var(--primary); }
.stat-card.success::before { background: var(--success); }
.stat-card.warning::before { background: var(--warning); }
.stat-card.danger::before { background: var(--danger); }

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
}

.stat-card.primary .stat-icon { background: rgba(37, 99, 235, 0.1); color: var(--primary); }
.stat-card.success .stat-icon { background: rgba(16, 185, 129, 0.1); color: var(--success); }
.stat-card.warning .stat-icon { background: rgba(245, 158, 11, 0.1); color: var(--warning); }
.stat-card.danger .stat-icon { background: rgba(239, 68, 68, 0.1); color: var(--danger); }

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    line-height: 1.2;
}

.stat-label {
    color: var(--text-muted);
    font-size: 0.875rem;
}

/* 表格样式 */
.table-scada {
    margin-bottom: 0;
}

.table-scada thead {
    background: linear-gradient(135deg, #1e3a5f 0%, #2563eb 100%);
    color: white;
}

.table-scada thead th {
    font-weight: 600;
    padding: 1rem;
    border: none;
    white-space: nowrap;
}

.table-scada tbody td {
    padding: 0.875rem 1rem;
    vertical-align: middle;
    border-color: var(--border);
}

.table-scada tbody tr {
    transition: background 0.2s;
}

.table-scada tbody tr:hover {
    background: rgba(37, 99, 235, 0.05);
}

/* 状态标签 */
.badge-status {
    display: inline-flex;
    align-items: center;
    padding: 0.375rem 0.75rem;
    border-radius: 50px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-online { background: #d1fae5; color: #065f46; }
.badge-offline { background: #fee2e2; color: #991b1b; }
.badge-running { background: #dbeafe; color: #1e40af; }
.badge-fault { background: #fee2e2; color: #991b1b; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-info { background: #e0f2fe; color: #075985; }

/* 状态指示灯 */
.indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

.indicator.online { background: var(--success); box-shadow: 0 0 8px var(--success); }
.indicator.offline { background: var(--danger); }
.indicator.running { background: var(--info); animation: pulse 2s infinite; }
.indicator.fault { background: var(--danger); animation: blink 1s infinite; }

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

/* 搜索框 */
.search-box {
    position: relative;
}

.search-box input {
    padding-left: 2.75rem;
    border-radius: 50px;
}

.search-box .search-icon {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

/* 认证页面 */
.auth-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1e3a5f 0%, #2563eb 50%, #3b82f6 100%);
    padding: 1rem;
}

.auth-card {
    width: 100%;
    max-width: 420px;
    background: var(--bg-white);
    border-radius: 20px;
    padding: 2.5rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
}

.auth-card .auth-logo {
    width: 72px;
    height: 72px;
    background: linear-gradient(135deg, #1e3a5f 0%, #2563eb 100%);
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1.5rem;
}

.auth-card .auth-logo i {
    font-size: 2rem;
    color: white;
}

.auth-card .form-control {
    border-radius: 10px;
    padding: 0.875rem 1rem;
    border: 1px solid var(--border);
    transition: all 0.3s;
}

.auth-card .form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.auth-card .btn-auth {
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    border: none;
    border-radius: 10px;
    padding: 0.875rem 1.5rem;
    font-weight: 600;
    color: white;
}

.auth-card .btn-auth:hover {
    background: linear-gradient(135deg, #1d4ed8 0%, #1e40af 100%);
    color: white;
}

/* AI聊天 */
.chat-container {
    height: 550px;
    display: flex;
    flex-direction: column;
    background: var(--bg-white);
    border-radius: var(--radius);
    overflow: hidden;
}

.chat-header {
    background: linear-gradient(135deg, #1e3a5f 0%, #2563eb 100%);
    color: white;
    padding: 1rem 1.25rem;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1.25rem;
    background: #f8fafc;
}

.chat-message {
    max-width: 85%;
    margin-bottom: 1rem;
    padding: 1rem;
    border-radius: 16px;
    line-height: 1.6;
}

.chat-message.user {
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    color: white;
    margin-left: auto;
    border-bottom-right-radius: 4px;
}

.chat-message.assistant {
    background: var(--bg-white);
    border: 1px solid var(--border);
    margin-right: auto;
    border-bottom-left-radius: 4px;
    box-shadow: var(--shadow);
}

.chat-message .avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.875rem;
}

.chat-message.user .avatar { background: rgba(255,255,255,0.2); }
.chat-message.assistant .avatar { background: var(--primary); color: white; }

.chat-input-area {
    padding: 1rem;
    background: var(--bg-white);
    border-top: 1px solid var(--border);
}

.chat-input-area textarea {
    border-radius: 50px;
    resize: none;
}

/* 设备卡片 */
.device-card {
    background: var(--bg-white);
    border-radius: var(--radius);
    padding: 1.25rem;
    box-shadow: var(--shadow);
    transition: all 0.3s;
    border-left: 4px solid var(--border);
}

.device-card:hover {
    box-shadow: var(--shadow-lg);
}

.device-card.online { border-left-color: var(--success); }
.device-card.offline { border-left-color: var(--danger); }
.device-card.running { border-left-color: var(--info); }
.device-card.fault { border-left-color: var(--danger); }

/* 分页 */
.pagination-scada {
    display: flex;
    gap: 0.5rem;
}

.pagination-scada a,
.pagination-scada span {
    padding: 0.5rem 1rem;
    border-radius: 8px;
    text-decoration: none;
    transition: all 0.2s;
}

.pagination-scada a {
    background: var(--bg-white);
    color: var(--text-dark);
    border: 1px solid var(--border);
}

.pagination-scada a:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.pagination-scada .active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* Toast通知 */
.toast-scada {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 1rem 1.5rem;
    border-radius: 12px;
    background: var(--bg-white);
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    z-index: 9999;
    opacity: 0;
    transform: translateX(120%);
    transition: all 0.3s ease;
}

.toast-scada.show {
    opacity: 1;
    transform: translateX(0);
}

.toast-scada.success { border-left: 4px solid var(--success); }
.toast-scada.error { border-left: 4px solid var(--danger); }
.toast-scada.info { border-left: 4px solid var(--info); }

/* 进度条 */
.progress-scada {
    height: 8px;
    border-radius: 50px;
    background: var(--border);
}

.progress-scada .progress-bar {
    border-radius: 50px;
}

/* 响应式 */
@media (max-width: 768px) {
    .auth-card { padding: 1.5rem; }
    .stat-value { font-size: 1.5rem; }
    .stat-card { padding: 1rem; }
}

/* 表格交替行 */
.table-striped tbody tr:nth-of-type(odd) {
    background: rgba(0,0,0,0.02);
}

/* 滚动条美化 */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: #f1f1f1; }
::-webkit-scrollbar-thumb { background: #c1c1c1; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #a1a1a1; }
