/* Modal Component Styles - Following Design System Architecture */

/* Modal Manager Container */
.bjl-modal-manager {
  position: fixed;
  top: 0;
  left: 0;
  width: 0;
  height: 0;
  pointer-events: none;
  z-index: var(--bjl-z-modal-manager, 999999);
}

/* Base modal backdrop */
.bjl-modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--bjl-overlay-backdrop, rgba(0, 0, 0, 0.8));
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: var(--bjl-z-modal-backdrop, 1000);
  animation: bjl-fade-in 200ms ease-out;
  pointer-events: all;
}

/* Modal container - Base component (stable selector) */
.bjl-modal {
  /* Use semantic tokens instead of component-specific ones */
  width: var(--bjl-content-width-md, 32rem);
  max-width: var(--bjl-content-max-width, 90vw);
  max-height: var(--bjl-content-max-height, 90vh);
  background-color: var(--bjl-color-surface);
  border-radius: var(--bjl-radius-lg, 0.5rem);
  box-shadow: var(--bjl-shadow-xl, 0 20px 25px -5px rgba(0, 0, 0, 0.1));
  overflow: hidden;
  display: flex;
  flex-direction: column;
  animation: bjl-slide-up 200ms ease-out;
  border: var(--bjl-border-width-thick, 2px) solid var(--bjl-color-border-strong);
}

/* Size variants (space-separated classes) */
.bjl-modal.sm {
  width: var(--bjl-content-width-sm, 24rem);
}

.bjl-modal.md {
  width: var(--bjl-content-width-md, 32rem);
}

.bjl-modal.lg {
  width: var(--bjl-content-width-lg, 42rem);
}

.bjl-modal.xl {
  width: var(--bjl-content-width-xl, 56rem);
}

.bjl-modal.full {
  width: 100vw;
  max-width: 100vw;
  height: 100vh;
  max-height: 100vh;
  border-radius: 0;
}

/* Type variants - Drawer */
.bjl-modal-backdrop:has(.drawer) {
  align-items: stretch;
  justify-content: stretch;
}

.bjl-modal.drawer {
  width: var(--bjl-drawer-width, 20rem);
  max-width: 90vw;
  height: 100vh;
  max-height: 100vh;
  border-radius: 0;
  animation: none;
}

/* Position variants for drawer */
.bjl-modal.drawer.left {
  margin-right: auto;
  animation: bjl-slide-in-left 200ms ease-out;
}

.bjl-modal.drawer.right {
  margin-left: auto;
  animation: bjl-slide-in-right 200ms ease-out;
}

/* Modal sub-components (no BEM syntax) */
.bjl-modal-header,
.bjl-modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--bjl-layout-padding-lg, 1.5rem);
  border-bottom: var(--bjl-border-width-thick, 2px) solid var(--bjl-color-border);
  flex-shrink: 0;
  background-color: var(--bjl-color-surface);
}

.bjl-modal-title,
.bjl-modal__title {
  margin: 0;
  font-size: var(--bjl-text-xl, 1.5rem);
  font-weight: var(--bjl-font-semibold, 600);
  color: var(--bjl-color-text);
  line-height: 1.2;
  font-family: var(--bjl-font-family-heading, inherit);
}

.bjl-modal-content,
.bjl-modal__content {
  padding: var(--bjl-layout-padding-lg, 1.5rem);
  overflow-y: auto;
  flex: 1;
  color: var(--bjl-color-text);
}

.bjl-modal-footer,
.bjl-modal__footer {
  padding: var(--bjl-layout-padding-md, 1rem);
  border-top: var(--bjl-border-width-thick, 2px) solid var(--bjl-color-border);
  display: flex;
  gap: var(--bjl-space-md, 0.75rem);
  justify-content: flex-end;
  flex-shrink: 0;
  background-color: transparent;
}

/* Close button */
.bjl-modal-close,
.bjl-modal__close {
  background: none;
  border: none;
  padding: var(--bjl-space-sm, 0.5rem);
  cursor: pointer;
  color: var(--bjl-color-text-secondary);
  transition: all 150ms ease;
  border-radius: var(--bjl-radius-sm, 0.25rem);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-left: var(--bjl-space-md, 1rem);
}

.bjl-modal-close:hover,
.bjl-modal__close:hover {
  color: var(--bjl-color-text);
  background: var(--bjl-color-background-hover, rgba(0, 0, 0, 0.05));
}

.bjl-modal-close:focus-visible,
.bjl-modal__close:focus-visible {
  outline: 2px solid var(--bjl-color-primary);
  outline-offset: 2px;
}

/* Animations */
@keyframes bjl-fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes bjl-slide-up {
  from {
    transform: translateY(20px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

@keyframes bjl-slide-in-left {
  from {
    transform: translateX(-100%);
  }
  to {
    transform: translateX(0);
  }
}

@keyframes bjl-slide-in-right {
  from {
    transform: translateX(100%);
  }
  to {
    transform: translateX(0);
  }
}

/* Responsive */
@media (max-width: 640px) {
  .bjl-modal:not(.full) {
    width: calc(100vw - 2rem);
    max-width: calc(100vw - 2rem);
    margin: 1rem;
  }
}

/* Accessibility - Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .bjl-modal-backdrop,
  .bjl-modal {
    animation: none;
  }
}

/* Screen reader only utility */
.bjl-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}