/* ============================================================================
   IESMAC ERP — Material skin over Phoenix Bootstrap 5.3
   SPRINT 3 · Surfaces: Modals, Offcanvas, Popovers, Tooltips, Toasts
   ----------------------------------------------------------------------------
   Depends on: material-skin.css (Sprint 1) — for tokens
   Load order:
     1. theme.min.css        (Phoenix core)
     2. user.min.css         (empty Phoenix slot)
     3. style.css            (existing tweaks)
     4. material-skin.css    (Sprint 1)
     5. material-skin-surfaces.css   ← THIS FILE

   ════════════════════════════════════════════════════════════════════════════
   TENANT THEMING NOTE — important for future
   ════════════════════════════════════════════════════════════════════════════
   This file uses ONLY --md-* CSS variables. No hex literals in component rules.
   That means a future tenant-branding system can override the brand by injecting
   a single <style> block in the layout head, like:

     <style th:if="${currentTenantBranding}" th:inline="text">
       :root {
         --md-primary-40: [[${tenantBranding.primaryHex}]];
         --md-primary-30: [[${@colorUtil.darken(tenantBranding.primaryHex, 15)}]];
         --md-primary-90: [[${@colorUtil.tonal(tenantBranding.primaryHex, 90)}]];
         --md-primary-95: [[${@colorUtil.tonal(tenantBranding.primaryHex, 95)}]];
       }
     </style>

   Every modal, popover, toast, etc. in this file will recolor automatically.
   For tonal stop calculation, consider Google's material-color-utilities
   (Java/MIT) as a Maven dependency.
   ════════════════════════════════════════════════════════════════════════════
   ============================================================================ */


/* ============================================================================
   1. MODAL — dialog with elevation-4, 16px radius, soft footer
   ============================================================================ */

/* Backdrop — teal-tinted, brand-aware */
html body .modal-backdrop {
  background-color: rgba(15, 55, 65, 0.35) !important;
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}

html body .modal-backdrop.show {
  opacity: 1 !important;
}

/* Dialog container */
html body .modal-content {
  border: 0 !important;
  border-radius: var(--md-radius-2xl) !important;
  box-shadow: var(--md-elev-4);
  background-color: var(--md-surface-card);
  overflow: hidden;
}

html body .modal-dialog {
  margin-top: 60px;
  margin-bottom: 60px;
}

html body .modal-dialog-centered {
  margin-top: 0;
  margin-bottom: 0;
}

/* Header — no harsh divider, just spacing */
html body .modal-header {
  border-bottom: 0 !important;
  padding: 18px 22px 4px !important;
  background-color: transparent;
  align-items: flex-start;
}

html body .modal-title {
  font-family: 'Inter', sans-serif;
  font-size: 16px;
  font-weight: 600;
  color: var(--md-neutral-10);
  letter-spacing: -0.2px;
  line-height: 1.35;
}

html body .modal-header .modal-title + p,
html body .modal-header .text-muted {
  font-size: 12.5px;
  color: var(--md-neutral-30);
  margin-top: 3px;
  margin-bottom: 0;
}

