/* ============================================
 * animations.css - 工业DCS风格动效系统
 * 森缇纳全域感知系统前端动效增强
 * ============================================ */

/* ---- 1. 统计卡片计数器动效 ---- */
.stat-card {
    position: relative;
    overflow: hidden;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--accent), transparent);
    transition: left 0.8s ease;
}

.stat-card.counting::before {
    left: 100%;
}

.stat-card.counting .stat-value {
    text-shadow: 0 0 20px rgba(212, 168, 83, 0.5);
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(212, 168, 83, 0.15);
}

.stat-value {
    font-variant-numeric: tabular-nums;
    font-family: 'JetBrains Mono', 'Consolas', 'Courier New', monospace;
    transition: text-shadow 0.4s ease;
}

/* ---- 2. 设备状态指示灯 ---- */
.status-cell {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    white-space: nowrap;
}

.status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* 运行：绿色脉动光晕 */
.status-running .status-dot {
    background: var(--success);
    box-shadow: 0 0 6px var(--success);
    animation: pulse-green 2s ease-in-out infinite;
}

/* 停机：灰色静态 */
.status-stopped .status-dot {
    background: #6e7681;
    box-shadow: none;
}

/* 检修：黄色闪烁 */
.status-maintenance .status-dot {
    background: var(--warning);
    animation: blink-yellow 1.2s ease-in-out infinite;
}

@keyframes pulse-green {
    0%, 100% {
        box-shadow: 0 0 6px var(--success), 0 0 0 0 rgba(63, 185, 80, 0.4);
    }
    50% {
        box-shadow: 0 0 14px var(--success), 0 0 0 8px rgba(63, 185, 80, 0);
    }
}

@keyframes blink-yellow {
    0%, 100% {
        opacity: 1;
        box-shadow: 0 0 10px var(--warning);
    }
    50% {
        opacity: 0.25;
        box-shadow: 0 0 2px var(--warning);
    }
}

/* ---- 3. 表格行交互动效 ---- */
tbody tr {
    animation: row-enter 0.4s ease forwards;
    animation-delay: calc(var(--row-index, 0) * 0.025s);
    opacity: 0;
}

@keyframes row-enter {
    from {
        opacity: 0;
        transform: translateX(-10px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

tbody tr {
    transition: background 0.15s ease;
}

tbody tr:hover td {
    background: linear-gradient(90deg,
        rgba(212, 168, 83, 0.09) 0%,
        rgba(212, 168, 83, 0.03) 50%,
        transparent 100%);
}

tbody tr:hover td:first-child {
    box-shadow: inset 2px 0 0 var(--accent);
}

tbody tr:hover .code {
    text-shadow: 0 0 8px rgba(212, 168, 83, 0.4);
}

/* ---- 4. 弹窗动画 ---- */
.modal-overlay.active {
    animation: overlay-in 0.2s ease;
}

.modal-overlay.closing {
    animation: overlay-out 0.2s ease forwards;
}

.modal-overlay.active .modal {
    animation: modal-in 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-overlay.closing .modal {
    animation: modal-out 0.2s ease forwards;
}

@keyframes overlay-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes overlay-out {
    from { opacity: 1; }
    to { opacity: 0; }
}

@keyframes modal-in {
    from {
        opacity: 0;
        transform: translateY(28px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes modal-out {
    from {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
    to {
        opacity: 0;
        transform: translateY(20px) scale(0.97);
    }
}

/* ---- 5. 仪表盘详情面板 ---- */
.detail-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.detail-header h2 {
    margin: 0;
    font-size: 20px;
}

.detail-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--success);
    padding: 4px 14px;
    background: rgba(63, 185, 80, 0.1);
    border: 1px solid rgba(63, 185, 80, 0.3);
    border-radius: 20px;
    transition: all 0.3s ease;
}

.detail-status .status-dot {
    width: 7px;
    height: 7px;
}

.detail-status.status-maintenance {
    color: var(--warning);
    background: rgba(210, 153, 29, 0.1);
    border-color: rgba(210, 153, 29, 0.3);
}

/* 参数卡片网格 */
.dashboard-params {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    margin-bottom: 20px;
}

.param-card {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 10px;
    text-align: center;
    transition: border-color 0.25s ease, transform 0.25s ease;
    position: relative;
    overflow: hidden;
}

.param-card:hover {
    border-color: rgba(212, 168, 83, 0.5);
    transform: translateY(-2px);
}

.param-card::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 2px;
    background: var(--accent);
    transform: scaleX(0);
    transform-origin: left;
    transition: transform 0.3s ease;
}

.param-card:hover::after {
    transform: scaleX(1);
}

.param-tag {
    display: inline-block;
    font-size: 10px;
    font-weight: 700;
    color: var(--accent);
    background: rgba(212, 168, 83, 0.08);
    border: 1px solid rgba(212, 168, 83, 0.2);
    border-radius: 3px;
    padding: 1px 6px;
    margin-bottom: 8px;
    font-family: 'JetBrains Mono', 'Consolas', monospace;
    letter-spacing: 0.5px;
}

.param-value {
    font-size: 22px;
    font-weight: 700;
    color: var(--accent);
    font-family: 'JetBrains Mono', 'Consolas', 'Courier New', monospace;
    line-height: 1.2;
}

.param-unit {
    font-size: 11px;
    font-weight: 400;
    color: var(--text-secondary);
    margin-left: 2px;
}

.param-label {
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 4px;
    letter-spacing: 0.5px;
}

/* 波形面板 */
.waveform-panel {
    background: #0d1117;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 20px;
    overflow: hidden;
    position: relative;
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 14px;
    background: var(--bg-input);
    border-bottom: 1px solid var(--border);
}

.panel-title {
    font-size: 11px;
    font-weight: 600;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 1.2px;
}

.panel-live {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 10px;
    color: var(--success);
    font-family: 'JetBrains Mono', 'Consolas', monospace;
    letter-spacing: 0.5px;
}

.live-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--success);
    animation: pulse-green 1.5s ease-in-out infinite;
}

#waveform-canvas {
    display: block;
    width: 100%;
    height: 180px;
}

/* 扫描线效果 */
.waveform-panel::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    height: 2px;
    background: linear-gradient(90deg,
        transparent 0%,
        rgba(212, 168, 83, 0.5) 50%,
        transparent 100%);
    pointer-events: none;
    animation: scan-line 4s linear infinite;
    z-index: 2;
}

@keyframes scan-line {
    0% { top: 35px; opacity: 0; }
    10% { opacity: 1; }
    90% { opacity: 1; }
    100% { top: 100%; opacity: 0; }
}

/* 设备信息网格 */
.info-panel {
    margin-bottom: 20px;
}

.info-panel .panel-title {
    display: block;
    margin-bottom: 10px;
}

.info-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0 24px;
}

