/**
 * Alert panel — slide-out panel from the right (triggered by header alert icon)
 */

/* Alert icon badge (shown when Guardian detects sensitive data on send) */
#alertPanelBtn {
  position: relative;
}
.alert-panel-btn-badge {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #dc2626;
  border: 2px solid var(--color-surface, #fff);
  pointer-events: none;
}
.alert-panel-btn-badge[hidden] {
  display: none !important;
}

/* Needs attention banner (header top-right, shown when Guardian detects sensitive data) */
.needs-attention-banner {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 8px;
  background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
  border: 1px solid #f59e0b;
  color: #92400e;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s ease, box-shadow 0.2s ease;
  box-shadow: 0 1px 3px rgba(245, 158, 11, 0.2);
}
.needs-attention-banner:hover {
  background: linear-gradient(135deg, #fde68a 0%, #fcd34d 100%);
  box-shadow: 0 2px 8px rgba(245, 158, 11, 0.3);
}
.needs-attention-banner[hidden] {
  display: none !important;
}
.needs-attention-banner__icon {
  font-size: 14px;
  line-height: 1;
}
.needs-attention-banner__text {
  letter-spacing: 0.02em;
}

.alert-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 360px;
  max-width: 90vw;
  background: var(--color-surface);
  box-shadow: -4px 0 24px rgba(0, 0, 0, 0.12);
  z-index: 1000;
  transform: translateX(100%);
  transition: transform 0.25s ease-out;
  display: flex;
  flex-direction: column;
}

.alert-panel.is-open {
  transform: translateX(0);
}

.alert-panel__backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.2);
  z-index: 999;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}

.alert-panel__backdrop.is-visible {
  opacity: 1;
  visibility: visible;
}

.alert-panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--color-border-light);
  flex-shrink: 0;
}

.alert-panel__title {
  font-size: 18px;
  font-weight: 600;
  color: var(--color-text);
  margin: 0;
}

.alert-panel__close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: none;
  background: transparent;
  border-radius: 6px;
  cursor: pointer;
  font-size: 16px;
  color: var(--color-text-secondary);
  transition: background 0.15s ease, color 0.15s ease;
}

.alert-panel__close:hover {
  background: var(--color-neutral-100);
  color: var(--color-text);
}

.alert-panel__body {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
}

.alert-panel__empty {
  font-size: 14px;
  color: var(--color-text-secondary);
  margin: 0;
}

.alert-panel__list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.alert-panel__body:has(.alert-panel__list .alert-panel__item) .alert-panel__empty {
  display: none;
}