/* Close button — icon button, top-right */
html body .modal-header .btn-close,
html body .modal-header button.close {
  width: 28px;
  height: 28px;
  border-radius: var(--md-radius-lg);
  background: transparent;
  border: 0;
  padding: 0;
  opacity: 0.7;
  background-image: none;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

html body .modal-header .btn-close::before {
  content: '×';
  font-size: 22px;
  line-height: 1;
  color: var(--md-neutral-30);
  font-weight: 300;
}

html body .modal-header .btn-close:hover {
  background-color: var(--md-neutral-95);
  opacity: 1;
}

html body .modal-header .btn-close:focus-visible {
  outline: 2px solid var(--md-primary-40);
  outline-offset: 2px;
}

/* Body */
html body .modal-body {
  padding: 14px 22px 18px !important;
  font-size: 13px;
  color: var(--md-neutral-20);
  line-height: 1.55;
}

html body .modal-body p {
  font-size: 13px;
  color: var(--md-neutral-20);
}

/* Inline info card — context block inside modal body */
html body .modal-body .alert,
html body .modal-body .info-block {
  margin-bottom: 12px;
}

/* Footer — soft tinted background, right-aligned actions */
html body .modal-footer {
  background-color: var(--md-surface-card-soft) !important;
  border-top: 1px solid var(--md-surface-divider) !important;
  padding: 12px 22px !important;
  gap: 8px;
}

html body .modal-footer > * {
  margin: 0 !important;
}

/* Modal sizes — keep MUI proportions */
html body .modal-sm  .modal-dialog { max-width: 380px; }
html body .modal-lg  .modal-dialog { max-width: 720px; }
html body .modal-xl  .modal-dialog { max-width: 1080px; }

/* Modal fade animation — slightly tighter */
html body .modal.fade .modal-dialog {
  transition: transform 220ms cubic-bezier(0.2, 0, 0, 1), opacity 180ms ease;
  transform: translateY(20px) scale(0.98);
}
html body .modal.show .modal-dialog {
  transform: translateY(0) scale(1);
}

/* Scrollable body modal */
html body .modal-dialog-scrollable .modal-body {
  scrollbar-width: thin;
}


/* ============================================================================
   2. OFFCANVAS — slide-in drawer (left/right/top/bottom)
   ============================================================================ */

html body .offcanvas {
  background-color: var(--md-surface-card) !important;
  border: 0 !important;
  box-shadow: -8px 0 16px rgba(15, 55, 65, 0.10);
  font-family: 'Inter', sans-serif;
}

html body .offcanvas-start { box-shadow: 8px 0 16px rgba(15, 55, 65, 0.10); }
html body .offcanvas-end   { box-shadow: -8px 0 16px rgba(15, 55, 65, 0.10); }
html body .offcanvas-top   { box-shadow: 0 8px 16px rgba(15, 55, 65, 0.10); }
html body .offcanvas-bottom{ box-shadow: 0 -8px 16px rgba(15, 55, 65, 0.10); }

/* Header */
html body .offcanvas-header {
  padding: 16px 18px !important;
  border-bottom: 1px solid var(--md-surface-divider) !important;
  align-items: flex-start;
}

html body .offcanvas-title {
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  font-weight: 600;
  color: var(--md-neutral-10);
  letter-spacing: -0.1px;
  line-height: 1.35;
}

html body .offcanvas-header .text-muted {
  font-size: 11.5px;
  color: var(--md-neutral-40);
  margin-top: 1px;
}

html body .offcanvas-header .btn-close {
  width: 28px;
  height: 28px;
  border-radius: var(--md-radius-lg);
  background: transparent;
  border: 0;
  padding: 0;
  opacity: 0.7;
  background-image: none;
  position: relative;
  margin: -2px -2px 0 8px;
}

html body .offcanvas-header .btn-close::before {
  content: '×';
  font-size: 20px;
  line-height: 28px;
  color: var(--md-neutral-30);
  font-weight: 300;
  display: block;
  text-align: center;
}

html body .offcanvas-header .btn-close:hover {
  background-color: var(--md-neutral-95);
  opacity: 1;
}

/* Body */
html body .offcanvas-body {
  padding: 16px 18px !important;
  font-size: 12.5px;
  color: var(--md-neutral-20);
}

/* Section labels inside offcanvas */
html body .offcanvas-body .section-label,
html body .offcanvas-body h6 {
  font-size: 10.5px;
  font-weight: 500;
  color: var(--md-neutral-40);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin: 14px 0 8px;
}

html body .offcanvas-body h6:first-child {
  margin-top: 0;
}

/* Backdrop for offcanvas — same brand-tinted treatment */
html body .offcanvas-backdrop {
  background-color: rgba(15, 55, 65, 0.45) !important;
  backdrop-filter: blur(2px);
}

html body .offcanvas-backdrop.show {
  opacity: 1 !important;
}

/* Widths */
html body .offcanvas-end,
html body .offcanvas-start {
  width: 320px;
}

@media (max-width: 576px) {
  html body .offcanvas-end,
  html body .offcanvas-start {
    width: 88vw;
  }
}


/* ============================================================================
   3. POPOVER — rich, with header + body + optional footer link
   ============================================================================ */

html body .popover {
  background-color: var(--md-surface-card) !important;
  border: 0 !important;
  border-radius: var(--md-radius-xl) !important;
  box-shadow: var(--md-elev-3);
  font-family: 'Inter', sans-serif;
  max-width: 300px;
  --bs-popover-bg: var(--md-surface-card);
  --bs-popover-border-color: transparent;
  --bs-popover-border-radius: var(--md-radius-xl);
  --bs-popover-inner-border-radius: var(--md-radius-xl);
}

html body .popover-header {
  background-color: var(--md-surface-tinted) !important;
  border-bottom: 1px solid var(--md-surface-divider) !important;
  color: var(--md-neutral-10) !important;
  font-size: 12.5px;
  font-weight: 600;
  padding: 10px 14px !important;
  border-radius: var(--md-radius-xl) var(--md-radius-xl) 0 0 !important;
}

html body .popover-header::before {
  border-bottom-color: var(--md-surface-divider) !important;
}

html body .popover-body {
  padding: 11px 14px 13px !important;
  font-size: 12px;
  color: var(--md-neutral-20);
  line-height: 1.55;
}

html body .popover-body strong,
html body .popover-body b {
  color: var(--md-neutral-10);
  font-weight: 500;
}

html body .popover-body a {
  color: var(--md-primary-40);
  font-weight: 500;
  font-size: 11.5px;
}

/* Arrow */
html body .popover .popover-arrow::before,
html body .popover .popover-arrow::after {
  border-width: 0;
}

html body .popover .popover-arrow {
  display: block;
  position: absolute;
  width: 12px;
  height: 12px;
}

html body .popover.bs-popover-top .popover-arrow,
html body .popover.bs-popover-auto[data-popper-placement^="top"] .popover-arrow {
  bottom: -6px;
}
html body .popover.bs-popover-top .popover-arrow::before,
html body .popover.bs-popover-auto[data-popper-placement^="top"] .popover-arrow::before {
  content: '';
  position: absolute;
  width: 12px;
  height: 12px;
  background: var(--md-surface-card);
  transform: rotate(45deg);
  top: -6px;
  left: 0;
  box-shadow: 2px 2px 4px rgba(15, 55, 65, 0.06);
}

html body .popover.bs-popover-bottom .popover-arrow,
html body .popover.bs-popover-auto[data-popper-placement^="bottom"] .popover-arrow {
  top: -6px;
}
html body .popover.bs-popover-bottom .popover-arrow::before,
html body .popover.bs-popover-auto[data-popper-placement^="bottom"] .popover-arrow::before {
  content: '';
  position: absolute;
  width: 12px;
  height: 12px;
  background: var(--md-surface-tinted);
  transform: rotate(45deg);
  top: 0;
  left: 0;
  box-shadow: -2px -2px 4px rgba(15, 55, 65, 0.04);
}

html body .popover.bs-popover-start .popover-arrow,
html body .popover.bs-popover-auto[data-popper-placement^="left"] .popover-arrow {
  right: -6px;
}
html body .popover.bs-popover-start .popover-arrow::before,
html body .popover.bs-popover-auto[data-popper-placement^="left"] .popover-arrow::before {
  content: '';
  position: absolute;
  width: 12px;
  height: 12px;
  background: var(--md-surface-card);
  transform: rotate(45deg);
  top: 0;
  left: -6px;
  box-shadow: 2px -2px 4px rgba(15, 55, 65, 0.04);
}

html body .popover.bs-popover-end .popover-arrow,
html body .popover.bs-popover-auto[data-popper-placement^="right"] .popover-arrow {
  left: -6px;
}
html body .popover.bs-popover-end .popover-arrow::before,
html body .popover.bs-popover-auto[data-popper-placement^="right"] .popover-arrow::before {
  content: '';
  position: absolute;
  width: 12px;
  height: 12px;
  background: var(--md-surface-card);
  transform: rotate(45deg);
  top: 0;
  left: 0;
  box-shadow: -2px 2px 4px rgba(15, 55, 65, 0.04);
}


/* ============================================================================
   4. TOOLTIP — plain dark MUI pill
   ============================================================================ */

html body .tooltip {
  font-family: 'Inter', sans-serif;
  --bs-tooltip-bg: var(--md-neutral-10);
  --bs-tooltip-color: #FFFFFF;
  --bs-tooltip-opacity: 1;
  --bs-tooltip-border-radius: var(--md-radius-md);
}

html body .tooltip .tooltip-inner {
  background-color: var(--md-neutral-10) !important;
  color: #FFFFFF !important;
  font-size: 11px !important;
  font-weight: 500 !important;
  padding: 4px 9px !important;
  border-radius: var(--md-radius-md) !important;
  max-width: 240px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.18);
  text-align: center;
  letter-spacing: 0.01em;
}

