// Rôle : regroupe les styles des modales, viewers et notifications.
.image-viewer-root {
  position: fixed;
  inset: 0;
  z-index: 110;
  display: grid;
  place-items: center;
  padding: var(--space-5);
  overscroll-behavior: contain;
}

.image-viewer-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(2, 3, 9, 0.64);
  backdrop-filter: blur(4px);
}

.image-viewer {
  --viewer-content-max-height: min(80vh, calc(100vh - 140px));
  --viewer-image-height: 400px;
  position: relative;
  display: grid;
  width: min(1500px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
  gap: var(--space-4);
  padding: var(--space-4);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  background: rgba(16, 20, 38, 0.96);
  box-shadow: var(--shadow-lg);
}

.image-viewer header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--space-2);
}

.image-viewer-title {
  overflow: hidden;
  color: var(--color-text);
  font-size: var(--font-size-md);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.image-viewer-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-2);
}

.image-viewer-button {
  flex: 0 0 40px;
}

.image-viewer-body {
  display: grid;
  min-width: 0;
  justify-items: center;
}

.image-viewer-body.has-annotation-side {
  grid-template-columns: minmax(0, 1fr) minmax(240px, 340px);
  gap: var(--space-4);
  align-items: start;
  justify-items: stretch;
}

.image-viewer-media {
  display: flex;
  min-width: 0;
  max-width: 100%;
  justify-self: center;
  justify-content: center;
  align-items: start;
}

.image-viewer-media.can-annotate {
  cursor: crosshair;
}

.image-viewer-image-frame {
  position: relative;
  display: block;
  width: fit-content;
  max-width: 100%;
  overflow: hidden;
  border-radius: var(--radius-md);
  line-height: 0;
}

.image-viewer-image-frame img {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: var(--viewer-content-max-height);
  object-fit: contain;
}

.image-viewer-marker {
  z-index: 3;
  display: inline-grid;
  width: 30px;
  min-width: 30px;
  height: 30px;
  min-height: 30px;
  place-items: center;
  padding: 0;
  border: 1px solid rgba(246, 196, 83, 0.72);
  border-radius: var(--radius-pill);
  background:
    linear-gradient(135deg, rgba(72, 43, 160, 0.96), rgba(45, 52, 146, 0.94)) padding-box,
    linear-gradient(135deg, rgba(246, 196, 83, 0.9), rgba(196, 181, 253, 0.5)) border-box;
  color: #fff;
  font-size: var(--font-size-xs);
  font-weight: 900;
  line-height: 1;
  box-shadow:
    0 0 0 2px rgba(5, 7, 17, 0.72),
    0 0 16px rgba(246, 196, 83, 0.22);
  pointer-events: none;
}

.image-viewer-side {
  display: grid;
  align-content: start;
  grid-template-rows: auto auto;
  gap: var(--space-3);
  min-width: 0;
  width: 100%;
  max-width: 340px;
  height: min(var(--viewer-image-height), var(--viewer-content-max-height));
  max-height: min(var(--viewer-image-height), var(--viewer-content-max-height));
  overflow: hidden;
  padding: 12px;
  border: 1px solid rgba(165, 180, 252, 0.12);
  border-radius: var(--radius-md);
  background:
    linear-gradient(135deg, rgba(139, 92, 246, 0.045), transparent 62%),
    rgba(7, 10, 24, 0.38);
}

.image-viewer-side strong {
  color: var(--color-text-secondary);
  font-size: var(--font-size-sm);
}

.image-viewer-side .annotation-marker-list {
  min-width: 0;
  max-height: 100%;
  align-content: start;
  grid-auto-rows: max-content;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 4px 4px 4px 0;
}

.drawer[aria-hidden="true"] {
  display: none;
}

.drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(2, 3, 9, 0.24);
  backdrop-filter: none;
}

.drawer-panel {
  position: fixed;
  inset: 0 0 0 auto;
  z-index: 50;
  width: min(720px, 94vw);
  min-width: 360px;
  max-width: 94vw;
  overflow: auto;
  border-left: 0;
  background:
    linear-gradient(
      180deg,
      rgba(246, 196, 83, 0.92),
      rgba(139, 92, 246, 0.64) 48%,
      rgba(196, 181, 253, 0.72)
    ) left top / 1px 100% no-repeat,
    rgba(7, 9, 19, 0.82);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  box-shadow:
    inset 8px 0 18px rgba(139, 92, 246, 0.08),
    var(--shadow-lg);
  padding: var(--space-5);
}

.drawer-panel::before {
  content: none;
}

.drawer-content {
  position: relative;
  display: flex;
  min-height: 100%;
  flex-direction: column;
  gap: var(--space-4);
}

.drawer-resize-handle {
  position: fixed;
  top: 50%;
  right: calc(var(--drawer-panel-width, min(720px, 94vw)) - 18px);
  z-index: 62;
  width: 14px;
  height: 72px;
  border-radius: var(--radius-pill);
  cursor: ew-resize;
  transform: translateY(-50%);
}

.drawer-resize-handle::before {
  content: "";
  position: absolute;
  top: 0;
  left: 5px;
  width: 4px;
  height: 100%;
  border-radius: inherit;
  background: var(--gradient-brand);
  opacity: 0.72;
}

body.is-resizing-drawer,
body.is-resizing-drawer * {
  cursor: ew-resize !important;
  user-select: none;
}

.drawer-panel > .drawer-content > header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-3);
}

.drawer-toolbox-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-top: var(--space-3);
}

.drawer-action-button {
  display: inline-flex;
}

