/* public/css/toast.css - Modern Animated Toast Notification System */

#toast-container {
  position: fixed;
  top: max(20px, calc(12px + env(safe-area-inset-top, 0px)));
  right: max(20px, env(safe-area-inset-right, 0px));
  z-index: 999999;
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-width: 420px;
  width: calc(100vw - 36px);
  pointer-events: none;
}

.custom-toast {
  pointer-events: auto;
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px 16px 16px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.94);
  color: #0f172a;
  box-shadow: 0 14px 35px -6px rgba(0, 0, 0, 0.16), 0 4px 12px -2px rgba(0, 0, 0, 0.08);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-left-width: 5px;
  overflow: hidden;
  box-sizing: border-box;
  animation: toastSlideIn 0.35s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  user-select: none;
}

[data-bs-theme="dark"] .custom-toast {
  background: rgba(30, 41, 59, 0.94);
  color: #f8fafc;
  border-color: rgba(255, 255, 255, 0.1);
  border-left-width: 5px;
  box-shadow: 0 16px 36px -6px rgba(0, 0, 0, 0.45), 0 4px 14px -2px rgba(0, 0, 0, 0.3);
}

.custom-toast:hover {
  transform: translateY(-2px);
  box-shadow: 0 18px 40px -6px rgba(0, 0, 0, 0.22);
}

