/* ═══════════════════════════════════════════════════════
   CNC TOAST NOTIFICATION SYSTEM
   Modern toast notifications with animations
   ═══════════════════════════════════════════════════════ */

:root {
  --toast-success: #42695d;
  --toast-success-bg: #e8f5e9;
  --toast-success-border: #42695d;
  --toast-error: #c62828;
  --toast-error-bg: #fce4ec;
  --toast-error-border: #c62828;
  --toast-warning: #ed7705;
  --toast-warning-bg: #fff3e0;
  --toast-warning-border: #ed7705;
  --toast-info: #1565c0;
  --toast-info-bg: #e3f2fd;
  --toast-info-border: #1565c0;
  --toast-radius: 12px;
  --toast-shadow: 0 8px 32px rgba(0,0,0,0.12), 0 2px 8px rgba(0,0,0,0.08);
  --toast-shadow-hover: 0 12px 40px rgba(0,0,0,0.18), 0 4px 12px rgba(0,0,0,0.1);
  --toast-max-width: 420px;
  --toast-gap: 12px;
  --toast-z: 99999;
}

/* ── Container ── */
#cnc-toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: var(--toast-z);
  display: flex;
  flex-direction: column-reverse;
  gap: var(--toast-gap);
  pointer-events: none;
  max-height: calc(100vh - 48px);
  overflow: hidden;
}

/* ── Toast Element ── */
.cnc-toast {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 16px 20px;
  border-radius: var(--toast-radius);
  background: #fff;
  border-left: 4px solid var(--toast-info);
  box-shadow: var(--toast-shadow);
  pointer-events: all;
  cursor: pointer;
  min-width: 320px;
  max-width: var(--toast-max-width);
  position: relative;
  overflow: hidden;
  transition: box-shadow 0.2s ease, transform 0.2s ease;
  animation: toastSlideIn 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  opacity: 0;
  transform: translateX(100%);
}

.cnc-toast:hover {
  box-shadow: var(--toast-shadow-hover);
  transform: translateX(-4px);
}

/* ── Type variants ── */
.cnc-toast--success { border-left-color: var(--toast-success); }
.cnc-toast--error   { border-left-color: var(--toast-error); }
.cnc-toast--warning { border-left-color: var(--toast-warning); }
.cnc-toast--info    { border-left-color: var(--toast-info); }

/* ── Icon ── */
.cnc-toast__icon {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-size: 13px;
  color: #fff;
  margin-top: 1px;
}

.cnc-toast--success .cnc-toast__icon { background: var(--toast-success); }
.cnc-toast--error   .cnc-toast__icon { background: var(--toast-error); }
.cnc-toast--warning .cnc-toast__icon { background: var(--toast-warning); }
.cnc-toast--info    .cnc-toast__icon { background: var(--toast-info); }

/* ── Content ── */
.cnc-toast__content {
  flex: 1;
  min-width: 0;
}

.cnc-toast__title {
  font-weight: 600;
  font-size: 14px;
  color: #1a1a2e;
  margin: 0 0 2px;
  line-height: 1.3;
}

.cnc-toast__message {
  font-size: 13px;
  color: #555;
  margin: 0;
  line-height: 1.4;
  word-wrap: break-word;
}

/* ── Close button ── */
.cnc-toast__close {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: #999;
  font-size: 16px;
  cursor: pointer;
  border-radius: 4px;
  transition: all 0.15s ease;
  padding: 0;
  line-height: 1;
  margin-top: 2px;
}

.cnc-toast__close:hover {
  background: rgba(0,0,0,0.08);
  color: #333;
}

/* ── Progress bar (auto-dismiss timer) ── */
.cnc-toast__progress {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 3px;
  background: currentColor;
  opacity: 0.3;
  border-radius: 0 0 0 var(--toast-radius);
  transition: width linear;
}

.cnc-toast--success .cnc-toast__progress { background: var(--toast-success); }
.cnc-toast--error   .cnc-toast__progress { background: var(--toast-error); }
.cnc-toast--warning .cnc-toast__progress { background: var(--toast-warning); }
.cnc-toast--info    .cnc-toast__progress { background: var(--toast-info); }

