/* File: src/css/components/notifications.css */
/* Toast system — Harbor (Phase 3). One toast at a time on phones, newest on
   top elsewhere; inverse surface; logical positioning (no right/left pin);
   sits above the tab bar and AccessCore button on phones; slides on the
   block axis so there is no RTL translate to get wrong. API unchanged:
   showNotification/showSuccess/showError/showWarning/showInfo
   (src/js/notifications.js). */

#notification-container {
  position: fixed;
  z-index: var(--af-z-toast, 600);
  inset-inline: 16px;
  inset-block-end: calc(var(--af-tabbar-h, 64px) + var(--af-safe-bottom, 0px) + var(--af-ac-size, 48px) + 24px);
  display: flex;
  flex-direction: column-reverse;
  align-items: stretch;
  gap: 8px;
  pointer-events: none;
}
/* Task pages (no tab bar) and wider screens: no tab bar to clear. */
html[data-shell-kind="task"] #notification-container,
html[data-shell="focus"] #notification-container,
body:not([data-authenticated="true"]) #notification-container {
  inset-block-end: calc(var(--af-safe-bottom, 0px) + 16px + var(--af-ac-size, 48px) + 16px);
}
/* Phones with a sheet open (dialog.js scroll lock, a row-menu action sheet,
   the bell sheet): the sheet's actions (menu items, Save bar) are at the
   bottom, so a toast there would cover and swallow taps. Show it near the top,
   below the sheet header (title + Close, 56–64px), so Close stays tappable. */
@media (max-width: 767.98px) {
  html:is(.af-scroll-lock, .af-bell-open, :has(.af-rowmenu--sheet)) #notification-container {
    inset-block-start: calc(env(safe-area-inset-top, 0px) + 72px);
    inset-block-end: auto;
    flex-direction: column;
  }
}
@media (min-width: 768px) {
  #notification-container,
  html[data-shell-kind="task"] #notification-container,
  body:not([data-authenticated="true"]) #notification-container {
    inset-inline: auto 24px;
    inset-inline-end: 24px;
    inset-inline-start: auto;
    inset-block-end: 24px;
    width: min(420px, calc(100vw - 48px));
  }
}

