/* Native dialog styling - Desktop */
dialog {
  border: none;
  border-radius: 0.5rem;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  padding: 0;
  margin: 0; /* Remove auto margins */
  max-height: calc(100vh - 8rem); /* More space for top positioning */
  overflow-y: auto;
  position: fixed;
  top: 5rem; /* Fixed top position with space */
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 32rem; /* 512px - equivalent to max-w-lg */
}

/* Tablet and small desktop adjustments */
@media (min-width: 640px) {
  dialog {
    margin: 0 1rem; /* Small horizontal margins on tablets */
  }
}

@media (min-width: 768px) {
  dialog {
    margin: 0; /* No horizontal margins on larger screens */
  }
}

/* Mobile dialog positioning */
@media (max-width: 639px) {
  dialog {
    position: fixed;
    top: 4rem; /* Keep some top space on mobile */
    left: 1rem; /* 16px margin from left */
    right: 1rem; /* 16px margin from right */
    width: calc(100% - 2rem); /* Account for left/right margins */
    max-width: none;
    max-height: calc(100vh - 6rem); /* Account for top space */
    transform: none; /* No centering transform needed */
    border-radius: 0.75rem; /* Slightly more rounded on mobile */
  }
}

/* Bottom sheet style for very small screens */
@media (max-width: 480px) {
  dialog {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    top: auto;
    width: 100%;
    max-width: none;
    max-height: 90vh;
    border-radius: 1rem 1rem 0 0; /* Rounded top corners only */
    transform: none;
  }
}

/* Backdrop styling using ::backdrop pseudo-element */
dialog::backdrop {
  background-color: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(2px);
}

/* Desktop animation */
dialog[open] {
  animation: dialog-show-desktop 0.3s ease-out;
}

dialog[open]::backdrop {
  animation: backdrop-show 0.3s ease-out;
}

/* Mobile animation for standard mobile view */
@media (max-width: 639px) and (min-width: 481px) {
  dialog[open] {
    animation: dialog-fade-in 0.3s ease-out;
  }
}

/* Bottom sheet animation for very small screens */
@media (max-width: 480px) {
  dialog[open] {
    animation: dialog-slide-up 0.3s ease-out;
  }
}

/* Desktop animations */
@keyframes dialog-show-desktop {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(-20px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0) scale(1);
  }
}

/* Mobile fade-in animation */
@keyframes dialog-fade-in {
  from {
    opacity: 0;
    transform: translateY(-10px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Mobile slide-up animation for bottom sheet */
@keyframes dialog-slide-up {
  from {
    opacity: 0;
    transform: translateY(100%);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Mobile slide-down animation for closing */
@keyframes dialog-slide-down {
  from {
    opacity: 1;
    transform: translateY(0);
  }
  to {
    opacity: 0;
    transform: translateY(100%);
  }
}

@keyframes backdrop-show {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* Focus styles for accessibility */
dialog:focus {
  outline: 2px solid #3b82f6;
  outline-offset: 2px;
}

/* Ensure content doesn't get cut off */
dialog > * {
  max-width: 100%;
}

/* Scrollable content area */
dialog .dialog-content {
  max-height: 100%;
  overflow-y: auto;
}

/* Responsive text sizing */
@media (max-width: 480px) {
  dialog h1,
  dialog h2,
  dialog h3 {
    font-size: 1.125rem; /* Slightly smaller headings on mobile */
  }
  
  dialog .btn {
    width: 100%; /* Full width buttons on mobile */
    margin-bottom: 0.5rem;
  }
  
  dialog .btn:last-child {
    margin-bottom: 0;
  }
}