/* Advoke CV — Native Dialog Component (Enhanced) */

dialog.dialog {
  display: none;
  position: fixed;
  inset: 0;
  width: 100%;
  max-width: 32rem;
  max-height: calc(100dvh - var(--space-8));
  margin: auto;
  padding: 0;
  border: none;
  border-radius: var(--radius-2xl);
  background-color: var(--white);
  color: var(--color-text);
  box-shadow: var(--shadow-2xl);
  overflow: hidden;
  z-index: var(--z-modal);
}

dialog.dialog[open] {
  display: flex;
  flex-direction: column;
  animation: dialog-in var(--duration-base) var(--ease-out) both;
}

dialog.dialog::backdrop {
  background-color: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  animation: dialog-backdrop-in var(--duration-base) var(--ease-out) both;
}

dialog.dialog.is-closing {
  animation: dialog-out var(--duration-fast) var(--ease-in) both;
}

dialog.dialog.is-closing::backdrop {
  animation: dialog-backdrop-out var(--duration-fast) var(--ease-in) both;
}

@keyframes dialog-in {
  from {
    opacity: 0;
    transform: scale(0.96) translateY(8px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

@keyframes dialog-out {
  from {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
  to {
    opacity: 0;
    transform: scale(0.96) translateY(8px);
  }
}

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

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

dialog.dialog--sm { max-width: 24rem; }
dialog.dialog--lg { max-width: 42rem; }
dialog.dialog--xl { max-width: 56rem; }
dialog.dialog--full {
  max-width: calc(100vw - var(--space-4));
  max-height: calc(100dvh - var(--space-4));
}

.dialog__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-5) var(--space-6);
  border-bottom: 1px solid var(--color-border-subtle);
  flex-shrink: 0;
}

.dialog__title {
  font-size: var(--text-xl);
  font-weight: var(--font-weight-semibold);
  letter-spacing: -0.015em;
  line-height: 1.3;
  color: var(--color-text);
  margin: 0;
  flex: 1 1 auto;
  min-width: 0;
}

.dialog__close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  color: var(--color-text-secondary);
  background-color: transparent;
  border: none;
  cursor: pointer;
  transition: var(--transition-colors);
  margin: -4px -4px -4px 0;
}

.dialog__close:hover {
  background-color: var(--color-accent-tint);
  color: var(--color-text);
}

.dialog__close:focus-visible {
  outline: var(--focus-ring-width) solid var(--focus-ring-color);
  outline-offset: var(--focus-ring-offset);
}

.dialog__close svg {
  width: 18px;
  height: 18px;
}

.dialog__body {
  flex: 1 1 auto;
  padding: var(--space-5) var(--space-6);
  overflow-y: auto;
  overscroll-behavior: contain;
  font-size: var(--text-base);
  line-height: var(--line-height-relaxed);
  color: var(--color-text-secondary);
}

.dialog__body > * + * {
  margin-top: var(--space-4);
}

.dialog__footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid var(--color-border-subtle);
  background-color: var(--color-bg-subtle);
  flex-shrink: 0;
}

.dialog--danger .dialog__header {
  border-bottom-color: #FCA5A5;
}

.dialog--danger .dialog__title {
  color: var(--color-danger);
}

.dialog--danger .dialog__body::before {
  content: "";
  display: block;
  width: 40px;
  height: 40px;
  margin-bottom: var(--space-3);
  border-radius: var(--radius-full);
  background-color: var(--color-danger-bg);
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23B91C1C'><path d='M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-2h2v2zm0-4h-2V7h2v6z'/></svg>");
  background-size: 24px 24px;
  background-repeat: no-repeat;
  background-position: center;
}

.dialog--confirm .dialog__footer {
  justify-content: space-between;
}

.dialog--confirm .dialog__footer .btn:last-child {
  margin-left: auto;
}

dialog.dialog--sheet {
  margin: auto auto 0;
  max-width: 100%;
  width: 100%;
  max-height: 85dvh;
  border-radius: var(--radius-2xl) var(--radius-2xl) 0 0;
}

@media (max-width: 640px) {
  dialog.dialog {
    margin: auto auto 0;
    max-width: 100%;
    width: 100%;
    max-height: 92dvh;
    border-radius: var(--radius-2xl) var(--radius-2xl) 0 0;
  }
  .dialog__header {
    padding: var(--space-4) var(--space-5);
  }
  .dialog__body {
    padding: var(--space-4) var(--space-5);
  }
  .dialog__footer {
    padding: var(--space-3) var(--space-5) var(--space-4);
    padding-bottom: max(var(--space-4), env(safe-area-inset-bottom));
  }
  .dialog__footer .btn {
    flex: 1 1 auto;
    min-width: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  dialog.dialog[open],
  dialog.dialog::backdrop,
  dialog.dialog.is-closing,
  dialog.dialog.is-closing::backdrop {
    animation: none;
  }
}