.info-item {
    display: flex;
    align-items: baseline;
    gap: 8px;
    padding: 7px 0;
    border-bottom: 1px solid rgba(48, 54, 61, 0.5);
    font-size: 13px;
}

.info-label {
    color: var(--text-secondary);
    min-width: 80px;
    font-size: 12px;
    flex-shrink: 0;
}

/* 维修时间线 */
.timeline-panel {
    margin-bottom: 8px;
}

.timeline-panel .panel-title {
    display: block;
    margin-bottom: 12px;
}

.timeline {
    position: relative;
    padding-left: 20px;
}

.timeline::before {
    content: '';
    position: absolute;
    left: 5px;
    top: 6px;
    bottom: 6px;
    width: 1px;
    background: var(--border);
}

.timeline-item {
    position: relative;
    padding-bottom: 14px;
}

.timeline-item:last-child {
    padding-bottom: 0;
}

.timeline-dot {
    position: absolute;
    left: -20px;
    top: 4px;
    width: 11px;
    height: 11px;
    border-radius: 50%;
    background: var(--accent);
    border: 2px solid var(--bg-card);
    box-shadow: 0 0 0 1px var(--accent), 0 0 8px rgba(212, 168, 83, 0.3);
}

.timeline-content {
    font-size: 13px;
}

.timeline-date {
    color: var(--accent);
    font-family: 'JetBrains Mono', 'Consolas', monospace;
    font-size: 12px;
    margin-bottom: 2px;
}

.timeline-text {
    color: var(--text-primary);
}

.timeline-tech {
    color: var(--text-secondary);
    font-size: 11px;
    margin-top: 2px;
}

.timeline-empty {
    color: var(--text-secondary);
    font-size: 13px;
    font-style: italic;
    padding-left: 0;
}

/* ---- 6. Toast 入场动画 ---- */
.toast.show {
    animation: toast-in 0.3s cubic-bezier(0.16, 1, 0.3, 1), toast-out 0.3s ease 2.2s forwards;
}

