/* ===== Toast Notifications ===== */
.toast-container {
  position: fixed;
  top: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  z-index: 10000;
  pointer-events: none;
}

.toast {
  padding: 16px 24px;
  border-radius: var(--radius);
  font-weight: 500;
  font-size: 14px;
  box-shadow: var(--shadow-lg);
  animation: toastIn 0.3s ease, toastOut 0.3s ease 3.7s forwards;
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: 400px;
}

.toast.success {
  background: linear-gradient(135deg, #10b981, #059669);
  color: #fff;
}

.toast.error {
  background: linear-gradient(135deg, #ef4444, #dc2626);
  color: #fff;
}

.toast.info {
  background: linear-gradient(135deg, #6366f1, #4f46e5);
  color: #fff;
}

.toast-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

@keyframes toastIn {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes toastOut {
  from {
    opacity: 1;
  }
  to {
    opacity: 0;
    transform: translateX(100%);
  }
}


/* ===== Modal Styles ===== */
/* IMPORTANT: Modal visibility is primarily controlled via JavaScript inline styles.
   CSS provides the base layout and transitions, but JS controls display/visibility. */

.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  /* Use flexbox for centering - display controlled by JS */
  align-items: center;
  justify-content: center;
  z-index: 9999; /* Higher z-index to ensure it's on top */
  /* Initial hidden state - JS will override these */
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

/* When active class is added by JS */
.modal-overlay.active {
  display: flex;
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

/* Ensure body doesn't scroll when modal is open */
body.modal-open {
  overflow: hidden !important;
}

.modal {
  background: var(--card);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  max-width: 640px;
  width: 92%;
  max-height: 90vh;
  overflow: auto;
  transform: scale(0.95) translateY(-20px);
  transition: transform 0.2s ease;
  /* Ensure modal content is always interactive when visible */
  pointer-events: auto;
}

.modal-overlay.active .modal {
  transform: scale(1) translateY(0);
}

.modal-content {
  background: var(--card);
  border-radius: var(--radius-xl);
  padding: 28px;
  box-shadow: var(--shadow-xl);
  max-height: 90vh;
  overflow-y: auto;
  width: 100%;
  transform: scale(0.95) translateY(-20px);
  transition: transform 0.2s ease;
  pointer-events: auto;
}

.modal-overlay.active .modal-content {
  transform: scale(1) translateY(0);
}

/* Header inside modal-content: avoid double horizontal padding */
.modal-content > .modal-header {
  padding: 0 0 16px;
  border-bottom: 1px solid var(--border-light);
  margin-bottom: 20px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 28px;
  border-bottom: 1px solid var(--border-light);
}

.modal-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.modal-header h2 {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
}

.edit-modal-checkbox input[type="checkbox"] {
  width: 24px;
  height: 24px;
}

.edit-modal-dates {
  display: flex;
  flex-direction: column;
  gap: 1px;
  margin-left: 4px;
}

.edit-modal-dates span {
  font-size: 11px;
  font-weight: 400;
  color: var(--muted);
  line-height: 1.3;
  white-space: nowrap;
}

.edit-modal-dates span:empty {
  display: none;
}

.modal-close,
.modal-close-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 8px;
  border-radius: var(--radius);
  color: var(--muted);
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  line-height: 1;
}

.modal-close:hover,
.modal-close-btn:hover {
  background: var(--bg);
  color: var(--text);
}

.modal-body {
  padding: 12px 28px 28px;
}

.modal-body .form-grid {
  margin-top: 0;
  gap: 12px;
}

.modal .grid {
  grid-template-columns: 1fr auto;
  gap: 12px;
  margin-bottom: 12px;
}

@media (max-width: 500px) {
  .modal .grid {
    grid-template-columns: 1fr;
  }
}



.todo-unsaved-dialog {
  max-width: 480px;
  overflow: hidden;
}

.todo-unsaved-dialog-header {
  padding: 24px 28px 16px;
}

.todo-unsaved-dialog-header h3 {
  margin: 0;
  font-size: clamp(1.5rem, 1.8vw, 1.95rem);
  line-height: 1.2;
  letter-spacing: -0.01em;
}

.todo-unsaved-dialog-body {
  padding: 18px 28px;
}

.todo-unsaved-dialog-body p {
  margin: 0;
  font-size: 1.15rem;
  line-height: 1.5;
  color: var(--text-secondary);
}

.todo-unsaved-dialog-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 18px 28px 24px;
  border-top: 1px solid var(--border-light);
  background: linear-gradient(180deg, rgba(99, 102, 241, 0.04), rgba(99, 102, 241, 0));
}

.todo-unsaved-dialog-btn {
  min-width: 132px;
}

@media (max-width: 620px) {
  .todo-unsaved-dialog {
    width: min(92vw, 480px);
  }

  .todo-unsaved-dialog-footer {
    flex-wrap: wrap;
  }

  .todo-unsaved-dialog-btn {
    flex: 1;
    min-width: 0;
  }
}