/* ── Animations ── */
@keyframes toastSlideIn {
  0%   { opacity: 0; transform: translateX(100%); }
  100% { opacity: 1; transform: translateX(0); }
}

@keyframes toastSlideOut {
  0%   { opacity: 1; transform: translateX(0); max-height: 200px; margin-bottom: 0; }
  50%  { opacity: 0; transform: translateX(100%); max-height: 200px; margin-bottom: 0; }
  100% { opacity: 0; transform: translateX(100%); max-height: 0; margin-bottom: -12px; padding: 0; }
}

.cnc-toast--exiting {
  animation: toastSlideOut 0.35s cubic-bezier(0.4, 0, 1, 1) forwards;
  pointer-events: none;
}

/* ── Shake animation for errors ── */
@keyframes toastShake {
  0%, 100% { transform: translateX(0); }
  10%, 50%, 90% { transform: translateX(-6px); }
  30%, 70% { transform: translateX(6px); }
}

.cnc-toast--error.cnc-toast--entering {
  animation: toastSlideIn 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards,
             toastShake 0.5s 0.4s ease;
}

/* ── Confirm Dialog (replaces window.confirm) ── */
#cnc-confirm-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(4px);
  z-index: 100000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  animation: confirmFadeIn 0.25s ease forwards;
}

#cnc-confirm-overlay.cnc-confirm--exiting {
  animation: confirmFadeOut 0.2s ease forwards;
}

.cnc-confirm {
  background: #fff;
  border-radius: 16px;
  padding: 28px 32px;
  max-width: 400px;
  width: 90%;
  box-shadow: 0 24px 80px rgba(0,0,0,0.2), 0 8px 24px rgba(0,0,0,0.1);
  transform: scale(0.9) translateY(20px);
  animation: confirmScaleIn 0.3s cubic-bezier(0.16, 1, 0.3, 1) 0.1s forwards;
  opacity: 0;
  text-align: center;
}

.cnc-confirm__icon {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
  font-size: 24px;
  color: #fff;
}

.cnc-confirm__icon--warning { background: var(--toast-warning); }
.cnc-confirm__icon--error   { background: var(--toast-error); }
.cnc-confirm__icon--info    { background: var(--toast-info); }

.cnc-confirm__title {
  font-size: 18px;
  font-weight: 700;
  color: #1a1a2e;
  margin: 0 0 8px;
}

.cnc-confirm__message {
  font-size: 14px;
  color: #555;
  margin: 0 0 24px;
  line-height: 1.5;
}

.cnc-confirm__actions {
  display: flex;
  gap: 12px;
  justify-content: center;
}

.cnc-confirm__btn {
  padding: 10px 24px;
  border-radius: 8px;
  border: none;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  min-width: 100px;
}

.cnc-confirm__btn--cancel {
  background: #f0f2f1;
  color: #555;
}

.cnc-confirm__btn--cancel:hover {
  background: #e0e2e1;
}

.cnc-confirm__btn--confirm {
  background: var(--toast-success);
  color: #fff;
}

.cnc-confirm__btn--confirm:hover {
  background: #2d4a41;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(66,105,93,0.3);
}

.cnc-confirm__btn--danger {
  background: var(--toast-error);
  color: #fff;
}

.cnc-confirm__btn--danger:hover {
  background: #b71c1c;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(198,40,40,0.3);
}

@keyframes confirmFadeIn {
  to { opacity: 1; }
}

@keyframes confirmFadeOut {
  to { opacity: 0; }
}

@keyframes confirmScaleIn {
  to { opacity: 1; transform: scale(1) translateY(0); }
}

/* ── Responsive ── */
@media (max-width: 576px) {
  #cnc-toast-container {
    right: 12px;
    left: 12px;
    bottom: 12px;
  }
  .cnc-toast {
    min-width: unset;
    max-width: 100%;
  }
}
