/* ============================================================
   NormaViva — Alertas Pro · estilos
   Convive con _shared.css (pro-site) + mi-expediente.css.
   ============================================================ */

.ap-toolbar {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 24px 0 18px;
  flex-wrap: wrap;
}

.ap-toolbar-hint {
  font-size: 13px;
  color: var(--me-mute, #6b7280);
}

.ap-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  padding: 9px 16px;
  border-radius: 8px;
  border: 1px solid transparent;
  cursor: pointer;
  background: #fff;
  color: #0b1e3f;
  transition: background .15s, border-color .15s, color .15s;
  text-decoration: none;
  line-height: 1.2;
}

.ap-btn--primary {
  background: #0b1e3f;
  color: #fff;
  border-color: #0b1e3f;
}
.ap-btn--primary:hover { background: #142b5c; border-color: #142b5c; }

.ap-btn--ghost {
  background: transparent;
  color: #0b1e3f;
  border-color: #d4d9e0;
}
.ap-btn--ghost:hover { background: #f1f3f7; border-color: #b9c0cb; }

.ap-btn--danger {
  background: transparent;
  color: #b91c1c;
  border-color: #f1c5c5;
}
.ap-btn--danger:hover { background: #fdf1f1; }

.ap-btn--gold {
  background: #c8a44b;
  color: #1a1a1a;
  border-color: #c8a44b;
}
.ap-btn--gold:hover { background: #b48f3a; border-color: #b48f3a; }

/* ─── form ─── */
.ap-form-section {
  background: #fff;
  border: 1px solid #e6e9ef;
  border-radius: 12px;
  padding: 22px;
  margin-bottom: 24px;
}

.ap-form-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}
.ap-form-row label {
  font-size: 13px;
  font-weight: 600;
  color: #2d3748;
}
.ap-hint {
  font-weight: 400;
  color: #6b7280;
  font-size: 12px;
  margin-left: 4px;
}

.ap-form-row input[type="text"],
.ap-form-row select {
  font-family: inherit;
  font-size: 14px;
  padding: 9px 12px;
  border: 1px solid #d4d9e0;
  border-radius: 7px;
  background: #fff;
  color: #1a202c;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.ap-form-row input[type="text"]:focus,
.ap-form-row select:focus {
  border-color: #0b1e3f;
  box-shadow: 0 0 0 2px rgba(11,30,63,.12);
}

/* chips input */
.ap-chips-input {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  padding: 6px 8px;
  border: 1px solid #d4d9e0;
  border-radius: 7px;
  background: #fff;
  min-height: 42px;
}
.ap-chips-input:focus-within {
  border-color: #0b1e3f;
  box-shadow: 0 0 0 2px rgba(11,30,63,.12);
}
.ap-chips-input input[type="text"] {
  flex: 1;
  min-width: 140px;
  padding: 4px 6px;
  border: 0;
  outline: 0;
  background: transparent;
  font-size: 14px;
}
.ap-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.ap-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #eef2f7;
  color: #0b1e3f;
  font-size: 12px;
  font-weight: 600;
  padding: 4px 6px 4px 10px;
  border-radius: 999px;
  line-height: 1.4;
}
.ap-chip button {
  background: transparent;
  border: 0;
  color: #4a5568;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  padding: 0 4px;
  border-radius: 50%;
}
.ap-chip button:hover { color: #b91c1c; }

/* radio group */
.ap-radio-group {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
}
.ap-radio {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  color: #2d3748;
  cursor: pointer;
}
.ap-radio input { accent-color: #0b1e3f; }

.ap-form-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  flex-wrap: wrap;
  border-top: 1px solid #eef0f4;
  padding-top: 14px;
  margin-top: 8px;
}

.ap-error {
  background: #fdf1f1;
  border: 1px solid #f1c5c5;
  color: #8b1c1c;
  font-size: 13px;
  padding: 10px 14px;
  border-radius: 8px;
  margin-bottom: 14px;
}

/* preview */
.ap-preview {
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px dashed #d4d9e0;
}
.ap-preview h3 {
  font-size: 14px;
  font-weight: 700;
  color: #0b1e3f;
  margin: 0 0 10px;
}
.ap-preview-list {
  list-style: none;
  padding: 0;
  margin: 10px 0 0;
}
.ap-preview-list li {
  background: #f7f8fa;
  border: 1px solid #e6e9ef;
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 6px;
  font-size: 13px;
}
.ap-preview-list .ap-prev-tipo {
  display: inline-block;
  font-size: 10px;
  letter-spacing: .04em;
  text-transform: uppercase;
  font-weight: 700;
  color: #6b7280;
  margin-bottom: 2px;
}
.ap-preview-list .ap-prev-titulo {
  color: #0b1e3f;
  font-weight: 600;
}
.ap-preview-list .ap-prev-fecha {
  font-size: 11px;
  color: #6b7280;
  margin-left: 6px;
}

/* rules list */
.ap-rules-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 12px;
}
.ap-rule-card {
  background: #fff;
  border: 1px solid #e6e9ef;
  border-radius: 12px;
  padding: 18px 20px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: start;
}
.ap-rule-card.ap-rule--paused {
  background: #f7f8fa;
  border-style: dashed;
  opacity: .85;
}
.ap-rule-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}
.ap-rule-name {
  font-size: 16px;
  font-weight: 700;
  color: #0b1e3f;
  margin: 0;
}
.ap-rule-tag {
  display: inline-block;
  font-size: 11px;
  letter-spacing: .04em;
  text-transform: uppercase;
  font-weight: 700;
  background: #eef2f7;
  color: #0b1e3f;
  padding: 2px 8px;
  border-radius: 999px;
}
.ap-rule-tag--paused {
  background: #fef3c7;
  color: #8a6d1d;
}
.ap-rule-meta {
  font-size: 12px;
  color: #6b7280;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 4px;
}
.ap-rule-criterios {
  margin-top: 10px;
  font-size: 13px;
  color: #2d3748;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.ap-rule-criterios .ap-chip {
  background: #f1f3f7;
  color: #2d3748;
  font-weight: 500;
  padding: 2px 8px;
  font-size: 11px;
}
.ap-rule-criterios .ap-chip strong {
  color: #6b7280;
  font-weight: 700;
  margin-right: 3px;
}

.ap-rule-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: flex-end;
}
.ap-rule-actions .ap-btn {
  font-size: 12px;
  padding: 5px 10px;
}

/* toggle */
.ap-toggle {
  position: relative;
  width: 36px;
  height: 20px;
  background: #ccd2db;
  border-radius: 999px;
  cursor: pointer;
  transition: background .15s;
  flex-shrink: 0;
  border: 0;
  padding: 0;
}
.ap-toggle::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  background: #fff;
  border-radius: 50%;
  transition: transform .15s;
  box-shadow: 0 1px 2px rgba(0,0,0,.2);
}
.ap-toggle.is-on {
  background: #2d7d4a;
}
.ap-toggle.is-on::after {
  transform: translateX(16px);
}

