/**
 * Configuration modal – matches csm-ui. Literal values only.
 */

.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
}

.modal-content {
  background: #fff;
  border-radius: 12px;
  width: 90%;
  max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
  overflow-x: hidden;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
  position: relative;
}

.modal-content-alert-rules {
  max-width: 42rem;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 24px;
  border-bottom: 1px solid #e5e7eb;
}

.modal-header h2 {
  font-size: 20px;
  font-weight: 600;
  color: #1a1a1a;
}

.close-button {
  background: none;
  border: none;
  font-size: 24px;
  color: #666;
  cursor: pointer;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
}

.close-button:hover {
  background-color: #f5f5f5;
}

.modal-description {
  padding: 24px;
  color: #666;
  font-size: 14px;
  border-bottom: 1px solid #e5e7eb;
}

.form-section {
  padding: 24px;
  border-bottom: 1px solid #e5e7eb;
  position: relative;
  z-index: 1;
  overflow: visible;
}

.practice-select-container {
  position: relative;
  z-index: 100;
  overflow: visible;
}

.form-section:last-of-type {
  border-bottom: none;
}

.form-section h3 {
  font-size: 16px;
  font-weight: 600;
  color: #1a1a1a;
  margin-bottom: 16px;
}

.radio-group {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.radio-group label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: #1a1a1a;
  cursor: pointer;
}

.threshold-group {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

.threshold-item {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.threshold-item label {
  font-size: 14px;
  font-weight: 500;
  color: #1a1a1a;
}

.input-with-unit {
  display: flex;
  align-items: center;
  border: 1px solid #ddd;
  border-radius: 6px;
  overflow: hidden;
}

.input-with-unit input {
  flex: 1;
  padding: 10px 12px;
  border: none;
  font-size: 14px;
}

.input-with-unit input:focus {
  outline: none;
}

.input-with-unit .unit {
  padding: 10px 12px;
  background-color: #f5f5f5;
  font-size: 14px;
  color: #666;
  border-left: 1px solid #ddd;
}

.practice-select {
  width: 100%;
  padding: 10px 12px;
  padding-right: 40px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 14px;
  background: #fff;
  cursor: pointer;
  position: relative;
  z-index: 100;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23666' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 12px;
}

.practice-select:focus {
  outline: none;
  border-color: #1a1a1a;
  z-index: 101;
}

.practice-selection-controls {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.select-all-button,
.deselect-all-button {
  padding: 6px 12px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 12px;
  background: #fff;
  color: #1a1a1a;
  cursor: pointer;
}

.select-all-button:hover,
.deselect-all-button:hover {
  background-color: #f5f5f5;
}

.practice-list {
  max-height: 200px;
  overflow-y: auto;
  border: 1px solid #ddd;
  border-radius: 6px;
  padding: 8px;
  background: #fafafa;
}

.practice-checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
  cursor: pointer;
  border-radius: 4px;
  font-size: 14px;
}

.practice-checkbox-label:hover {
  background-color: #f5f5f5;
}

.threshold-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 6px;
}

.watch-dot {
  background-color: #f59e0b;
}

.flagged-dot {
  background-color: #ef4444;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  padding: 24px;
  border-top: 1px solid #e5e7eb;
}

.cancel-button,
.save-button {
  padding: 10px 20px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border: none;
}

.cancel-button {
  background: #fff;
  color: #1a1a1a;
  border: 1px solid #ddd;
}

.cancel-button:hover {
  background-color: #f5f5f5;
}

.save-button {
  background: #1a1a1a;
  color: #fff;
}

.save-button:hover {
  background: #333;
}

/* Alert Rules Configuration – 5 metric cards + severity toggles */
.alert-rules-list {
  padding: 0 24px 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.alert-rule-card {
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 16px;
  background: #fff;
  transition: background-color 0.15s;
}

.alert-rule-card:hover {
  background: #f9fafb;
}

.alert-rule-card-inner {
  display: flex;
  align-items: flex-start;
  gap: 16px;
}

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

.alert-rule-title {
  font-size: 1rem;
  font-weight: 500;
  color: #111827;
  margin: 0 0 4px;
}

.alert-rule-desc {
  font-size: 0.875rem;
  color: #4b5563;
  margin: 0 0 12px;
}

.alert-rule-fields {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.alert-rule-three-levels {
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
}

/* Single threshold + severity row (Figma: one input per rule, severity toggles) */
.alert-rule-single-threshold {
  flex-direction: row;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
}

.alert-rule-threshold-severity-row {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.alert-rule-threshold-group,
.alert-rule-severity-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.alert-rule-threshold-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.alert-rule-threshold,
.alert-rule-severity {
  display: flex;
  align-items: center;
  gap: 8px;
}

.alert-rule-label {
  font-size: 0.875rem;
  font-weight: 500;
  color: #374151;
}

.alert-rule-input {
  width: 8rem;
  height: 36px;
  padding: 0 12px;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  font-size: 0.875rem;
  background: #fff;
}

.alert-rule-input:focus {
  outline: none;
  border-color: #1a1a1a;
  box-shadow: 0 0 0 2px rgba(26, 26, 26, 0.1);
}

.alert-rule-unit {
  font-size: 0.875rem;
  color: #6b7280;
}

.severity-toggle {
  display: inline-flex;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  background: #fff;
  overflow: hidden;
}

.severity-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  font-size: 0.875rem;
  font-weight: 500;
  border: none;
  background: transparent;
  color: #4b5563;
  cursor: pointer;
  border-left: 1px solid #d1d5db;
  transition: background-color 0.15s, color 0.15s;
}

.severity-btn:first-child {
  border-left: none;
}

.severity-btn:hover {
  background: #f9fafb;
}

.severity-btn.active {
  cursor: default;
}

.severity-btn-good.active {
  background: #dcfce7;
  color: #15803d;
  border-color: #86efac;
}

.severity-btn-warning.active {
  background: #fef9c3;
  color: #a16207;
  border-color: #fde047;
}

.severity-btn-flagged.active {
  background: #fee2e2;
  color: #b91c1c;
  border-color: #fca5a5;
}

.severity-icon {
  font-size: 1rem;
  line-height: 1;
}

.modal-actions-alert-rules {
  flex-direction: column;
  align-items: stretch;
  margin-top: 0;
  padding-top: 16px;
  border-top: 1px solid #e5e7eb;
}

.alert-rules-how-it-works {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  padding: 12px 16px;
  margin-bottom: 16px;
}

.alert-rules-how-it-works p {
  margin: 0;
  font-size: 0.875rem;
  color: #1e40af;
}

.modal-actions-buttons {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}