@keyframes toast-in {
    from {
        opacity: 0;
        transform: translateX(120%);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes toast-out {
    to {
        opacity: 0;
        transform: translateX(120%);
    }
}

/* ---- 7. 按钮微动效 ---- */
.btn {
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.btn:active {
    transform: scale(0.95);
}

/* ---- 8. 搜索框聚焦动效 ---- */
.toolbar input[type="text"]:focus,
.toolbar select:focus {
    box-shadow: 0 0 0 3px rgba(212, 168, 83, 0.1);
}

/* ---- 9. 导航下划线滑动 ---- */
nav a {
    position: relative;
}

nav a::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 50%;
    width: 0;
    height: 2px;
    background: var(--accent);
    transition: width 0.3s ease, left 0.3s ease;
}

nav a:hover::after,
nav a.active::after {
    width: 100%;
    left: 0;
}

nav a.active {
    border-bottom: none;
}

/* ---- 10. 响应式 ---- */
@media (max-width: 768px) {
    .dashboard-params {
        grid-template-columns: repeat(2, 1fr);
    }
    .info-grid {
        grid-template-columns: 1fr;
    }
    .modal {
        padding: 20px !important;
    }
}

/* ============================================
 * 11. 大号搜索框
 * ============================================ */
.search-section {
    margin-bottom: 20px;
}

.search-bar-wrapper {
    display: flex;
    justify-content: center;
    margin-bottom: 12px;
}

.search-bar {
    position: relative;
    width: 100%;
    max-width: 640px;
}

.search-icon {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
    pointer-events: none;
    transition: color 0.3s ease;
}

.search-bar:focus-within .search-icon {
    color: var(--accent);
}

.search-input-large {
    width: 100%;
    padding: 16px 44px 16px 48px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    color: var(--text-primary);
    font-size: 16px;
    outline: none;
    transition: all 0.3s ease;
}

.search-input-large:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 4px rgba(212, 168, 83, 0.08), 0 0 30px rgba(212, 168, 83, 0.05);
}

.search-input-large::placeholder {
    color: var(--text-secondary);
}

.search-clear {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: var(--bg-input);
    border: none;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 12px;
    display: none;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.search-clear:hover {
    background: var(--danger);
    color: #fff;
}

.search-controls {
    display: flex;
    justify-content: center;
    gap: 12px;
}

.search-controls select {
    padding: 8px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 14px;
    outline: none;
}

/* ============================================
 * 12. 搜索结果卡片
 * ============================================ */
.search-results {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}

.search-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 16px;
    cursor: pointer;
    transition: all 0.2s ease;
    animation: card-fade-in 0.3s ease forwards;
    opacity: 0;
}

@keyframes card-fade-in {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.search-card:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
    box-shadow: 0 4px 20px rgba(0,0,0,0.3), 0 0 0 1px rgba(212,168,83,0.1);
}

.search-card:hover .search-card-code {
    text-shadow: 0 0 10px rgba(212, 168, 83, 0.4);
}

.search-card-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}

.search-card-code {
    font-family: 'JetBrains Mono', 'Consolas', monospace;
    color: var(--accent);
    font-weight: 600;
    font-size: 15px;
    transition: text-shadow 0.2s ease;
}

.search-card-tag {
    font-size: 9px;
    font-weight: 700;
    color: var(--blue);
    background: rgba(88, 166, 255, 0.1);
    border: 1px solid rgba(88, 166, 255, 0.3);
    border-radius: 3px;
    padding: 1px 5px;
    font-family: 'JetBrains Mono', monospace;
}

.search-card-name {
    font-size: 14px;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.search-card-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 10px;
    font-size: 12px;
    color: var(--text-secondary);
}

.search-card-meta .tag {
    background: var(--bg-input);
    padding: 2px 8px;
    border-radius: 3px;
    font-size: 11px;
}

.search-empty {
    grid-column: 1 / -1;
    text-align: center;
    padding: 48px;
    color: var(--text-secondary);
    font-style: italic;
    font-size: 14px;
}

/* ============================================
 * 13. 备件库存状态指示灯
 * ============================================ */
.status-low .status-dot {
    background: var(--danger);
    animation: blink-red 1s ease-in-out infinite;
}

.status-low {
    color: var(--danger);
}

.status-ok .status-dot {
    background: var(--success);
    box-shadow: 0 0 4px var(--success);
}

.status-ok {
    color: var(--success);
}

@keyframes blink-red {
    0%, 100% {
        opacity: 1;
        box-shadow: 0 0 8px var(--danger), 0 0 0 0 rgba(248, 81, 73, 0.4);
    }
    50% {
        opacity: 0.3;
        box-shadow: 0 0 2px var(--danger), 0 0 0 4px rgba(248, 81, 73, 0);
    }
}

/* 备件行低库存高亮 */
tr.low-stock-row td {
    background: rgba(248, 81, 73, 0.04);
}

tr.low-stock-row:hover td {
    background: rgba(248, 81, 73, 0.08) !important;
}

/* 响应式补充 */
@media (max-width: 768px) {
    .search-input-large {
        font-size: 14px;
        padding: 14px 40px 14px 44px;
    }
    .search-controls {
        flex-wrap: wrap;
    }
    .search-results {
        grid-template-columns: 1fr;
    }
}

/* ============ 设备详情仪表盘移动端适配（v2 2026-09-06） ============ */
@media (max-width: 768px) {
    /* 参数卡 4列 → 2列 */
    .dashboard-params { grid-template-columns: repeat(2, 1fr); gap: 8px; }
    .param-card { padding: 12px 8px; }
    /* 信息两列间距收紧 */
    .info-grid { gap: 0 12px; }
    /* 波形面板内边距收紧 */
    .waveform-panel { padding: 12px; }
}
