/* ═══════════════════════════════════════════════════════
   MRE Core — Design Enhancement Layer
   Overlays on top of existing inline styles
   ═══════════════════════════════════════════════════════ */

/* ─── Subtle security-grade background ─── */
body {
  background:
    radial-gradient(ellipse at 20% 50%, rgba(10, 37, 64, 0.018) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 20%, rgba(59, 130, 246, 0.012) 0%, transparent 50%),
    radial-gradient(ellipse at 50% 100%, rgba(10, 37, 64, 0.01) 0%, transparent 40%),
    #ffffff;
  background-attachment: fixed;
}

body::after {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: 0.018;
  background-image: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M30 6l6.93 4v8L30 22l-6.93-4v-8L30 6z' fill='none' stroke='%230a2540' stroke-width='0.5'/%3E%3C/svg%3E");
  background-size: 60px 60px;
}

/* ─── Page entrance animations ─── */
@keyframes mre-fadeInUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes mre-fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes mre-slideDown {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes mre-scaleIn {
  from { opacity: 0; transform: scale(0.95); }
  to   { opacity: 1; transform: scale(1); }
}

@keyframes mre-shimmer {
  0%   { background-position: -200% center; }
  100% { background-position: 200% center; }
}

@keyframes mre-borderPulse {
  0%, 100% { border-color: rgba(10, 37, 64, 0.08); }
  50%      { border-color: rgba(10, 37, 64, 0.16); }
}

@keyframes mre-float {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-4px); }
}

/* ─── Staggered entrance for containers ─── */
.container,
.portal-main,
.home-main,
.main-content,
.login-wrap {
  animation: mre-fadeInUp 0.5s cubic-bezier(0.22, 1, 0.36, 1) both;
}

/* ─── Enhanced header ─── */
.header {
  background: rgba(255, 255, 255, 0.92) !important;
  backdrop-filter: blur(12px) saturate(1.4);
  -webkit-backdrop-filter: blur(12px) saturate(1.4);
  border-bottom: 1px solid rgba(10, 37, 64, 0.06) !important;
  box-shadow: 0 1px 3px rgba(10, 37, 64, 0.04), 0 4px 12px rgba(10, 37, 64, 0.02);
  transition: box-shadow 0.3s ease;
}

/* ─── Enhanced cards ─── */
.card,
.portal-card,
.login-card,
.register-card,
.home-card {
  transition: box-shadow 0.3s ease, transform 0.3s ease, border-color 0.3s ease;
  animation: mre-scaleIn 0.4s cubic-bezier(0.22, 1, 0.36, 1) both;
  animation-delay: 0.1s;
}

/* ─── Enhanced buttons ─── */
.btn-primary {
  background: linear-gradient(145deg, #0a2540 0%, #132f4c 100%) !important;
  box-shadow: 0 2px 8px rgba(10, 37, 64, 0.3), 0 0 0 0 rgba(10, 37, 64, 0) !important;
  transition: all 0.25s cubic-bezier(0.22, 1, 0.36, 1) !important;
  position: relative;
  overflow: hidden;
}

.btn-primary::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(145deg, rgba(255,255,255,0.08) 0%, transparent 60%);
  opacity: 0;
  transition: opacity 0.25s;
}

.btn-primary:hover {
  background: linear-gradient(145deg, #132f4c 0%, #1a3a5c 100%) !important;
  box-shadow: 0 4px 16px rgba(10, 37, 64, 0.35), 0 0 0 4px rgba(10, 37, 64, 0.06) !important;
  transform: translateY(-2px) !important;
}

.btn-primary:hover::after {
  opacity: 1;
}

.btn-primary:active {
  transform: translateY(0) !important;
  box-shadow: 0 1px 4px rgba(10, 37, 64, 0.3) !important;
}

.btn-success {
  transition: all 0.25s cubic-bezier(0.22, 1, 0.36, 1) !important;
  position: relative;
  overflow: hidden;
}

.btn-success::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(145deg, rgba(255,255,255,0.1) 0%, transparent 60%);
  opacity: 0;
  transition: opacity 0.25s;
}

.btn-success:hover::after { opacity: 1; }

.btn-success:hover {
  transform: translateY(-2px) !important;
  box-shadow: 0 4px 16px rgba(5, 150, 105, 0.35), 0 0 0 4px rgba(5, 150, 105, 0.08) !important;
}

.btn-danger {
  transition: all 0.25s cubic-bezier(0.22, 1, 0.36, 1) !important;
}

