/* Overlay */
.ds-modal__overlay {
  position: fixed;
  inset: 0;
  background: var(--semantic-bg-overlay);
  z-index: 1000;
  animation: ds-modal-fade-in 0.2s ease-out;
}

/* Modal container */
.ds-modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1001;
  pointer-events: none;
  padding: var(--size4, 16px);
  box-sizing: border-box;
}

/* Dialog */
.ds-modal__dialog {
  background: var(--semantic-bg-surface-default);
  border-radius: var(--br-sm, 8px);
  box-shadow: var(--semantic-elevation-elevation3);
  max-width: 95vw;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  pointer-events: auto;
  overflow: hidden;
  position: relative;
  animation: ds-modal-slide-up 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

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

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

/* Sizes */
.ds-modal--sm .ds-modal__dialog {
  width: 320px;
}

.ds-modal--md .ds-modal__dialog {
  width: 600px;
}

.ds-modal--lg .ds-modal__dialog {
  width: 820px;
}

.ds-modal--xl .ds-modal__dialog {
  width: 1024px;
}

.ds-modal--fullscreen .ds-modal__dialog {
  width: 100vw;
  height: 100vh;
  max-width: 100vw;
  max-height: 100vh;
  border-radius: 0;
}

/* Header */
.ds-modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--size5, 40px) var(--size5, 40px) 0 var(--size5, 40px);
  min-height: 56px;
  flex-shrink: 0;
}

.ds-modal__title {
  font-family: var(--heading-h4-fontFamily, var(--font-family, 'Satoshi', sans-serif));
  font-size: var(--heading-h4-fontSize, 24px);
  font-weight: var(--heading-h4-fontWeight, 700);
  line-height: var(--heading-h4-lineHeight, 150%);
  color: var(--semantic-text-corp-primary);
  margin: 0;
}

.ds-modal__close {
  flex-shrink: 0;
}

.ds-modal__close--absolute {
  position: absolute;
  top: var(--size2, 8px);
  right: var(--size2, 8px);
  z-index: 2;
}

/* Body */
.ds-modal__body {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: var(--size5, 40px);
  font-family: var(--body-regular-fontFamily, var(--font-family, 'Satoshi', sans-serif));
  font-size: var(--body-regular-fontSize, 16px);
  font-weight: var(--body-regular-fontWeight, 400);
  line-height: var(--body-regular-lineHeight, 150%);
  color: var(--semantic-text-corp-secondary);
}

/* Footer */
.ds-modal__footer {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: var(--size3, 12px);
  padding: 0 var(--size5, 40px) var(--size5, 40px) var(--size5, 40px);
  min-height: 72px;
  background: var(--semantic-bg-surface-default);
  flex-shrink: 0;
}

/* Variant: Classic */
.ds-modal--classic .ds-modal__dialog {
  width: 408px;
}

/* Variant: Image Top */
.ds-modal--image-top .ds-modal__dialog {
  padding-top: 0;
}

.ds-modal__image-top {
  width: 100%;
  aspect-ratio: 21 / 9;
  background: var(--semantic-bg-surface-default);
  overflow: hidden;
  position: relative;
  flex-shrink: 0;
}

.ds-modal__image-top img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Variant: Image Left */
.ds-modal--image-left .ds-modal__dialog {
  flex-direction: row;
  padding: 0;
}

.ds-modal__image-left {
  width: 200px;
  height: 100%;
  background: var(--semantic-bg-surface-default);
  overflow: hidden;
  border-radius: var(--br-sm, 8px) 0 0 var(--br-sm, 8px);
  flex-shrink: 0;
  display: flex;
  align-items: stretch;
}

.ds-modal__image-left img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.ds-modal--image-left .ds-modal__content {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
  max-height: 85vh;
  overflow: hidden;
}

/* Size SM: Stacked buttons */
.ds-modal--sm .ds-modal__footer {
  flex-direction: column;
  align-items: stretch;
  gap: var(--size2, 8px);
}

.ds-modal--sm .ds-modal__footer > * {
  width: 100%;
}

.ds-modal--sm .ds-modal__title {
  font-family: var(--mobile-h4-m-fontFamily, var(--font-family, 'Satoshi', sans-serif));
  font-size: var(--mobile-h4-m-fontSize, 20px);
  font-weight: var(--mobile-h4-m-fontWeight, 700);
  line-height: var(--mobile-h4-m-lineHeight, 150%);
}

.ds-modal--sm .ds-modal__body {
  padding: var(--size3, 12px);
}

.ds-modal--sm .ds-modal__footer {
  padding: var(--size3, 12px);
  gap: var(--size1, 4px);
}

/* Responsive */
@media (max-width: 600px) {
  .ds-modal__dialog,
  .ds-modal--classic .ds-modal__dialog,
  .ds-modal--image-top .ds-modal__dialog,
  .ds-modal--image-left .ds-modal__dialog {
    width: 100vw;
    min-width: 0;
    max-width: 100vw;
    height: 100vh;
    max-height: 100vh;
    border-radius: 0;
  }

  .ds-modal__image-left {
    display: none;
  }

  .ds-modal--image-left .ds-modal__content {
    max-height: 100vh;
  }

  .ds-modal__header,
  .ds-modal__body,
  .ds-modal__footer {
    padding-left: var(--size4, 16px);
    padding-right: var(--size4, 16px);
  }
}