/* Exit animation applied when dismissed */
.custom-toast.toast-closing {
  animation: toastSlideOut 0.32s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

/* Toast Type Variants */
.custom-toast.toast-success {
  border-left-color: #10b981;
}
.custom-toast.toast-success .toast-icon {
  background: rgba(16, 185, 129, 0.15);
  color: #10b981;
}
.custom-toast.toast-success .toast-progress-bar {
  background: linear-gradient(90deg, #10b981, #34d399);
}

.custom-toast.toast-error {
  border-left-color: #f43f5e;
}
.custom-toast.toast-error .toast-icon {
  background: rgba(244, 63, 94, 0.15);
  color: #f43f5e;
}
.custom-toast.toast-error .toast-progress-bar {
  background: linear-gradient(90deg, #f43f5e, #fb7185);
}

.custom-toast.toast-warning {
  border-left-color: #f59e0b;
}
.custom-toast.toast-warning .toast-icon {
  background: rgba(245, 158, 11, 0.15);
  color: #f59e0b;
}
.custom-toast.toast-warning .toast-progress-bar {
  background: linear-gradient(90deg, #f59e0b, #fbbf24);
}

.custom-toast.toast-info {
  border-left-color: #6366f1;
}
.custom-toast.toast-info .toast-icon {
  background: rgba(99, 102, 241, 0.15);
  color: #6366f1;
}
.custom-toast.toast-info .toast-progress-bar {
  background: linear-gradient(90deg, #6366f1, #818cf8);
}

/* Icon Container */
.toast-icon {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
}

/* Content Area */
.toast-content {
  flex: 1;
  min-width: 0;
}

.toast-title {
  font-size: 0.92rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin-bottom: 3px;
  line-height: 1.25;
}

.toast-message {
  font-size: 0.84rem;
  line-height: 1.45;
  color: #64748b;
  word-break: break-word;
}

[data-bs-theme="dark"] .toast-message {
  color: #94a3b8;
}

/* Close Button */
.toast-close-btn {
  flex-shrink: 0;
  background: transparent;
  border: none;
  color: #94a3b8;
  cursor: pointer;
  padding: 2px 4px;
  font-size: 0.85rem;
  line-height: 1;
  border-radius: 6px;
  transition: color 0.15s ease, background-color 0.15s ease, transform 0.15s ease;
}

.toast-close-btn:hover {
  color: #0f172a;
  background: rgba(0, 0, 0, 0.06);
  transform: rotate(90deg);
}

[data-bs-theme="dark"] .toast-close-btn:hover {
  color: #f8fafc;
  background: rgba(255, 255, 255, 0.1);
}

/* Bottom Progress Bar */
.toast-progress-track {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 3.5px;
  background: rgba(0, 0, 0, 0.05);
}

[data-bs-theme="dark"] .toast-progress-track {
  background: rgba(255, 255, 255, 0.06);
}

.toast-progress-bar {
  height: 100%;
  width: 100%;
  transform-origin: left;
  animation: toastProgress linear forwards;
}

.custom-toast.toast-paused .toast-progress-bar {
  animation-play-state: paused;
}

/* Keyframes */
@keyframes toastSlideIn {
  0% {
    transform: translateX(115%) scale(0.9);
    opacity: 0;
  }
  60% {
    transform: translateX(-4px) scale(1.01);
    opacity: 1;
  }
  100% {
    transform: translateX(0) scale(1);
    opacity: 1;
  }
}

@keyframes toastSlideOut {
  0% {
    transform: translateX(0) scale(1);
    opacity: 1;
    max-height: 160px;
    margin-bottom: 12px;
  }
  40% {
    transform: translateX(-10px) scale(0.98);
    opacity: 0.9;
  }
  100% {
    transform: translateX(120%) scale(0.85);
    opacity: 0;
    max-height: 0;
    margin-bottom: 0;
    padding-top: 0;
    padding-bottom: 0;
    border-width: 0;
  }
}

@keyframes toastProgress {
  0% {
    transform: scaleX(1);
  }
  100% {
    transform: scaleX(0);
  }
}

/* Prompt / input dialog (replaces window.prompt) */
#app-prompt-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(16px, env(safe-area-inset-top, 0px)) 16px max(16px, env(safe-area-inset-bottom, 0px));
  background: rgba(15, 23, 42, 0.48);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  animation: promptFadeIn 0.2s ease forwards;
}

#app-prompt-overlay.prompt-closing {
  animation: promptFadeOut 0.18s ease forwards;
}

.app-prompt-card {
  width: min(440px, 100%);
  background: rgba(255, 255, 255, 0.97);
  color: #0f172a;
  border-radius: 16px;
  border: 1px solid rgba(0, 0, 0, 0.08);
  box-shadow: 0 24px 48px -12px rgba(0, 0, 0, 0.28);
  padding: 20px 20px 16px;
  animation: promptPopIn 0.28s cubic-bezier(0.16, 1, 0.3, 1);
}

[data-bs-theme="dark"] .app-prompt-card {
  background: rgba(30, 41, 59, 0.97);
  color: #f8fafc;
  border-color: rgba(255, 255, 255, 0.1);
  box-shadow: 0 24px 48px -12px rgba(0, 0, 0, 0.55);
}

.app-prompt-card.prompt-shake {
  animation: promptShake 0.35s ease;
}

.app-prompt-title {
  font-size: 1.02rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin-bottom: 6px;
}

.app-prompt-message {
  font-size: 0.88rem;
  line-height: 1.45;
  color: #64748b;
  margin-bottom: 14px;
  white-space: pre-wrap;
  word-break: break-word;
}

[data-bs-theme="dark"] .app-prompt-message {
  color: #94a3b8;
}

.app-prompt-input,
.app-prompt-textarea {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid rgba(15, 23, 42, 0.14);
  border-radius: 10px;
  padding: 11px 12px;
  font-size: 0.95rem;
  font-family: inherit;
  color: inherit;
  background: rgba(248, 250, 252, 0.9);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.app-prompt-textarea {
  min-height: 96px;
  resize: vertical;
}

[data-bs-theme="dark"] .app-prompt-input,
[data-bs-theme="dark"] .app-prompt-textarea {
  background: rgba(15, 23, 42, 0.55);
  border-color: rgba(255, 255, 255, 0.12);
}

.app-prompt-input:focus,
.app-prompt-textarea:focus {
  border-color: #6366f1;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.22);
}

.app-prompt-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 14px;
}

.app-prompt-btn {
  border: none;
  border-radius: 10px;
  padding: 8px 14px;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}

.app-prompt-btn-cancel {
  background: rgba(15, 23, 42, 0.06);
  color: #334155;
}

[data-bs-theme="dark"] .app-prompt-btn-cancel {
  background: rgba(255, 255, 255, 0.08);
  color: #e2e8f0;
}

.app-prompt-btn-ok {
  background: #5c3d2e;
  color: #fff;
}

[data-bs-theme="dark"] .app-prompt-btn-ok {
  background: #c4a484;
  color: #1c1410;
}

.app-prompt-btn-danger {
  background: #b42318;
  color: #fff;
}

[data-bs-theme="dark"] .app-prompt-btn-danger {
  background: #f97066;
  color: #1c1410;
}

.app-prompt-check {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 0 0 2px;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(15, 23, 42, 0.05);
  cursor: pointer;
}

[data-bs-theme="dark"] .app-prompt-check {
  background: rgba(255, 255, 255, 0.06);
}

.app-prompt-check input {
  margin-top: 3px;
  flex-shrink: 0;
}

.app-prompt-check-text {
  font-size: 0.86rem;
  line-height: 1.4;
}

.app-prompt-check-hint {
  display: block;
  margin-top: 3px;
  font-size: 0.75rem;
  color: #64748b;
}

[data-bs-theme="dark"] .app-prompt-check-hint {
  color: #94a3b8;
}

@keyframes promptFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes promptFadeOut {
  from { opacity: 1; }
  to { opacity: 0; }
}

@keyframes promptPopIn {
  from { transform: translateY(10px) scale(0.96); opacity: 0; }
  to { transform: translateY(0) scale(1); opacity: 1; }
}

@keyframes promptShake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}

/* Responsive adjustments for mobile screens */
@media (max-width: 480px) {
  #toast-container {
    top: max(14px, calc(8px + env(safe-area-inset-top, 0px)));
    right: max(14px, env(safe-area-inset-right, 0px));
    left: max(14px, env(safe-area-inset-left, 0px));
    width: auto;
    max-width: none;
  }
  .custom-toast {
    padding: 12px 14px 14px 14px;
  }
}