.btn-danger:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(220, 38, 38, 0.12);
}

/* ─── Enhanced form inputs ─── */
.field input:focus,
.form-group input:focus,
.form-group textarea:focus {
  border-color: #1a3a5c !important;
  box-shadow: 0 0 0 4px rgba(10, 37, 64, 0.08), 0 0 16px rgba(10, 37, 64, 0.04) !important;
}

.field input,
.form-group input,
.form-group textarea {
  transition: all 0.25s cubic-bezier(0.22, 1, 0.36, 1) !important;
}

/* OTP input special glow */
.otp-input:focus {
  box-shadow: 0 0 0 4px rgba(10, 37, 64, 0.08), 0 0 24px rgba(10, 37, 64, 0.06) !important;
}

/* ─── Enhanced status badges ─── */
.status,
.status-badge {
  transition: all 0.2s ease;
  position: relative;
}

.status::before {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  margin-right: 2px;
}

.status-pending::before { background: #7b8ba3; }
.status-notified::before { background: #d97706; }
.status-delivered::before { background: #059669; }
.status-refused::before { background: #dc2626; }
.status-negligence::before { background: #ea580c; }
.status-notification_failed::before { background: #991b1b; }

/* ─── Enhanced timeline ─── */
.timeline li {
  animation: mre-fadeInUp 0.4s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.timeline li:nth-child(1) { animation-delay: 0.1s; }
.timeline li:nth-child(2) { animation-delay: 0.2s; }
.timeline li:nth-child(3) { animation-delay: 0.3s; }
.timeline li:nth-child(4) { animation-delay: 0.4s; }
.timeline li:nth-child(5) { animation-delay: 0.5s; }
.timeline li:nth-child(6) { animation-delay: 0.6s; }

.timeline::before {
  background: linear-gradient(to bottom, #0a2540, rgba(10, 37, 64, 0.15)) !important;
}

.timeline li::before {
  transition: all 0.3s ease !important;
  box-shadow: 0 0 0 2px rgba(10, 37, 64, 0.12), 0 0 8px rgba(10, 37, 64, 0.06) !important;
}

/* ─── Enhanced table rows ─── */
tr {
  transition: background 0.15s ease;
}

tr:hover td {
  background: rgba(10, 37, 64, 0.025) !important;
}

tr[style*="cursor: pointer"]:hover td {
  background: rgba(10, 37, 64, 0.035) !important;
}

/* ─── Enhanced security badge ─── */
.security-badge {
  animation: mre-fadeIn 0.6s ease both;
  animation-delay: 0.5s;
  padding: 10px 16px !important;
  background: rgba(10, 37, 64, 0.025);
  border-radius: 8px;
  border: 1px solid rgba(10, 37, 64, 0.05);
}

.security-badge svg {
  animation: mre-float 3s ease-in-out infinite;
}

/* ─── Enhanced info boxes ─── */
.info-box {
  transition: all 0.2s ease;
  position: relative;
}

.info-box::before {
  content: '';
  position: absolute;
  left: 0;
  top: 8px;
  bottom: 8px;
  width: 3px;
  border-radius: 3px;
  background: linear-gradient(to bottom, #0a2540, rgba(10, 37, 64, 0.3));
  opacity: 0;
  transition: opacity 0.2s ease;
}

.info-box:hover::before {
  opacity: 1;
}

.info-box:hover {
  border-color: rgba(10, 37, 64, 0.12);
}

/* ─── Enhanced portal card header icon ─── */
.portal-card-header .icon {
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  animation: mre-scaleIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.portal-card-header .icon:hover {
  transform: scale(1.05);
}

/* ─── Home page enhancements ─── */
.home-shield {
  animation: mre-scaleIn 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) both;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  position: relative;
}

.home-shield::after {
  content: '';
  position: absolute;
  inset: -6px;
  border-radius: 22px;
  border: 2px solid rgba(10, 37, 64, 0.08);
  animation: mre-borderPulse 3s ease-in-out infinite;
}

.home-title {
  animation: mre-fadeInUp 0.5s cubic-bezier(0.22, 1, 0.36, 1) both;
  animation-delay: 0.15s;
}

.home-subtitle {
  animation: mre-fadeInUp 0.5s cubic-bezier(0.22, 1, 0.36, 1) both;
  animation-delay: 0.25s;
}

.home-card {
  animation: mre-fadeInUp 0.5s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.home-card:nth-child(1) { animation-delay: 0.3s; }
.home-card:nth-child(2) { animation-delay: 0.4s; }
.home-card:nth-child(3) { animation-delay: 0.5s; }

.home-card:hover {
  box-shadow: 0 8px 32px rgba(10, 37, 64, 0.12), 0 2px 8px rgba(10, 37, 64, 0.06) !important;
  transform: translateY(-4px) !important;
}

.home-card-icon {
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.home-card:hover .home-card-icon {
  transform: scale(1.08);
  box-shadow: 0 4px 16px rgba(10, 37, 64, 0.2);
}

.home-footer {
  animation: mre-fadeIn 0.5s ease both;
  animation-delay: 0.6s;
}

/* ─── Login page card ─── */
.login-card {
  animation: mre-scaleIn 0.5s cubic-bezier(0.22, 1, 0.36, 1) both;
  animation-delay: 0.15s;
}

/* ─── Improved card header icons ─── */
.card-header .icon {
  transition: transform 0.3s ease;
  animation: mre-scaleIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

/* ─── Empty state enhancement ─── */
.empty-state {
  animation: mre-fadeIn 0.5s ease both;
  animation-delay: 0.2s;
}

.empty-state .empty-icon,
.empty-state svg {
  animation: mre-float 4s ease-in-out infinite;
}

/* ─── Alert entrance ─── */
.alert {
  animation: mre-slideDown 0.3s cubic-bezier(0.22, 1, 0.36, 1) both;
}

/* ─── Detail section stagger ─── */
.detail-section {
  animation: mre-fadeInUp 0.4s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.detail-section:nth-child(1) { animation-delay: 0.1s; }
.detail-section:nth-child(2) { animation-delay: 0.2s; }
.detail-section:nth-child(3) { animation-delay: 0.3s; }
.detail-section:nth-child(4) { animation-delay: 0.4s; }

/* ─── Hash/mono text enhancement ─── */
.event-hash,
.hash-mono,
[style*="JetBrains Mono"] {
  position: relative;
}

/* ─── Attachment item enhancement ─── */
.attachment-item {
  transition: all 0.2s ease !important;
}

.attachment-item:hover {
  transform: translateX(4px);
  border-color: rgba(10, 37, 64, 0.12) !important;
}

/* ─── Enhanced page header ─── */
.page-header {
  animation: mre-fadeInUp 0.4s cubic-bezier(0.22, 1, 0.36, 1) both;
}

/* ─── Recipient cards stagger (message detail) ─── */
.card + .card {
  animation-delay: 0.15s;
}

.card + .card + .card {
  animation-delay: 0.25s;
}

/* ─── Footer enhancement ─── */
footer,
.footer,
.portal-footer {
  animation: mre-fadeIn 0.5s ease both;
  animation-delay: 0.6s;
}

/* ─── Config overlay ─── */
.config-overlay.open,
#configOverlay[style*="flex"] {
  animation: mre-fadeIn 0.2s ease both;
}

.config-overlay.open > div,
#configOverlay[style*="flex"] > div {
  animation: mre-scaleIn 0.3s cubic-bezier(0.22, 1, 0.36, 1) both;
}

/* ─── Enhanced logo brand ─── */
.logo-brand-badge {
  transition: all 0.2s ease;
}

.logo-brand:hover .logo-brand-badge {
  box-shadow: 0 0 0 3px rgba(10, 37, 64, 0.06);
}

/* ─── Identity badge shimmer ─── */
.identity-badge {
  background: linear-gradient(110deg, #ecfdf5 30%, #d1fae5 50%, #ecfdf5 70%) !important;
  background-size: 200% 100%;
  animation: mre-shimmer 3s ease-in-out infinite;
}

/* ─── Auth method enhancement ─── */
.auth-method {
  transition: all 0.25s cubic-bezier(0.22, 1, 0.36, 1) !important;
}

.auth-method.active {
  box-shadow: 0 0 0 3px rgba(10, 37, 64, 0.06);
}

.auth-method:not(.disabled):hover {
  transform: translateY(-1px);
}

/* ─── Scroll-triggered reveal helper (JS-driven) ─── */
.mre-reveal {
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.5s cubic-bezier(0.22, 1, 0.36, 1), transform 0.5s cubic-bezier(0.22, 1, 0.36, 1);
}

.mre-reveal.visible {
  opacity: 1;
  transform: translateY(0);
}

/* ─── Print: remove background noise ─── */
@media print {
  body::after { display: none; }
  body { background: #fff !important; }
  .header { position: static; box-shadow: none; }
  * { animation: none !important; transition: none !important; }
}

/* ─── Reduce motion preference ─── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