html body .tooltip .tooltip-arrow::before {
  border-top-color: var(--md-neutral-10) !important;
  border-bottom-color: var(--md-neutral-10) !important;
  border-left-color: var(--md-neutral-10) !important;
  border-right-color: var(--md-neutral-10) !important;
}

/* Tooltip fade animation */
html body .tooltip.fade {
  transition: opacity 120ms ease;
}


/* ============================================================================
   5. TOAST / SNACKBAR — MUI dark style, bottom-right
   ============================================================================ */

/* Container — position bottom-right by default */
html body .toast-container {
  position: fixed !important;
  bottom: 24px !important;
  right: 24px !important;
  top: auto !important;
  left: auto !important;
  z-index: 1090;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

html body .toast-container > * {
  pointer-events: auto;
}

/* Phoenix's container positions — neutralize and let bottom-right win */
html body .toast-container.position-fixed.top-0,
html body .toast-container.position-fixed.start-0 {
  top: auto !important;
  left: auto !important;
  bottom: 24px !important;
  right: 24px !important;
}

/* Toast body — dark MUI snackbar */
html body .toast {
  background-color: var(--md-neutral-10) !important;
  color: #FFFFFF !important;
  border: 0 !important;
  border-radius: var(--md-radius-lg) !important;
  box-shadow: var(--md-elev-3), 0 4px 8px rgba(15, 55, 65, 0.18);
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  font-weight: 400;
  min-width: 280px;
  max-width: 480px;
  padding: 0;
  --bs-toast-bg: var(--md-neutral-10);
  --bs-toast-color: #FFFFFF;
  --bs-toast-border-color: transparent;
  --bs-toast-header-bg: transparent;
  --bs-toast-header-color: #FFFFFF;
}

html body .toast.show {
  display: flex;
  align-items: stretch;
}

html body .toast-header {
  background-color: transparent !important;
  border-bottom: 0 !important;
  color: #FFFFFF !important;
  padding: 10px 12px 4px 14px !important;
  font-size: 13px;
}

html body .toast-header .me-auto,
html body .toast-header strong {
  color: #FFFFFF !important;
  font-weight: 500;
}

html body .toast-header small {
  color: rgba(255, 255, 255, 0.6) !important;
  font-size: 11px;
}

html body .toast-header .btn-close {
  background: transparent;
  border: 0;
  padding: 0;
  width: 18px;
  height: 18px;
  opacity: 0.7;
  background-image: none;
  position: relative;
  margin-left: 8px;
}

html body .toast-header .btn-close::before {
  content: '×';
  font-size: 18px;
  line-height: 1;
  color: #FFFFFF;
  font-weight: 300;
}

html body .toast-header .btn-close:hover {
  opacity: 1;
}

html body .toast-body {
  padding: 10px 14px !important;
  color: #FFFFFF !important;
  font-size: 13px;
  line-height: 1.5;
}

/* Semantic toast variants — colored leading bar + icon */
html body .toast.toast-success,
html body .toast.bg-success {
  background-color: var(--md-neutral-10) !important;
  border-left: 3px solid var(--md-success-400) !important;
}

html body .toast.toast-warning,
html body .toast.bg-warning {
  background-color: var(--md-neutral-10) !important;
  border-left: 3px solid var(--md-warning-400) !important;
}

html body .toast.toast-danger,
html body .toast.bg-danger {
  background-color: var(--md-neutral-10) !important;
  border-left: 3px solid var(--md-error-400) !important;
}

html body .toast.toast-info,
html body .toast.bg-info {
  background-color: var(--md-neutral-10) !important;
  border-left: 3px solid var(--md-info-400) !important;
}

/* Toast action button — tonal text */
html body .toast .btn-toast-action,
html body .toast .toast-action {
  background: transparent !important;
  border: 0 !important;
  color: var(--md-primary-80) !important;
  font-family: 'Inter', sans-serif !important;
  font-size: 12px !important;
  font-weight: 500 !important;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 4px 8px !important;
  border-radius: var(--md-radius-sm) !important;
  white-space: nowrap;
}

html body .toast .btn-toast-action:hover,
html body .toast .toast-action:hover {
  background: rgba(255, 255, 255, 0.08) !important;
  color: var(--md-primary-80) !important;
}

/* Toast fade-in slide animation */
html body .toast.fade {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 200ms ease, transform 220ms cubic-bezier(0.2, 0, 0, 1);
}

html body .toast.fade.show {
  opacity: 1;
  transform: translateY(0);
}


/* ============================================================================
   6. NOTYF — third-party toast library Phoenix uses in some pages
   Override if found
   ============================================================================ */

html body .notyf__toast {
  background-color: var(--md-neutral-10) !important;
  border-radius: var(--md-radius-lg) !important;
  box-shadow: var(--md-elev-3), 0 4px 8px rgba(15, 55, 65, 0.18) !important;
  color: #FFFFFF !important;
  font-family: 'Inter', sans-serif !important;
  font-size: 13px !important;
  padding: 10px 14px !important;
  min-width: 280px;
  max-width: 480px;
}

html body .notyf__toast--success {
  border-left: 3px solid var(--md-success-400) !important;
}

html body .notyf__toast--error {
  border-left: 3px solid var(--md-error-400) !important;
}

html body .notyf__icon {
  width: 18px !important;
  height: 18px !important;
  margin-right: 10px !important;
}

html body .notyf__icon--success {
  background-color: var(--md-success-400) !important;
}

html body .notyf__icon--error {
  background-color: var(--md-error-400) !important;
}

html body .notyf__dismiss-btn {
  opacity: 0.7 !important;
  background-color: transparent !important;
}

html body .notyf__dismiss-btn:hover {
  opacity: 1 !important;
}


/* ============================================================================
   7. CONFIRMATION DIALOGS — when modal is used for confirm/destroy actions
   Detect by .modal.modal-confirm or destructive pattern
   ============================================================================ */

html body .modal-confirm .modal-content,
html body .modal-destructive .modal-content {
  max-width: 420px;
}

html body .modal-destructive .modal-header .modal-title {
  color: var(--md-error-800);
}

html body .modal-destructive .modal-footer .btn-danger {
  /* already styled in Sprint 1 */
}


/* ============================================================================
   8. ACCESSIBILITY — focus rings, reduced motion
   ============================================================================ */

html body .modal-content:focus-visible,
html body .offcanvas:focus-visible {
  outline: 2px solid var(--md-primary-40);
  outline-offset: 4px;
}

@media (prefers-reduced-motion: reduce) {
  html body .modal.fade .modal-dialog { transition: none; transform: none; }
  html body .toast.fade { transition: none; transform: none; }
  html body .modal-backdrop,
  html body .offcanvas-backdrop { backdrop-filter: none; -webkit-backdrop-filter: none; }
}


/* ============================================================================
   9. RESPONSIVE — mobile breakpoints
   ============================================================================ */

@media (max-width: 576px) {
  html body .modal-dialog {
    margin: 12px;
  }
  html body .modal-content {
    border-radius: var(--md-radius-xl) !important;
  }
  html body .modal-header {
    padding: 14px 16px 4px !important;
  }
  html body .modal-body {
    padding: 12px 16px 14px !important;
  }
  html body .modal-footer {
    padding: 10px 16px !important;
    flex-wrap: wrap;
  }
  html body .toast-container {
    bottom: 16px !important;
    right: 16px !important;
    left: 16px !important;
  }
  html body .toast {
    min-width: 0;
    max-width: 100%;
    width: 100%;
  }
}


/* ============================================================================
   END OF SPRINT 3
   Coming next:
   · Sprint 4: tables, data grids, list-groups, pagination, empty states
   · Sprint 5: tabs, stepper, nav-pills, breadcrumb extensions
   · Sprint 6: charts (ECharts theme), sparklines, gauges
   · Sprint 7: kanban, calendar, file manager, wizard, timeline
   · Sprint 8: Flatpickr, TinyMCE, Choices.js, Dropzone polish
   ============================================================================ */