.alert-panel__item {
  padding: 0;
  margin-bottom: 16px;
  background: var(--color-surface);
  border-radius: 12px;
  font-size: 13px;
  border: 1px solid var(--color-border-light, #e5e7eb);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
  overflow: hidden;
  transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.alert-panel__item:hover {
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08), 0 2px 4px rgba(0, 0, 0, 0.06);
}

.alert-panel__item--clickable {
  cursor: pointer;
}

.alert-panel__item--clickable:hover {
  box-shadow: 0 6px 20px rgba(245, 158, 11, 0.15), 0 2px 6px rgba(0, 0, 0, 0.08);
}

/* Card title: "Issues Identified" — highlighted */
.alert-panel__item-title {
  padding: 12px 16px 10px;
  font-size: 14px;
  font-weight: 700;
  color: #fff;
  letter-spacing: 0.02em;
  /* text-transform: uppercase; */
  background: linear-gradient(135deg, #ea580c 0%, #c2410c 50%, #9a3412 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

/* Meta block: Subject, Guardian Score, Risk, To, Content */
.alert-panel__item-meta {
  padding: 12px 16px 10px;
  background: var(--color-neutral-50, #f9fafb);
  border-bottom: 1px solid var(--color-border-light, #e5e7eb);
}

.alert-panel__item-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 8px;
}

.alert-panel__item-row:last-child {
  margin-bottom: 0;
}

.alert-panel__item-label {
  flex-shrink: 0;
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-secondary, #6b7280);
  min-width: 90px;
}

.alert-panel__item-value {
  color: var(--color-text);
  word-break: break-word;
  line-height: 1.4;
}

.alert-panel__item-value--subject {
  font-weight: 600;
  color: var(--color-text);
  font-size: 13px;
}

/* Guardian Score badge */
.alert-panel__score-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 28px;
  font-size: 25px;
  font-weight: 700;
  background: rgba(245, 158, 11, 0.12);
  color: var(--alert-risk-color, #f59e0b);
  border: 1px solid rgba(245, 158, 11, 0.35);
}

.alert-panel__score-badge[data-risk="red"] {
  background: rgba(239, 68, 68, 0.12);
  color: #dc2626;
  border-color: rgba(239, 68, 68, 0.35);
}

.alert-panel__score-badge[data-risk="amber"] {
  background: rgba(245, 158, 11, 0.12);
  color: #d97706;
  border-color: rgba(245, 158, 11, 0.35);
}

.alert-panel__score-badge[data-risk="green"] {
  background: rgba(16, 185, 129, 0.12);
  color: #059669;
  border-color: rgba(16, 185, 129, 0.35);
}

/* Risk badge */
.alert-panel__risk-badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.alert-panel__risk-badge--red {
  /* background: linear-gradient(135deg, #fef2f2 0%, #fee2e2 100%); */
  color: #dc2626;
  /* border: 1px solid #fecaca; */
}

.alert-panel__risk-badge--amber {
  /* background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%); */
  color: #d97706;
  /* border: 1px solid #fde68a; */
}

.alert-panel__risk-badge--green {
  background: linear-gradient(135deg, #ecfdf5 0%, #d1fae5 100%);
  color: #059669;
  border: 1px solid #a7f3d0;
}

.alert-panel__item-value--preview {
  font-size: 12px;
  color: var(--color-text-secondary);
  line-height: 1.45;
  max-height: 3.6em;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

/* One row: column 1 = Guardian Score + Risk (stacked), column 2 = Issue cards */
.alert-panel__item-score-risk-issues {
  display: grid;
  grid-template-columns: 3fr 7fr;
  gap: 16px;
  align-items: start;
  padding: 12px 16px;
  background: var(--color-neutral-50, #f9fafb);
  border-bottom: 1px solid var(--color-border-light, #e5e7eb);
}

.alert-panel__item-col-left {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: flex-start;
  gap: 8px;
  min-width: 0;
}

.alert-panel__item-col-left .alert-panel__item-row {
  margin-bottom: 0;
  display: flex;
  justify-content: flex-start;
  align-items: center;
  width: 100%;
}

.alert-panel__item-col-left .alert-panel__item-value {
  display: flex;
  justify-content: flex-start;
  align-items: center;
}

.alert-panel__item-col-right {
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

/* Issue cards list (second column) */
.alert-panel__item-issues {
  padding: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 8px;
}

.alert-panel__issue-card {
  padding: 10px 12px;
  border-radius: 8px;
  border-left: 3px solid var(--issue-color, #6b7280);
  background: var(--issue-bg, rgba(0, 0, 0, 0.02));
  transition: box-shadow 0.15s ease;
}

.alert-panel__issue-card:hover {
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
}

.alert-panel__issue-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.alert-panel__issue-severity {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--issue-color);
}

.alert-panel__issue-type {
  font-size: 12px;
  font-weight: 600;
  color: var(--color-text);
}

.alert-panel__issue-desc {
  font-size: 12px;
  color: var(--color-text-secondary);
  line-height: 1.45;
}

.alert-panel__issue-location {
  font-size: 11px;
  color: var(--color-text-tertiary, #9ca3af);
  margin-top: 4px;
}

.alert-panel__item-time {
  font-size: 11px;
  color: var(--color-text-tertiary, #9ca3af);
  padding: 8px 16px 12px;
  border-top: 1px solid var(--color-border-light, #e5e7eb);
  background: var(--color-neutral-50, #f9fafb);
}

/* Guardian suggested safe version block (inside alert item) */
.alert-panel__safe-version {
  padding: 12px 16px;
  margin: 0;
  border-top: 1px solid var(--color-border-light, #e5e7eb);
  background: linear-gradient(180deg, #ecfdf5 0%, #d1fae5 100%);
  border-radius: 0 0 12px 12px;
}

.alert-panel__safe-version-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 700;
  color: #047857;
  margin-bottom: 8px;
}

.alert-panel__safe-version-textarea {
  width: 100%;
  min-height: 80px;
  padding: 10px 12px;
  font-size: 12px;
  line-height: 1.5;
  color: var(--color-text, #374151);
  background: #fff;
  border: 1px solid #a7f3d0;
  border-radius: 8px;
  resize: vertical;
  box-sizing: border-box;
  display: block;
  margin-bottom: 10px;
}

.alert-panel__safe-version-textarea:focus {
  outline: none;
  border-color: #10b981;
  box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.2);
}

.alert-panel__safe-version-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.alert-panel__btn {
  padding: 8px 14px;
  font-size: 12px;
  font-weight: 600;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s ease, box-shadow 0.15s ease;
}

.alert-panel__btn--safe {
  background: linear-gradient(135deg, #10b981, #059669);
  color: #fff;
  box-shadow: 0 2px 6px rgba(16, 185, 129, 0.3);
}

.alert-panel__btn--safe:hover {
  background: linear-gradient(135deg, #059669, #047857);
  box-shadow: 0 2px 10px rgba(16, 185, 129, 0.4);
}

.alert-panel__btn--risk {
  background: #fff;
  color: #b45309;
  border: 1px solid #f59e0b;
}

.alert-panel__btn--risk:hover {
  background: #fffbeb;
  border-color: #d97706;
}
