/* Alerts 组件样式 */

/* ==================== Alerts 容器 ==================== */

.tl-mt-alerts-container {
    padding: 24px;
}

/* ==================== 统计计数网格 ==================== */

.tl-mt-alerts-counts-grid {
    display: grid;
    grid-template-columns: repeat(1, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

@media (min-width: 768px) {
    .tl-mt-alerts-counts-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* ==================== 统计计数卡片 ==================== */

.tl-mt-alerts-count-card {
    background-color: #ffffff;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    border: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

body.dark .tl-mt-alerts-count-card {
    background-color: #1e293b;
    border-color: #334155;
}

.tl-mt-alerts-count-card-info-label {
    font-size: 12px;
    color: #64748b;
}

.tl-mt-alerts-count-card-info-value {
    font-size: 24px;
    font-weight: 700;
    margin-top: 4px;
    color: #1e293b;
}

body.dark .tl-mt-alerts-count-card-info-value {
    color: #ffffff;
}

.tl-mt-alerts-count-card-info-value.danger {
    color: #ef4444;
}

.tl-mt-alerts-count-card-info-value.warning {
    color: #eab308;
}

.tl-mt-alerts-count-card-info-value.success {
    color: #22c55e;
}

.tl-mt-alerts-count-card-icon {
    opacity: 0.2;
    font-size: 30px;
}

/* ==================== 预警列表卡片 ==================== */

.tl-mt-alerts-list-card {
    background-color: #ffffff;
    border-radius: 12px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    border: 1px solid #e2e8f0;
}

body.dark .tl-mt-alerts-list-card {
    background-color: #1e293b;
    border-color: #334155;
}

/* ==================== 预警列表项 ==================== */

.tl-mt-alerts-list-item {
    padding: 16px;
    border-bottom: 1px solid #f1f5f9;
    display: flex;
    align-items: center;
    gap: 16px;
    transition: background-color 0.15s;
}

body.dark .tl-mt-alerts-list-item {
    border-bottom-color: #1e293b;
}

.tl-mt-alerts-list-item:last-child {
    border-bottom: none;
}

.tl-mt-alerts-list-item:hover {
    background-color: #f8fafc;
}

body.dark .tl-mt-alerts-list-item:hover {
    background-color: #1e293b;
}

.tl-mt-alerts-list-item-icon-wrapper {
    width: 40px;
    height: 40px;
    border-radius: 9999px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.tl-mt-alerts-list-item-icon-wrapper.red {
    background-color: #fef2f2;
}

body.dark .tl-mt-alerts-list-item-icon-wrapper.red {
    background-color: rgba(153, 27, 27, 0.2);
}

.tl-mt-alerts-list-item-icon-wrapper.yellow {
    background-color: #fefce8;
}

body.dark .tl-mt-alerts-list-item-icon-wrapper.yellow {
    background-color: rgba(161, 98, 7, 0.2);
}

.tl-mt-alerts-list-item-icon {
    font-size: 20px;
}

.tl-mt-alerts-list-item-icon.danger {
    color: #ef4444;
}

.tl-mt-alerts-list-item-icon.warning {
    color: #eab308;
}

.tl-mt-alerts-list-item-content {
    flex: 1;
    min-width: 0;
}

.tl-mt-alerts-list-item-header {
    display: flex;
    align-items: center;
    gap: 8px;
}

.tl-mt-alerts-list-item-title {
    font-weight: 700;
    font-size: 14px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tl-mt-alerts-list-item-category {
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 10px;
    background-color: #f1f5f9;
    color: #64748b;
    text-transform: uppercase;
}

body.dark .tl-mt-alerts-list-item-category {
    background-color: #334155;
}

.tl-mt-alerts-list-item-desc {
    font-size: 12px;
    color: #64748b;
    margin-top: 4px;
}

.tl-mt-alerts-list-item-right {
    text-align: right;
    flex-shrink: 0;
}

.tl-mt-alerts-list-item-time {
    font-size: 10px;
    color: #94a3b8;
}

.tl-mt-alerts-list-item-action {
    margin-top: 4px;
    font-size: 12px;
    color: #0ea5e9;
    font-weight: 700;
    opacity: 0;
    transition: opacity 0.15s;
    background: none;
    border: none;
    cursor: pointer;
}

.tl-mt-alerts-list-item:hover .tl-mt-alerts-list-item-action {
    opacity: 1;
}

/* ==================== 预警筛选栏 ==================== */

.tl-mt-alerts-filter-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    padding: 16px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

body.dark .tl-mt-alerts-filter-bar {
    background: #0f172a;
}

.tl-mt-alerts-filter-buttons {
    display: flex;
    gap: 8px;
}

.tl-mt-alerts-filter-btn {
    padding: 8px 16px;
    font-size: 14px;
    border: 1px solid #e2e8f0;
    background: white;
    color: #475569;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.15s;
}

.tl-mt-alerts-filter-btn:hover {
    background: #f8fafc;
}

.tl-mt-alerts-filter-btn.active {
    background: #3b82f6;
    color: white;
    border-color: #3b82f6;
}

body.dark .tl-mt-alerts-filter-btn {
    background: #1e293b;
    border-color: #334155;
    color: #cbd5e1;
}

body.dark .tl-mt-alerts-filter-btn:hover {
    background: #334155;
}

body.dark .tl-mt-alerts-filter-btn.active {
    background: #3b82f6;
    border-color: #3b82f6;
}

.tl-mt-alerts-filter-selects {
    display: flex;
    gap: 12px;
}

.tl-mt-alerts-filter-select {
    padding: 8px 12px;
    font-size: 14px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    background: white;
    color: #475569;
    cursor: pointer;
}

body.dark .tl-mt-alerts-filter-select {
    background: #1e293b;
    border-color: #334155;
    color: #cbd5e1;
}

.tl-mt-alerts-list-item-meta {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 8px;
    font-size: 12px;
}

.tl-mt-alerts-list-item-level {
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 500;
}

.tl-mt-alerts-list-item-level.high {
    background: #fee2e2;
    color: #dc2626;
}

.tl-mt-alerts-list-item-level.medium {
    background: #fef3c7;
    color: #d97706;
}

body.dark .tl-mt-alerts-list-item-level.high {
    background: rgba(239, 68, 68, 0.2);
    color: #fca5a5;
}

body.dark .tl-mt-alerts-list-item-level.medium {
    background: rgba(234, 179, 8, 0.2);
    color: #fde047;
}

.tl-mt-alerts-list-item-handler {
    color: #64748b;
}

body.dark .tl-mt-alerts-list-item-handler {
    color: #94a3b8;
}

.tl-mt-alerts-list-item-status {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
    margin-bottom: 8px;
}

.tl-mt-alerts-list-item-status.active {
    background: #fef3c7;
    color: #d97706;
}

.tl-mt-alerts-list-item-status.resolved {
    background: #dcfce7;
    color: #15803d;
}

body.dark .tl-mt-alerts-list-item-status.active {
    background: rgba(234, 179, 8, 0.2);
    color: #fde047;
}

body.dark .tl-mt-alerts-list-item-status.resolved {
    background: rgba(34, 197, 94, 0.2);
    color: #86efac;
}

.tl-mt-alerts-list-item-action.danger {
    color: #ef4444;
}

.tl-mt-alerts-empty {
    text-align: center;
    padding: 60px 20px;
    color: #94a3b8;
}

.tl-mt-alerts-empty .material-symbols-outlined {
    font-size: 64px;
    opacity: 0.3;
    margin-bottom: 16px;
}

.tl-mt-alerts-empty p {
    font-size: 16px;
    margin: 0;
}

/* ==================== 预警规则配置按钮 ==================== */

.tl-mt-alerts-config-btn {
    background: #0ea5e9;
    color: #ffffff;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    border: none;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.2s;
    box-shadow: 0 1px 3px rgba(14, 165, 233, 0.3);
}

.tl-mt-alerts-config-btn:hover {
    background: #0284c7;
}

/* ==================== 预警规则配置对话框 ==================== */

.tl-mt-modal-content.large {
    max-width: 900px;
}

.tl-mt-alert-rules-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    max-height: 500px;
    overflow-y: auto;
}

.tl-mt-alert-rule-card {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 1rem;
    transition: all 0.2s;
}

body.dark .tl-mt-alert-rule-card {
    background: #334155;
    border-color: #475569;
}

.tl-mt-alert-rule-card:hover {
    border-color: #0ea5e9;
    box-shadow: 0 2px 8px rgba(14, 165, 233, 0.1);
}

.tl-mt-alert-rule-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.tl-mt-alert-rule-header-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.tl-mt-alert-rule-icon {
    font-size: 2rem;
    color: #64748b;
}

.tl-mt-alert-rule-icon.inventory {
    color: #0ea5e9;
}

.tl-mt-alert-rule-icon.quality {
    color: #eab308;
}

.tl-mt-alert-rule-title {
    font-size: 1rem;
    font-weight: 600;
    color: #0f172a;
    margin-bottom: 0.25rem;
}

body.dark .tl-mt-alert-rule-title {
    color: #ffffff;
}

.tl-mt-alert-rule-desc {
    font-size: 0.875rem;
    color: #64748b;
}

body.dark .tl-mt-alert-rule-desc {
    color: #cbd5e1;
}

/* Toggle Switch */
.tl-mt-alert-rule-toggle {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 26px;
}

.tl-mt-alert-rule-toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.tl-mt-alert-rule-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #cbd5e1;
    transition: 0.3s;
    border-radius: 26px;
}

body.dark .tl-mt-alert-rule-slider {
    background-color: #475569;
}

.tl-mt-alert-rule-slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
}

.tl-mt-alert-rule-toggle input:checked + .tl-mt-alert-rule-slider {
    background-color: #0ea5e9;
}

.tl-mt-alert-rule-toggle input:checked + .tl-mt-alert-rule-slider:before {
    transform: translateX(24px);
}

.tl-mt-alert-rule-config {
    display: grid;
    grid-template-columns: repeat(1, 1fr);
    gap: 1rem;
    padding-top: 1rem;
    border-top: 1px solid #e2e8f0;
}

body.dark .tl-mt-alert-rule-config {
    border-top-color: #475569;
}

@media (min-width: 640px) {
    .tl-mt-alert-rule-config {
        grid-template-columns: repeat(2, 1fr);
    }
}

.tl-mt-alert-rule-param {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.tl-mt-alert-rule-param label {
    font-size: 0.875rem;
    font-weight: 500;
    color: #475569;
}

body.dark .tl-mt-alert-rule-param label {
    color: #cbd5e1;
}

.tl-mt-alert-rule-input {
    padding: 0.5rem 0.75rem;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    font-size: 0.875rem;
    color: #475569;
    background: #ffffff;
    transition: all 0.2s;
}

body.dark .tl-mt-alert-rule-input {
    background: #1e293b;
    border-color: #475569;
    color: #e2e8f0;
}

.tl-mt-alert-rule-input:focus {
    outline: none;
    border-color: #0ea5e9;
    box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.1);
}