.notification {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  min-height: 52px;
  padding: 14px 8px 14px 16px;
  padding-inline: 16px 8px;
  border-radius: var(--af-r-md, 14px);
  background: var(--af-inverse-bg, #16201E);
  color: var(--af-inverse-ink, #F3F5F4);
  box-shadow: var(--af-shadow-3);
  font-family: var(--af-font-body);
  font-size: var(--af-fs-sm, .875rem);
  line-height: 1.45;
  pointer-events: auto;
  overflow: hidden;
  animation: afToastIn var(--af-dur, 200ms) var(--af-ease) both;
}
/* finance-common.css (wallets, cards, recurring, …) still styles a bare
   .notification as a fixed, centred, 300px-min top banner with opacity 0.
   Inside the shared container that legacy box must not apply: it pinned
   toasts over sheet titles on phones and pushed them off-screen at 390. */
#notification-container > .notification {
  position: relative;
  inset: auto;
  min-width: 0;
  max-width: 100%;
  opacity: 1;
  z-index: auto;
  transform: none;
  border-inline-start: 0;
  border-right: 0;
}

.notification.removing {
  animation: afToastOut 140ms var(--af-ease-exit, ease-in) forwards;
}
@keyframes afToastIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@keyframes afToastOut { to { opacity: 0; transform: translateY(8px); } }

.notification-icon {
  flex: none;
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  margin-block-start: 0;
  border-radius: 50%;
  font-size: 13px;
  font-weight: 700;
  color: var(--af-inverse-bg, #16201E);
  background: var(--af-inverse-accent, #86D4CB);
}
.notification.error .notification-icon { background: var(--af-red-300, #FF8A7A); }
.notification.warning .notification-icon { background: var(--af-amber-300, #E9B44C); }
.notification.info .notification-icon { background: var(--af-blue-300, #8DB2F0); }
.notification.success .notification-icon { background: var(--af-green-300, #5CCB82); }

.notification-content { flex: 1; min-width: 0; padding-block-start: 1px; }
.notification-title { font-weight: 600; font-size: var(--af-fs-sm, .875rem); }
.notification-message { opacity: .9; overflow-wrap: anywhere; }

.notification-report-btn {
  margin-block-start: 8px;
  min-height: 36px;
  padding-inline: 12px;
  border-radius: var(--af-r-pill, 999px);
  border: 1px solid currentColor;
  background: transparent;
  color: var(--af-inverse-accent, #86D4CB);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.notification-report-btn:disabled { opacity: .7; cursor: default; }

.notification-close {
  flex: none;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  margin-block: -10px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: inherit;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  opacity: .8;
}
.notification-close:hover { opacity: 1; background: rgba(255, 255, 255, .08); }
.notification-close:focus-visible { outline: 2px solid var(--af-inverse-accent, #86D4CB); outline-offset: -4px; }

.notification-progress {
  position: absolute;
  inset-inline-start: 0;
  inset-block-end: 0;
  height: 3px;
  width: 100%;
  background: var(--af-inverse-accent, #86D4CB);
  opacity: .5;
  transform-origin: inline-start;
  animation: afToastProgress linear forwards;
}
[dir="rtl"] .notification-progress { transform-origin: right; }
[dir="ltr"] .notification-progress { transform-origin: left; }
.notification:hover .notification-progress,
.notification:focus-within .notification-progress { animation-play-state: paused; }
@keyframes afToastProgress { from { transform: scaleX(1); } to { transform: scaleX(0); } }

@media (prefers-reduced-motion: reduce) {
  .notification, .notification.removing { animation-duration: 1ms; }
  .notification-progress { display: none; }
}

/* ================================================
   Confirmation Modal Styles
   ================================================ */

.confirm-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000000;
  padding: 20px;
  animation: confirmOverlayFadeIn 0.2s ease-out forwards;
}

.confirm-modal-overlay.removing {
  animation: confirmOverlayFadeOut 0.2s ease-out forwards;
}

@keyframes confirmOverlayFadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes confirmOverlayFadeOut {
  from {
    opacity: 1;
  }
  to {
    opacity: 0;
  }
}

.confirm-modal {
  background: white;
  border-radius: 12px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
  max-width: 400px;
  width: 100%;
  overflow: hidden;
  animation: confirmModalSlideIn 0.2s ease-out forwards;
}

.confirm-modal-overlay.removing .confirm-modal {
  animation: confirmModalSlideOut 0.2s ease-out forwards;
}

@keyframes confirmModalSlideIn {
  from {
    transform: translateY(-20px) scale(0.95);
    opacity: 0;
  }
  to {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
}

@keyframes confirmModalSlideOut {
  from {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
  to {
    transform: translateY(-20px) scale(0.95);
    opacity: 0;
  }
}

.confirm-modal-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 24px 16px;
  border-bottom: 1px solid #e5e7eb;
}

.confirm-modal-icon {
  font-size: 24px;
  flex-shrink: 0;
}

.confirm-modal-title {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  color: #1f2937;
}

.confirm-modal-body {
  padding: 20px 24px;
}

.confirm-modal-message {
  margin: 0;
  font-size: 14px;
  line-height: 1.6;
  color: #4b5563;
  white-space: pre-wrap;
}

.confirm-modal-footer {
  display: flex;
  gap: 12px;
  padding: 16px 24px 20px;
  background: #f9fafb;
  justify-content: flex-end;
}

.confirm-modal-btn {
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  border: none;
  min-width: 80px;
}

.confirm-modal-btn.cancel {
  background: #e5e7eb;
  color: #4b5563;
}

.confirm-modal-btn.cancel:hover {
  background: #d1d5db;
}

.confirm-modal-btn.confirm {
  background: #3b82f6;
  color: white;
}

.confirm-modal-btn.confirm:hover {
  background: #2563eb;
}

.confirm-modal-btn.confirm:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.3);
}

.confirm-modal-btn.cancel:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(107, 114, 128, 0.3);
}

/* Warning type */
.confirm-modal.warning .confirm-modal-btn.confirm {
  background: #f59e0b;
}

.confirm-modal.warning .confirm-modal-btn.confirm:hover {
  background: #d97706;
}

.confirm-modal.warning .confirm-modal-btn.confirm:focus {
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.3);
}

/* Danger type */
.confirm-modal.danger .confirm-modal-btn.confirm {
  background: #ef4444;
}

.confirm-modal.danger .confirm-modal-btn.confirm:hover {
  background: #dc2626;
}

.confirm-modal.danger .confirm-modal-btn.confirm:focus {
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.3);
}

/* Alert modal specific (single button) */
.alert-modal .confirm-modal-footer {
  justify-content: center;
}

/* Alert type colors */
.alert-modal.error .confirm-modal-header {
  background: #fef2f2;
}

.alert-modal.error .confirm-modal-icon {
  color: #ef4444;
}

.alert-modal.error .confirm-modal-btn.confirm {
  background: #ef4444;
}

.alert-modal.error .confirm-modal-btn.confirm:hover {
  background: #dc2626;
}

.alert-modal.warning .confirm-modal-header {
  background: #fffbeb;
}

.alert-modal.warning .confirm-modal-icon {
  color: #f59e0b;
}

.alert-modal.success .confirm-modal-header {
  background: #f0fdf4;
}

.alert-modal.success .confirm-modal-icon {
  color: #10b981;
}

.alert-modal.success .confirm-modal-btn.confirm {
  background: #10b981;
}

.alert-modal.success .confirm-modal-btn.confirm:hover {
  background: #059669;
}

.alert-modal.info .confirm-modal-header {
  background: #eff6ff;
}

.alert-modal.info .confirm-modal-icon {
  color: #3b82f6;
}

/* Mobile responsive */
@media (max-width: 480px) {
  .confirm-modal {
    max-width: none;
    margin: 10px;
  }

  .confirm-modal-header {
    padding: 16px 20px 12px;
  }

  .confirm-modal-body {
    padding: 16px 20px;
  }

  .confirm-modal-footer {
    padding: 12px 20px 16px;
    flex-direction: column-reverse;
  }

  .confirm-modal-btn {
    width: 100%;
  }
}

/* RTL Support */
[dir="rtl"] .confirm-modal-footer {
  flex-direction: row-reverse;
}

@media (max-width: 480px) {
  [dir="rtl"] .confirm-modal-footer {
    flex-direction: column-reverse;
  }
}
