/* Alerts page styles */

.alerts-container {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.alerts-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
}

.header-info h2 {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 0.5rem;
}

.header-info h2 svg {
    color: var(--primary);
}

.alert-summary {
    display: flex;
    gap: 1rem;
}

.summary-item {
    font-size: 0.75rem;
    font-weight: 500;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
}

.summary-item.critical {
    background: rgba(239, 68, 68, 0.1);
    color: var(--error);
}

.summary-item.warning {
    background: rgba(245, 158, 11, 0.1);
    color: var(--warning);
}

.summary-item.info {
    background: var(--primary-light);
    color: var(--primary);
}

.header-actions {
    display: flex;
    gap: 0.5rem;
}

.action-btn {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.5rem 0.875rem;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 0.8125rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.action-btn:hover {
    background: var(--primary-hover);
}

.action-btn.secondary {
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
}

.action-btn.secondary:hover {
    background: var(--surface-hover);
    border-color: var(--primary);
}

.action-btn.small {
    padding: 0.375rem 0.625rem;
    font-size: 0.75rem;
}

/* Alerts Tabs */
.alerts-tabs {
    display: flex;
    gap: 0.25rem;
    border-bottom: 1px solid var(--border);
    padding-bottom: 0;
}

.tab-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    transition: all 0.2s ease;
}

.tab-btn:hover {
    color: var(--text);
    background: var(--surface-hover);
}

.tab-btn.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.tab-badge {
    background: var(--border);
    color: var(--text-secondary);
    font-size: 0.6875rem;
    font-weight: 600;
    padding: 0.125rem 0.375rem;
    border-radius: 10px;
    min-width: 18px;
    text-align: center;
}

.tab-btn.active .tab-badge {
    background: var(--primary-light);
    color: var(--primary);
}

/* Tab Panels */
.tab-panel {
    display: none;
}

.tab-panel.active {
    display: block;
}

.panel-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 0;
    gap: 1rem;
    flex-wrap: wrap;
}

.filter-group {
    display: flex;
    gap: 0.5rem;
}

.filter-group select {
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 0.5rem 0.75rem;
    border-radius: 6px;
    font-size: 0.8125rem;
    cursor: pointer;
}

.filter-group select:focus {
    outline: none;
    border-color: var(--primary);
}

.search-box {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.5rem 0.75rem;
}

.search-box svg {
    color: var(--text-secondary);
    flex-shrink: 0;
}

.search-box input {
    background: transparent;
    border: none;
    color: var(--text);
    font-size: 0.8125rem;
    width: 200px;
    outline: none;
}

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

/* Alerts List */
.alerts-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.alert-item {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    padding: 1rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    border-left: 4px solid transparent;
}

.alert-item.critical {
    border-left-color: var(--error);
}

.alert-item.warning {
    border-left-color: var(--warning);
}

.alert-item.info {
    border-left-color: var(--primary);
}

.alert-severity {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    flex-shrink: 0;
}

.alert-item.critical .alert-severity {
    background: rgba(239, 68, 68, 0.1);
    color: var(--error);
}

.alert-item.warning .alert-severity {
    background: rgba(245, 158, 11, 0.1);
    color: var(--warning);
}

.alert-item.info .alert-severity {
    background: var(--primary-light);
    color: var(--primary);
}

.alert-content {
    flex: 1;
}

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

.alert-message {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    line-height: 1.4;
}

.alert-meta {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.alert-meta span {
    font-size: 0.75rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.alert-meta svg {
    width: 12px;
    height: 12px;
}

.alert-actions {
    display: flex;
    gap: 0.5rem;
    flex-shrink: 0;
}

.alert-action-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
}

.alert-action-btn:hover {
    background: var(--surface-hover);
    color: var(--primary);
    border-color: var(--primary);
}

.alert-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4rem;
    text-align: center;
    color: var(--text-secondary);
}

.alert-placeholder svg {
    margin-bottom: 1rem;
    color: var(--success);
    opacity: 0.7;
}

.alert-placeholder p {
    font-size: 1rem;
    color: var(--text);
    margin-bottom: 0.25rem;
}

/* Rules Grid */
.rules-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1rem;
}

.rule-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
    transition: all 0.2s ease;
}

.rule-card:hover {
    border-color: var(--primary);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.rule-card.disabled {
    opacity: 0.6;
}

.rule-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem;
    border-bottom: 1px solid var(--border);
}

.rule-status {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--success);
}

.rule-card.disabled .rule-status {
    background: var(--text-secondary);
}

.rule-toggle {
    position: relative;
    width: 36px;
    height: 20px;
}

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

.rule-toggle .toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--border);
    border-radius: 20px;
    transition: 0.3s;
}

.rule-toggle .toggle-slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 2px;
    bottom: 2px;
    background: white;
    border-radius: 50%;
    transition: 0.3s;
}

.rule-toggle input:checked + .toggle-slider {
    background: var(--primary);
}

.rule-toggle input:checked + .toggle-slider:before {
    transform: translateX(16px);
}

.rule-body {
    padding: 1rem;
}

.rule-name {
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 0.375rem;
}

.rule-condition {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
    font-family: 'SF Mono', 'Monaco', 'Inconsolata', monospace;
    background: var(--bg);
    padding: 0.375rem 0.5rem;
    border-radius: 4px;
}