.drawer-action-button:disabled {
  color: var(--color-text-disabled);
  cursor: not-allowed;
  opacity: 0.56;
}

.drawer-close-button {
  flex: 0 0 40px;
}

.drawer-panel .modules {
  grid-template-columns: 1fr;
}

.confirm-modal-root {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: var(--space-5);
  overscroll-behavior: contain;
}

.tool-add-modal-root {
  position: fixed;
  inset: 0;
  z-index: 130;
  display: grid;
  place-items: center;
  padding: var(--space-5);
  overscroll-behavior: contain;
}

.confirm-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(2, 3, 9, 0.62);
  backdrop-filter: blur(6px);
}

.confirm-modal {
  position: relative;
  width: min(520px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
  overflow: auto;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  background: rgba(16, 20, 38, 0.96);
  box-shadow: var(--shadow-lg);
  padding: var(--space-5);
}

.confirm-modal h2 {
  margin-bottom: var(--space-3);
}

.confirm-modal p {
  margin-bottom: var(--space-6);
}

.confirm-modal footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

@property --notification-toast-angle {
  syntax: "<angle>";
  inherits: false;
  initial-value: 0deg;
}

.notification-toast-stack {
  position: fixed;
  bottom: var(--space-5);
  z-index: 360;
  display: flex;
  max-width: min(460px, calc(100vw - 32px));
  flex-direction: column-reverse;
  gap: var(--space-3);
  pointer-events: none;
}

.notification-toast-stack.is-right {
  right: var(--space-5);
}

.notification-toast-stack.is-left {
  left: var(--space-5);
}

.notification-toast {
  --notification-toast-angle: 0deg;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 34px;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  min-width: min(360px, calc(100vw - 32px));
  padding: 14px 14px 14px 18px;
  border: 2px solid transparent;
  border-radius: var(--radius-lg);
  background:
    radial-gradient(circle at 100% 0%, rgba(246, 196, 83, 0.12), transparent 38%) padding-box,
    linear-gradient(135deg, rgba(16, 20, 38, 0.98), rgba(24, 20, 42, 0.98)) padding-box,
    conic-gradient(
      from var(--notification-toast-angle),
      rgba(246, 196, 83, 0.95),
      rgba(139, 92, 246, 0.8),
      rgba(56, 189, 248, 0.62),
      rgba(246, 196, 83, 0.95)
    ) border-box;
  color: var(--color-text-primary);
  box-shadow:
    var(--shadow-md),
    0 0 24px rgba(139, 92, 246, 0.22),
    0 0 18px rgba(246, 196, 83, 0.1);
  font-size: var(--font-size-md);
  font-weight: 900;
  pointer-events: auto;
  animation:
    notification-toast-enter-right 320ms var(--ease-standard),
    notification-toast-border-spin 2.4s linear infinite,
    notification-toast-pulse 1.8s ease-in-out infinite;
}

.notification-toast-stack.is-left .notification-toast {
  animation:
    notification-toast-enter-left 320ms var(--ease-standard),
    notification-toast-border-spin 2.4s linear infinite,
    notification-toast-pulse 1.8s ease-in-out infinite;
}

.notification-toast span {
  min-width: 0;
}

.notification-toast button {
  display: inline-grid;
  width: 34px;
  min-width: 34px;
  min-height: 34px;
  place-items: center;
  padding: 0;
  border-color: rgba(165, 180, 252, 0.12);
  background: rgba(5, 7, 17, 0.28);
  color: var(--color-text-secondary);
}

.notification-toast button:hover {
  border-color: rgba(196, 181, 253, 0.26);
  background: rgba(21, 26, 48, 0.72);
  color: var(--color-text-primary);
}

.notification-toast button .ui-icon {
  width: 16px;
  height: 16px;
}

@keyframes notification-toast-border-spin {
  to { --notification-toast-angle: 360deg; }
}

@keyframes notification-toast-enter-right {
  from {
    opacity: 0;
    transform: translateX(calc(100% + var(--space-5)));
  }

  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes notification-toast-enter-left {
  from {
    opacity: 0;
    transform: translateX(calc(-100% - var(--space-5)));
  }

  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes notification-toast-pulse {
  0%,
  100% {
    box-shadow:
      var(--shadow-md),
      0 0 24px rgba(139, 92, 246, 0.22),
      0 0 18px rgba(246, 196, 83, 0.1);
  }

  50% {
    box-shadow:
      var(--shadow-md),
      0 0 34px rgba(139, 92, 246, 0.3),
      0 0 26px rgba(246, 196, 83, 0.18);
  }
}

.tool-add-modal {
  width: min(560px, calc(100vw - 32px));
}

.tool-add-modal header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-4);
}

.tool-add-modal h2 {
  margin: 0;
}

.tool-add-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-3);
}

.tool-add-card {
  display: grid;
  height: 98px;
  min-width: 0;
  align-content: center;
  justify-items: center;
  gap: 8px;
  padding: var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: rgba(21, 26, 48, 0.72);
  text-align: center;
}

.tool-add-card span:last-child {
  width: 100%;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tool-add-card .module-icon {
  flex: 0 0 34px;
}

.tool-add-card:hover {
  border-color: var(--color-border-hover);
  background: var(--color-bg-hover);
  transform: translateY(-1px);
}

.toolbox-create-modal form,
.toolbox-link-modal form {
  display: grid;
  gap: var(--space-4);
}

.toolbox-create-modal .field,
.toolbox-link-modal .field {
  padding: 0;
}

.confirm-danger {
  border-color: rgba(251, 113, 133, 0.34);
  background: var(--color-danger);
  color: #fff;
  font-weight: 700;
}