/* empty */
.ap-empty {
  text-align: center;
  background: #f7f8fa;
  border: 1px dashed #d4d9e0;
  border-radius: 12px;
  padding: 32px 22px;
  color: #2d3748;
}
.ap-empty p { margin: 0 0 6px; }
.ap-empty-sub { font-size: 13px; color: #6b7280; }

/* modal */
.ap-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}
.ap-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(11,30,63,.55);
}
.ap-modal-content {
  position: relative;
  background: #fff;
  border-radius: 12px;
  max-width: 640px;
  width: calc(100% - 32px);
  max-height: 80vh;
  overflow: auto;
  padding: 26px 24px 22px;
  box-shadow: 0 20px 50px rgba(0,0,0,.25);
}
.ap-modal-content h2 {
  margin: 0 0 14px;
  font-size: 18px;
  color: #0b1e3f;
}
.ap-modal-close {
  position: absolute;
  top: 10px;
  right: 12px;
  background: transparent;
  border: 0;
  font-size: 26px;
  color: #6b7280;
  cursor: pointer;
  line-height: 1;
}
.ap-history-list {
  list-style: none;
  padding: 0;
  margin: 0;
}
.ap-history-list li {
  border-bottom: 1px solid #eef0f4;
  padding: 10px 0;
  font-size: 13px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
}
.ap-history-list li:last-child { border-bottom: 0; }
.ap-history-list .ap-h-meta {
  color: #6b7280;
  font-size: 11px;
}

.ap-disclaimer {
  margin: 32px 0 12px;
  font-size: 11px;
  color: #9aa0aa;
  text-align: center;
}

/* responsive */
@media (max-width: 640px) {
  .ap-rule-card {
    grid-template-columns: 1fr;
  }
  .ap-rule-actions {
    flex-direction: row;
    justify-content: flex-start;
    flex-wrap: wrap;
    align-items: center;
  }
}