.rule-info {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.rule-info span {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.rule-info .severity {
    padding: 0.125rem 0.375rem;
    border-radius: 4px;
    font-weight: 500;
}

.rule-info .severity.critical {
    background: rgba(239, 68, 68, 0.1);
    color: var(--error);
}

.rule-info .severity.warning {
    background: rgba(245, 158, 11, 0.1);
    color: var(--warning);
}

.rule-info .severity.info {
    background: var(--primary-light);
    color: var(--primary);
}

.rule-actions {
    display: flex;
    border-top: 1px solid var(--border);
}

.rule-action {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.rule-action:hover {
    background: var(--surface-hover);
    color: var(--primary);
}

.rule-action:not(:last-child) {
    border-right: 1px solid var(--border);
}

.rule-action svg {
    width: 14px;
    height: 14px;
    margin-right: 0.375rem;
}

/* Skeleton Loading */
.rule-card.skeleton {
    min-height: 150px;
    padding: 1rem;
}

.skeleton-line {
    height: 16px;
    background: linear-gradient(90deg, var(--border) 25%, var(--surface-hover) 50%, var(--border) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 4px;
    margin-bottom: 0.75rem;
}

.skeleton-line.short {
    width: 60%;
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* History List */
.history-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.history-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.875rem 1rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
}

.history-time {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-family: 'SF Mono', 'Monaco', 'Inconsolata', monospace;
    white-space: nowrap;
}

.history-severity {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.history-severity.critical { background: var(--error); }
.history-severity.warning { background: var(--warning); }
.history-severity.info { background: var(--primary); }

.history-content {
    flex: 1;
    min-width: 0;
}

.history-name {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text);
}

.history-outcome {
    font-size: 0.75rem;
    padding: 0.125rem 0.375rem;
    border-radius: 4px;
    font-weight: 500;
}

.history-outcome.resolved {
    background: rgba(34, 197, 94, 0.1);
    color: var(--success);
}

.history-outcome.acknowledged {
    background: var(--primary-light);
    color: var(--primary);
}

.history-outcome.expired {
    background: var(--bg);
    color: var(--text-secondary);
}

/* Modal Styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.modal-overlay.open {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    width: 100%;
    max-width: 560px;
    max-height: 90vh;
    overflow: hidden;
    transform: translateY(20px);
    transition: transform 0.3s ease;
}

.modal-overlay.open .modal {
    transform: translateY(0);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
}

.modal-header h3 {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text);
}

.modal-header h3 svg {
    color: var(--primary);
}

.close-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.close-btn:hover {
    background: var(--surface-hover);
    color: var(--text);
}

.modal-body {
    padding: 1.25rem;
    overflow-y: auto;
    max-height: calc(90vh - 140px);
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--border);
}

.btn {
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn.primary {
    background: var(--primary);
    color: white;
    border: none;
}

.btn.primary:hover {
    background: var(--primary-hover);
}

.btn.secondary {
    background: transparent;
    color: var(--text);
    border: 1px solid var(--border);
}

.btn.secondary:hover {
    background: var(--surface-hover);
    border-color: var(--primary);
}

/* Form Styles */
.form-section {
    margin-bottom: 1.5rem;
}

.form-section:last-child {
    margin-bottom: 0;
}

.form-section h4 {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border);
}

.form-group {
    margin-bottom: 1rem;
}

.form-group:last-child {
    margin-bottom: 0;
}

.form-group label {
    display: block;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text);
    margin-bottom: 0.375rem;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.5rem 0.75rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    font-size: 0.875rem;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
}

.form-group input::placeholder,
.form-group textarea::placeholder {
    color: var(--text-secondary);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.notification-channels {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.8125rem;
    color: var(--text);
    transition: all 0.2s ease;
}

.checkbox-label:hover {
    border-color: var(--primary);
}

.checkbox-label input {
    display: none;
}

.checkbox-label input:checked + .checkbox-custom + svg {
    color: var(--primary);
}

.checkbox-label input:checked ~ span:last-child {
    color: var(--primary);
}

.checkbox-custom {
    width: 16px;
    height: 16px;
    border: 2px solid var(--border);
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.checkbox-label input:checked + .checkbox-custom {
    background: var(--primary);
    border-color: var(--primary);
}

.checkbox-label input:checked + .checkbox-custom::after {
    content: "";
    width: 4px;
    height: 8px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.toggle-label {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
    font-size: 0.875rem;
    color: var(--text);
}

.toggle-label input {
    display: none;
}

.toggle-switch {
    position: relative;
    width: 44px;
    height: 24px;
    background: var(--border);
    border-radius: 24px;
    transition: background 0.3s ease;
}

.toggle-switch::before {
    content: "";
    position: absolute;
    width: 20px;
    height: 20px;
    background: white;
    border-radius: 50%;
    top: 2px;
    left: 2px;
    transition: transform 0.3s ease;
}

.toggle-label input:checked + .toggle-switch {
    background: var(--primary);
}

.toggle-label input:checked + .toggle-switch::before {
    transform: translateX(20px);
}

/* Responsive */
@media (max-width: 768px) {
    .alerts-header {
        flex-direction: column;
        align-items: stretch;
    }

    .header-actions {
        flex-wrap: wrap;
    }

    .alerts-tabs {
        overflow-x: auto;
    }

    .tab-btn {
        white-space: nowrap;
    }

    .panel-toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .filter-group {
        flex-wrap: wrap;
    }

    .search-box {
        width: 100%;
    }

    .search-box input {
        width: 100%;
    }

    .rules-grid {
        grid-template-columns: 1fr;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .modal {
        margin: 1rem;
        max-height: calc(100vh - 2rem);
    }
}
