/* Phase 4B: Event Rule Editor styles */

/* Events sub-tabs */
.events-sub-tabs {
    display: flex;
    gap: 0;
    border-bottom: 2px solid #e0e0e0;
    margin-bottom: 8px;
}

.events-sub-tabs .sub-tab {
    padding: 6px 16px;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 13px;
    color: #666;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
}

.events-sub-tabs .sub-tab.active {
    color: #2196f3;
    border-bottom-color: #2196f3;
    font-weight: 600;
}

/* Rules list */
.rules-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
}

.rules-header h3 {
    margin: 0;
    font-size: 14px;
}

.rule-create-btn {
    padding: 4px 12px;
    background: #4caf50;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
}

.rule-create-btn:hover { background: #43a047; }

.rules-list {
    overflow-y: auto;
}

/* Rule card */
.rule-card {
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    margin-bottom: 8px;
    overflow: hidden;
}

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

.rule-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    border-bottom: 1px solid #f0f0f0;
}

.rule-card-header.sev-0 { border-left: 3px solid #5bc0de; }
.rule-card-header.sev-1 { border-left: 3px solid #5cb85c; }
.rule-card-header.sev-2 { border-left: 3px solid #f0ad4e; }
.rule-card-header.sev-3 { border-left: 3px solid #e67e22; }
.rule-card-header.sev-4 { border-left: 3px solid #d9534f; }

.rule-name {
    font-weight: 600;
    font-size: 13px;
}

.rule-type-badge {
    font-size: 11px;
    padding: 2px 6px;
    background: #e3f2fd;
    color: #1565c0;
    border-radius: 3px;
    text-transform: capitalize;
}

.rule-card-body {
    padding: 8px 12px;
}

.rule-meta {
    display: flex;
    gap: 12px;
    margin-bottom: 6px;
    font-size: 12px;
    color: #666;
}

.rule-severity {
    padding: 1px 6px;
    border-radius: 3px;
    font-size: 11px;
}

.sev-badge-0 { background: #e1f5fe; color: #0277bd; }
.sev-badge-1 { background: #e8f5e9; color: #2e7d32; }
.sev-badge-2 { background: #fff3e0; color: #e65100; }
.sev-badge-3 { background: #ffe0b2; color: #bf360c; }
.sev-badge-4 { background: #ffebee; color: #b71c1c; }

.rule-actions {
    display: flex;
    gap: 6px;
}

.rule-actions button {
    padding: 3px 8px;
    font-size: 11px;
    border: 1px solid #ddd;
    border-radius: 3px;
    background: #f8f8f8;
    cursor: pointer;
}

.rule-toggle-btn:hover { background: #fff3e0; border-color: #ff9800; }
.rule-edit-btn:hover { background: #e3f2fd; border-color: #2196f3; }
.rule-duplicate-btn:hover { background: #f3e5f5; border-color: #9c27b0; }
.rule-delete-btn:hover { background: #ffebee; border-color: #f44336; }

/* Rule editor modal */
.rule-editor-modal {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 10001;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.rule-editor-content {
    background: #fff;
    border-radius: 8px;
    width: 600px;
    max-width: 95vw;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 8px 32px rgba(0,0,0,0.2);
}

.rule-editor-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    border-bottom: 1px solid #eee;
    background: #f8f8f8;
    border-radius: 8px 8px 0 0;
}

.rule-editor-header h3 {
    margin: 0;
    font-size: 16px;
}

.rule-editor-close {
    background: none;
    border: none;
    font-size: 22px;
    cursor: pointer;
    color: #999;
}

.rule-editor-body {
    padding: 16px 20px;
}

.rule-editor-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 12px 20px;
    border-top: 1px solid #eee;
}

.rule-cancel-btn {
    padding: 6px 16px;
    background: #f5f5f5;
    border: 1px solid #ddd;
    border-radius: 4px;
    cursor: pointer;
}

.rule-save-btn {
    padding: 6px 16px;
    background: #2196f3;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

.rule-save-btn:hover { background: #1976d2; }

/* Editor sections */
.editor-section {
    margin-bottom: 20px;
    padding: 12px;
    background: #fafafa;
    border-radius: 6px;
    border: 1px solid #f0f0f0;
}

.editor-section h4 {
    margin: 0 0 10px 0;
    font-size: 14px;
    color: #333;
    border-bottom: 1px solid #e0e0e0;
    padding-bottom: 4px;
}

.editor-row {
    display: flex;
    align-items: center;
    margin-bottom: 8px;
    gap: 12px;
}

.editor-row label {
    min-width: 140px;
    font-size: 13px;
    font-weight: 500;
    color: #555;
}

.editor-row input[type="text"],
.editor-row input[type="number"],
.editor-row input[type="url"],
.editor-row input[type="time"],
.editor-row select {
    flex: 1;
    padding: 4px 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 13px;
}

.multi-select {
    flex: 1;
    max-height: 120px;
    overflow-y: auto;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 4px;
}

.multi-select label {
    display: block;
    min-width: 0;
    font-weight: normal;
    font-size: 12px;
    padding: 2px 0;
}

.weekday-selector {
    flex: 1;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.weekday-selector label {
    min-width: 0;
    font-weight: normal;
    font-size: 12px;
}

.time-range-inputs {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 8px;
}

.section-note {
    font-size: 11px;
    color: #999;
    font-style: italic;
    margin-bottom: 8px;
}

.planned-badge {
    font-size: 10px;
    padding: 1px 4px;
    background: #e0e0e0;
    color: #666;
    border-radius: 2px;
    margin-left: 4px;
}

.webhook-test-btn {
    padding: 4px 12px;
    background: #e0e0e0;
    color: #999;
    border: none;
    border-radius: 4px;
    cursor: not-allowed;
    font-size: 12px;
}

/* Loading/empty/error states */
.rules-loading,
.rules-empty,
.rules-error {
    padding: 20px;
    text-align: center;
    color: #999;
    font-size: 13px;
}

.rules-error { color: #d9534f; }

.rules-empty button {
    margin-top: 8px;
}

/* Responsive */
@media (max-width: 768px) {
    .rule-editor-content {
        width: 100vw;
        max-width: 100vw;
        max-height: 100vh;
        border-radius: 0;
    }

    .editor-row {
        flex-direction: column;
        align-items: flex-start;
    }

    .editor-row label {
        min-width: 0;
    }
}
