.xr-restore-overlay {
  position: fixed;
  inset: 0;
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(15, 23, 42, 0.62);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  padding: 20px;
  font-family: 'Open Sans', 'Cairo', 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  animation: xr-fade-in 220ms ease-out;
}

@keyframes xr-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes xr-card-rise {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

.xr-restore-card {
  width: min(560px, 100%);
  background: #ffffff;
  border-radius: 18px;
  padding: 26px 28px;
  box-shadow: 0 28px 60px rgba(15, 23, 42, 0.28), 0 4px 12px rgba(15, 23, 42, 0.12);
  color: #1f2937;
  animation: xr-card-rise 280ms cubic-bezier(.2, .9, .35, 1.2);
  position: relative;
}

.xr-restore-card-head {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 20px;
}

[dir="rtl"] .xr-restore-card-head {
  flex-direction: row-reverse;
}

.xr-restore-icon {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #f59e0b 0%, #f97316 100%);
  color: #fff;
  font-size: 20px;
  flex-shrink: 0;
  box-shadow: 0 6px 14px rgba(245, 158, 11, 0.32);
}

.xr-restore-card[data-status="completed"] .xr-restore-icon {
  background: linear-gradient(135deg, #16a34a 0%, #22c55e 100%);
  box-shadow: 0 6px 14px rgba(22, 163, 74, 0.32);
}

.xr-restore-card[data-status="failed"] .xr-restore-icon {
  background: linear-gradient(135deg, #dc2626 0%, #ef4444 100%);
  box-shadow: 0 6px 14px rgba(220, 38, 38, 0.32);
}

.xr-restore-titles {
  flex: 1;
  min-width: 0;
}

.xr-restore-titles h3 {
  margin: 0 0 4px;
  font-size: 17px;
  font-weight: 700;
  color: #0f172a;
  letter-spacing: -0.01em;
}

.xr-restore-stage {
  font-size: 13px;
  color: #64748b;
  font-weight: 500;
  line-height: 1.4;
}

.xr-restore-percent {
  min-width: 78px;
  text-align: center;
  border-radius: 999px;
  background: linear-gradient(135deg, #fff7ed 0%, #ffedd5 100%);
  color: #c2410c;
  font-size: 22px;
  font-weight: 800;
  line-height: 1;
  padding: 10px 14px;
  flex-shrink: 0;
  border: 1px solid rgba(249, 115, 22, 0.18);
  font-variant-numeric: tabular-nums;
}

.xr-restore-percent span {
  font-size: 13px;
  font-weight: 700;
  margin: 0 2px;
  opacity: 0.75;
}

.xr-restore-card[data-status="completed"] .xr-restore-percent {
  background: linear-gradient(135deg, #f0fdf4 0%, #dcfce7 100%);
  color: #15803d;
  border-color: rgba(34, 197, 94, 0.22);
}

.xr-restore-card[data-status="failed"] .xr-restore-percent {
  background: linear-gradient(135deg, #fef2f2 0%, #fee2e2 100%);
  color: #b91c1c;
  border-color: rgba(239, 68, 68, 0.22);
}

.xr-restore-bar {
  position: relative;
  height: 12px;
  border-radius: 999px;
  background: #eef2f7;
  overflow: hidden;
  margin-bottom: 18px;
  box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.08);
}

.xr-restore-bar-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #f59e0b 0%, #f97316 50%, #fb923c 100%);
  transition: width 0.6s cubic-bezier(.2, .8, .3, 1);
  position: relative;
  overflow: hidden;
  min-width: 0;
}

[dir="rtl"] .xr-restore-bar-fill {
  background: linear-gradient(270deg, #f59e0b 0%, #f97316 50%, #fb923c 100%);
}

.xr-restore-bar-shine {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 80px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.55), transparent);
  animation: xr-shine 1.6s linear infinite;
}

@keyframes xr-shine {
  from { left: -80px; }
  to { left: 100%; }
}

.xr-restore-card[data-status="completed"] .xr-restore-bar-fill {
  background: linear-gradient(90deg, #16a34a 0%, #22c55e 100%);
}

.xr-restore-card[data-status="completed"] .xr-restore-bar-shine,
.xr-restore-card[data-status="failed"] .xr-restore-bar-shine,
.xr-restore-card[data-status="not_running"] .xr-restore-bar-shine {
  display: none;
}

.xr-restore-card[data-status="failed"] .xr-restore-bar-fill {
  background: linear-gradient(90deg, #dc2626 0%, #ef4444 100%);
}

.xr-restore-file {
  font-size: 12.5px;
  color: #475569;
  margin-bottom: 16px;
  word-break: break-all;
  background: #f8fafc;
  border-radius: 8px;
  padding: 9px 12px;
  border: 1px solid #e2e8f0;
}

.xr-restore-file-label {
  font-weight: 700;
  color: #0f172a;
  margin-inline-end: 6px;
}

.xr-restore-file-name {
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', monospace;
  color: #334155;
}

.xr-restore-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px 12px;
  margin-bottom: 18px;
}

.xr-restore-stat {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.xr-restore-stat-eta {
  grid-column: 1 / -1;
  background: linear-gradient(135deg, #fff7ed 0%, #fef3c7 100%);
  border-color: rgba(249, 115, 22, 0.22);
}

.xr-restore-card[data-status="completed"] .xr-restore-stat-eta {
  background: linear-gradient(135deg, #f0fdf4 0%, #dcfce7 100%);
  border-color: rgba(34, 197, 94, 0.22);
}

.xr-restore-stat-label {
  font-size: 11px;
  color: #64748b;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.xr-restore-stat-value {
  font-size: 14px;
  color: #0f172a;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

.xr-restore-stat-eta .xr-restore-stat-value {
  font-size: 16px;
  color: #c2410c;
}

.xr-restore-card[data-status="completed"] .xr-restore-stat-eta .xr-restore-stat-value {
  color: #15803d;
}

.xr-restore-warning {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #fff7ed;
  border: 1px solid #fed7aa;
  color: #9a3412;
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
}

[dir="rtl"] .xr-restore-warning {
  flex-direction: row-reverse;
  text-align: right;
}

.xr-restore-warning i {
  font-size: 15px;
  color: #ea580c;
  flex-shrink: 0;
}

.xr-restore-success-info {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  color: #166534;
  padding: 12px 14px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
}

[dir="rtl"] .xr-restore-success-info {
  flex-direction: row-reverse;
  text-align: right;
}

.xr-restore-success-info i {
  font-size: 18px;
  color: #16a34a;
  flex-shrink: 0;
}

.xr-restore-failure {
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #991b1b;
  padding: 14px;
  border-radius: 10px;
  font-size: 13px;
}

.xr-restore-failure-message {
  font-weight: 600;
  word-break: break-word;
}

.xr-restore-btn {
  border: 0;
  border-radius: 8px;
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  transition: transform 100ms ease, box-shadow 200ms ease;
}

.xr-restore-btn-primary {
  background: linear-gradient(135deg, #dc2626 0%, #ef4444 100%);
  color: #ffffff;
  box-shadow: 0 4px 10px rgba(220, 38, 38, 0.28);
}

.xr-restore-btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 14px rgba(220, 38, 38, 0.36);
}

@media (max-width: 520px) {
  .xr-restore-card {
    padding: 20px;
    border-radius: 14px;
  }

  .xr-restore-grid {
    grid-template-columns: 1fr;
  }

  .xr-restore-titles h3 {
    font-size: 15px;
  }

  .xr-restore-percent {
    font-size: 18px;
    min-width: 64px;
    padding: 8px 10px;
  }
}

/* Hide the legacy Angular restore monitor whenever our overlay is present. */
.xr-restore-overlay ~ * app-database-restore-monitor,
body:has(.xr-restore-overlay) app-database-restore-monitor {
  visibility: hidden !important;
}
