/*
 * İnsya Dialog (insya-dialog.js) — onay / uyarı / giriş pencereleri ve bildirimler. Öneki: idg-
 * Renkler masaüstü paletinden (--ee-* pencere teması varsa o, yoksa aynı değerler); --idg-* ile ezilebilir.
 */
.idg-backdrop,
.idg-toasts {
  --idg-bg: var(--ee-surface, #ffffff);
  --idg-bg-2: var(--ee-surface-2, #f6f7f3);
  --idg-ink: var(--ee-ink, #1f2f25);
  --idg-soft: var(--ee-ink-soft, #3d5245);
  --idg-muted: var(--ee-muted, #6b7d6f);
  --idg-line: var(--ee-line, rgba(83, 105, 83, 0.2));
  --idg-line-strong: var(--ee-line-strong, rgba(83, 105, 83, 0.34));
  --idg-accent: #2b5038;
  --idg-ring: rgba(43, 80, 56, 0.2);
  --idg-danger: #c0533a;
  --idg-warning: #c68a1d;
  --idg-success: #3f9a5b;
  --idg-info: #4b6fb5;
  --idg-radius: 12px;
  --idg-font: var(--ee-sans, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif);
}

body.darkmode .idg-backdrop,
body.darkmode .idg-toasts,
html.ed-embed:has(> body.darkmode) .idg-backdrop {
  --idg-bg: #1f2328;
  --idg-bg-2: #262b31;
  --idg-ink: #e6edf3;
  --idg-soft: #c9d1d9;
  --idg-muted: #8b949e;
  --idg-line: rgba(240, 246, 252, 0.12);
  --idg-line-strong: rgba(240, 246, 252, 0.22);
  --idg-accent: #7fc79a;
  --idg-ring: rgba(127, 199, 154, 0.25);
}

html.idg-open {
  overflow: hidden;
}

/* ---------------- arka plan ---------------- */
.idg-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100000;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(22, 32, 26, 0.34);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
  opacity: 0;
  transition: opacity 0.16s ease;
  font-family: var(--idg-font);
}

.idg-backdrop.is-on {
  opacity: 1;
}

.idg-backdrop.is-behind {
  background: transparent;
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
}

/* ---------------- pencere ---------------- */
.idg {
  position: relative;
  display: flex;
  gap: 14px;
  width: 420px;
  max-width: 100%;
  max-height: calc(100vh - 32px);
  max-height: calc(100dvh - 32px);
  padding: 20px 20px 16px;
  overflow: auto;
  background: var(--idg-bg);
  border: 1px solid var(--idg-line);
  border-radius: var(--idg-radius);
  box-shadow: 0 24px 60px rgba(20, 35, 25, 0.24), 0 2px 6px rgba(20, 35, 25, 0.08);
  color: var(--idg-ink);
  font-size: 13px;
  line-height: 1.45;
  text-align: left;
  flex-wrap: wrap;
  transform: translateY(6px) scale(0.985);
  transition: transform 0.16s ease;
}

.idg-backdrop.is-on .idg {
  transform: none;
}

.idg:focus {
  outline: none;
}

.idg-icon {
  flex: none;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  color: var(--idg-muted);
  background: var(--idg-bg-2);
}

.idg-icon svg {
  width: 22px;
  height: 22px;
}

.idg-warning .idg-icon { color: var(--idg-warning); background: rgba(198, 138, 29, 0.12); }
.idg-danger .idg-icon,
.idg-error .idg-icon { color: var(--idg-danger); background: rgba(192, 83, 58, 0.12); }
.idg-success .idg-icon { color: var(--idg-success); background: rgba(63, 154, 91, 0.13); }
.idg-info .idg-icon,
.idg-question .idg-icon { color: var(--idg-info); background: rgba(75, 111, 181, 0.12); }

.idg-image {
  flex: none;
  max-width: 64px;
  max-height: 64px;
  border-radius: 8px;
}

.idg-body {
  flex: 1 1 260px;
  min-width: 0;
}

.idg-title {
  margin: 2px 0 6px;
  color: var(--idg-ink);
  font: 700 15px/1.3 var(--idg-font);
  letter-spacing: 0;
  text-transform: none;
}

.idg-text {
  color: var(--idg-soft);
  white-space: pre-line;
  overflow-wrap: anywhere;
}

.idg-details {
  margin: 8px 0 0;
  padding: 8px 10px 8px 26px;
  max-height: 160px;
  overflow-y: auto;
  border-radius: 8px;
  background: var(--idg-bg-2);
  color: var(--idg-soft);
  font-size: 12px;
}

.idg-field {
  display: block;
  margin: 10px 0 0;
  font-weight: 400;
}

.idg-field-label {
  display: block;
  margin-bottom: 4px;
  color: var(--idg-muted);
  font-size: 12px;
}

.idg .idg-input {
  display: block;
  width: 100%;
  margin-top: 10px;
  padding: 7px 10px;
  border: 1px solid var(--idg-line-strong);
  border-radius: 8px;
  background: var(--idg-bg);
  box-shadow: none;
  color: var(--idg-ink);
  font: 400 13px/1.4 var(--idg-font);
}

.idg .idg-field .idg-input {
  margin-top: 0;
}

.idg textarea.idg-input {
  resize: vertical;
  min-height: 84px;
}

.idg .idg-input:focus {
  outline: none;
  border-color: var(--idg-accent);
  box-shadow: 0 0 0 1px var(--idg-accent);
}

.idg .idg-input.is-invalid {
  border-color: var(--idg-danger);
  box-shadow: 0 0 0 3px rgba(192, 83, 58, 0.16);
}

.idg-check {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 10px 0 0;
  color: var(--idg-soft);
  font-weight: 400;
  cursor: pointer;
}

.idg-check input {
  margin: 0;
  accent-color: var(--idg-accent);
}

.idg-invalid {
  margin-top: 8px;
  color: var(--idg-danger);
  font-size: 12px;
}

/* ---------------- düğmeler ---------------- */
.idg-actions {
  display: flex;
  flex: 1 1 100%;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 4px;
  padding-top: 12px;
  border-top: 1px solid var(--idg-line);
}

.idg .idg-btn {
  height: 32px;
  min-width: 84px;
  padding: 0 14px;
  border: 1px solid var(--idg-line-strong);
  border-radius: 8px;
  background: var(--idg-bg);
  box-shadow: none;
  color: var(--idg-ink);
  font: 600 13px/1 var(--idg-font);
  letter-spacing: 0;
  text-transform: none;
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease, filter 0.12s ease;
}

.idg .idg-btn:hover {
  background: var(--idg-bg-2);
}

.idg .idg-btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 1px var(--idg-accent);
}

.idg .idg-btn-ghost {
  border-color: transparent;
  color: var(--idg-soft);
}

.idg .idg-btn-primary {
  border-color: var(--idg-accent);
  background: var(--idg-accent);
  color: #fff;
}

.idg .idg-btn-danger {
  border-color: var(--idg-danger);
  background: var(--idg-danger);
  color: #fff;
}

.idg .idg-btn-primary:hover,
.idg .idg-btn-danger:hover {
  background: var(--idg-accent);
  filter: brightness(1.1);
}

.idg .idg-btn-danger:hover {
  background: var(--idg-danger);
}

.idg .idg-btn[style*="background"] {
  color: #fff;
}

.idg .idg-btn[disabled] {
  opacity: 0.6;
  cursor: progress;
}

body.darkmode .idg .idg-btn-primary {
  color: #10231a;
}

/* ---------------- zamanlayıcı ---------------- */
.idg-timer {
  position: absolute;
  left: 0;
  bottom: 0;
  height: 3px;
  width: 100%;
  background: var(--idg-accent);
  transform-origin: left;
  animation: idg-timer linear forwards;
  opacity: 0.5;
}

@keyframes idg-timer {
  from { transform: scaleX(1); }
  to { transform: scaleX(0); }
}

/* ---------------- bildirimler ---------------- */
.idg-toasts {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 100001;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  pointer-events: none;
  font-family: var(--idg-font);
}

.idg-toast {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 220px;
  max-width: 380px;
  padding: 8px 8px 8px 10px;
  border: 1px solid var(--idg-line);
  border-radius: 10px;
  background: var(--idg-bg);
  box-shadow: 0 12px 32px rgba(20, 35, 25, 0.18);
  color: var(--idg-ink);
  font-size: 13px;
  pointer-events: auto;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.idg-toast.is-on {
  opacity: 1;
  transform: none;
}

.idg-toast .idg-icon {
  width: 26px;
  height: 26px;
  border-radius: 7px;
}

.idg-toast .idg-icon svg {
  width: 16px;
  height: 16px;
}

.idg-toast-success .idg-icon { color: var(--idg-success); background: rgba(63, 154, 91, 0.13); }
.idg-toast-error .idg-icon { color: var(--idg-danger); background: rgba(192, 83, 58, 0.12); }
.idg-toast-warning .idg-icon { color: var(--idg-warning); background: rgba(198, 138, 29, 0.12); }
.idg-toast-info .idg-icon { color: var(--idg-info); background: rgba(75, 111, 181, 0.12); }

.idg-toast-text {
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
}

.idg-toast-action,
.idg-toast-close {
  flex: none;
  border: 0;
  background: none;
  cursor: pointer;
  font: inherit;
}

.idg-toast-action {
  padding: 4px 8px;
  border-radius: 6px;
  color: var(--idg-accent);
  font-weight: 700;
}

.idg-toast-action:hover {
  background: var(--idg-bg-2);
}

.idg-toast-close {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  color: var(--idg-muted);
  font-size: 16px;
  line-height: 1;
}

.idg-toast-close:hover {
  background: var(--idg-bg-2);
  color: var(--idg-ink);
}

/* ---------------- dar ekran: alttan açılan pencere ---------------- */
@media (max-width: 480px) {
  .idg-backdrop {
    place-items: end center;
    padding: 0;
  }

  .idg {
    width: 100% !important;
    border-radius: var(--idg-radius) var(--idg-radius) 0 0;
    max-height: 85vh;
  }

  .idg-actions .idg-btn {
    flex: 1;
  }

  .idg-toasts {
    left: 12px;
    right: 12px;
    align-items: stretch;
  }

  .idg-toast {
    max-width: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .idg-backdrop,
  .idg,
  .idg-toast {
    transition: none;
  }

  .idg-timer {
    animation: none;
  }
}
