/**
 * Site Mechanic - Modal Component Styles
 * Generic, reusable modal system
 */

/* Modal Overlay */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal, 40);
  background: var(--modal-backdrop, rgba(0, 0, 0, 0.85));
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.modal-overlay--open {
  opacity: 1;
  pointer-events: all;
}

/* Modal Container */
.modal {
  position: relative;
  background: var(--bg-card, #161A1F);
  border: 1px solid var(--border-color, rgba(255, 255, 255, 0.1));
  border-radius: var(--radius-xl, 16px);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  max-height: calc(100vh - 2rem);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transform: scale(0.9);
  opacity: 0;
  transition: transform 0.3s ease, opacity 0.3s ease;
}

.modal--open {
  transform: scale(1);
  opacity: 1;
}

/* Modal Sizes */
.modal--small {
  width: 100%;
  max-width: var(--modal-width-sm, 400px);
}

.modal--medium {
  width: 100%;
  max-width: var(--modal-width-md, 600px);
}

.modal--large {
  width: 100%;
  max-width: var(--modal-width-lg, 900px);
}

.modal--fullscreen {
  width: 100%;
  max-width: 100%;
  height: calc(100vh - 2rem);
}

/* Single report purchase modal (compact) */
.modal--single-report {
  width: min(400px, calc(100vw - 2rem));
  max-width: min(400px, calc(100vw - 2rem));
}

/* Modal Header */
.modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.5rem 2rem;
  border-bottom: 1px solid var(--border-color, rgba(255, 255, 255, 0.1));
}

.modal__title {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-primary, #fff);
}

.modal__title .sm-modal-title {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
}

.modal__title .sm-modal-title--stacked {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.125rem;
  width: 100%;
}

.modal__title .sm-modal-title__brand {
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-secondary, #9ca3af);
}

.modal__title .sm-modal-title__logo {
  width: 28px;
  height: 28px;
  display: inline-block;
}

.modal__title .sm-modal-title__logo--large {
  width: 140px;
  height: auto;
  display: block;
}

.modal__title .sm-modal-title__logo--red {
  width: 240px;
  height: 36px;
  display: block;
}

.modal__title .sm-modal-title__text {
  display: inline-block;
}

.modal__title .sm-modal-title--stacked .sm-modal-title__text {
  display: block;
  text-align: center;
  font-size: 0.875rem;
  margin-top: 0.25rem;
}

.modal__close {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem;
  background: transparent;
  border: none;
  border-radius: var(--radius-md, 8px);
  color: var(--text-secondary, #9ca3af);
  cursor: pointer;
  transition: all 0.2s ease;
}

.modal__close:hover {
  background: var(--bg-hover, rgba(255, 255, 255, 0.05));
  color: var(--text-primary, #fff);
}

.modal__close:focus {
  outline: 2px solid var(--color-primary, #5bf4e7);
  outline-offset: 2px;
}

.modal__close svg {
  display: block;
}

/* Modal Body */
.modal__body {
  flex: 1;
  overflow-y: auto;
  padding: 2rem;
}

/* Scrollbar styling for modal body */
.modal__body::-webkit-scrollbar {
  width: 8px;
}

.modal__body::-webkit-scrollbar-track {
  background: var(--bg-elevated, #111418);
  border-radius: 4px;
}

.modal__body::-webkit-scrollbar-thumb {
  background: var(--border-color, rgba(255, 255, 255, 0.2));
  border-radius: 4px;
}

.modal__body::-webkit-scrollbar-thumb:hover {
  background: var(--border-color-strong, rgba(255, 255, 255, 0.3));
}

/* Modal Footer */
.modal__footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
  padding: 1.5rem 2rem;
  border-top: 1px solid var(--border-color, rgba(255, 255, 255, 0.1));
}

/* Responsive */
@media (max-width: 768px) {
  .modal-overlay {
    padding: 0;
  }

  .modal {
    max-height: 100vh;
    border-radius: 0;
  }

  .modal--fullscreen,
  .modal--large,
  .modal--medium,
  .modal--small {
    width: 100%;
    max-width: 100%;
    height: 100vh;
    max-height: 100vh;
  }

  .modal__header {
    padding: 1rem 1.5rem;
  }

  .modal__body {
    padding: 1.5rem;
  }

  .modal__footer {
    padding: 1rem 1.5rem;
  }
}

/* Accessibility: Reduce motion */
@media (prefers-reduced-motion: reduce) {
  .modal-overlay,
  .modal {
    transition: none;
  }
}
