.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(17, 24, 39, 0.5);
  z-index: 999;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

.modal-card {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: var(--panel);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  max-width: 800px;
  width: calc(100% - 48px);
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  animation: slideUp 0.3s ease;
  z-index: 1000;
}

/* Modal size variants */
.modal-card.modal-large {
  max-width: 1400px;
}

.modal-card.modal-medium {
  max-width: 800px;
}

.modal-card.modal-small {
  max-width: 500px;
}

@keyframes slideUp {
  from {
    transform: translate(-50%, calc(-50% + 20px));
    opacity: 0;
  }

  to {
    transform: translate(-50%, -50%);
    opacity: 1;
  }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 22px 24px;
  border-bottom: 1px solid var(--line);
  gap: 16px;
}

.modal-header h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 800;
  color: var(--text);
}

.modal-close {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  padding: 0;
  color: #6b7280;
  transition: color 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
}

.modal-close:hover {
  color: var(--text);
}

.modal-form {
  padding: 18px 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.modal-form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  align-items: start;
}

.add-campaign-modal .modal-form-grid {
  align-items: stretch;
}

.form-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
  background: #f9fbfd;
  border-radius: 12px;
  border: 1px solid #e5e7eb;
}

.add-campaign-modal .form-section {
  height: 100%;
}

.add-campaign-modal .form-section textarea {
  min-height: 110px;
}

.form-section.full-width {
  grid-column: 1 / -1;
}

.form-section h3 {
  margin: 0 0 8px 0;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  color: #6b7280;
  letter-spacing: 0.05em;
}

.form-section label {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-section label span {
  display: block;
  font-weight: 600;
  color: var(--text);
  font-size: 13px;
}

.form-section input,
.form-section textarea,
.form-section select {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid #d1d5db;
  border-radius: 12px;
  background: #fff;
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  transition: border-color 0.2s ease;
}

.form-section input:focus,
.form-section textarea:focus,
.form-section select:focus {
  outline: none;
  border-color: #0f172a;
  box-shadow: 0 0 0 3px rgba(15, 23, 42, 0.1);
}

.form-section input.input-invalid,
.form-section textarea.input-invalid {
  border-color: #dc2626;
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.12);
}

.form-section textarea {
  resize: vertical;
  min-height: 70px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.form-row.three-col {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.form-row label {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field-error {
  color: #b91c1c;
  font-size: 12px;
  line-height: 1.3;
}

.form-error {
  background: #fee2e2;
  border: 1px solid #fecaca;
  color: #b91c1c;
  padding: 12px 14px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 500;
}

.modal-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  padding: 12px 24px 18px 24px;
  border-top: 1px solid var(--line);
  background: var(--panel);
  position: sticky;
  bottom: 0;
}

.modal-actions button {
  padding: 10px 16px;
  font-weight: 600;
  font-size: 13px;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.modal-actions .btn.primary {
  background: linear-gradient(135deg, var(--cyan), var(--pink));
  color: var(--text);
}

.modal-actions .btn.primary:hover:not(:disabled) {
  box-shadow: 0 8px 16px rgba(37, 244, 238, 0.3);
}

.modal-actions .btn.ghost {
  background: #f3f4f6;
  color: #374151;
  border: none;
}

.modal-actions .btn.ghost:hover:not(:disabled) {
  background: #e5e7eb;
}

.modal-actions button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

@media (max-width: 980px) {
  .modal-card {
    width: calc(100% - 24px);
    max-height: calc(100vh - 24px);
  }

  .modal-form-grid {
    grid-template-columns: 1fr;
  }

  .form-section.full-width {
    grid-column: auto;
  }

  .form-row,
  .form-row.three-col {
    grid-template-columns: 1fr;
  }
}

/* Compact modal variant + icon styles */
.modal-card.compact {
  max-width: 520px;
  width: min(92%, 520px);
  border-radius: 12px;
}

.modal-header {
  align-items: center;
}

.modal-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 8px;
  font-size: 18px;
  margin-right: 12px;
  flex-shrink: 0;
}

.modal-icon.info {
  background: #ecfeff;
  color: #065f46;
  border: 1px solid #a7f3d0;
}

.modal-icon.success {
  background: #ecfdf5;
  color: #065f46;
  border: 1px solid #86efac;
}

.modal-icon.warning {
  background: #fffbeb;
  color: #92400e;
  border: 1px solid #fcd34d;
}

.modal-icon.error {
  background: #fff1f2;
  color: #9f1239;
  border: 1px solid #fecaca;
}

/* Tighter paddings for compact modals */
.modal-card.compact .modal-header {
  padding: 12px 16px;
}

.modal-card.compact .modal-form {
  padding: 12px 16px;
  gap: 12px;
}

.modal-card.compact .modal-actions {
  padding: 10px 16px 12px 16px;
}

/* Alternative modal structure for simple forms */
.modal-content {
  background: #fff;
  border-radius: var(--radius-lg);
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  width: 100%;
  max-width: 500px;
}

.modal-body {
  padding: 18px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}

.form-group label {
  font-size: 13px;
  font-weight: 600;
  color: #0f172a;
  display: inline-block;
  white-space: nowrap;
}

.required {
  display: inline;
  color: #dc2626;
  font-weight: 600;
  margin-left: 2px;
}

.input-text,
.form-group input {
  border: 1px solid #d5deea;
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font-size: 13px;
  font-family: inherit;
}

.input-text:focus,
.form-group input:focus {
  outline: none;
  border-color: #06b6d4;
  box-shadow: 0 0 0 3px rgba(6, 182, 212, 0.1);
}

/* Numeric input styling */
.input-text.numeric,
input.numeric[inputmode="numeric"] {
  font-family: inherit;
  text-align: right;
}

.input-text.numeric::placeholder,
input.numeric[inputmode="numeric"]::placeholder {
  text-align: right;
  opacity: 0.6;
}

.modal-actions.flat {
  padding: 12px 16px;
  justify-content: flex-end;
  border: none;
  background: none;
}

/* Notification/Toast Popup Styles */
.notification-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 9999;
  max-width: 400px;
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  pointer-events: none;
}

.notification {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  margin-bottom: 10px;
  border-radius: 12px;
  border-left: 4px solid;
  background: #fff;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  animation: slideIn 0.3s ease-out forwards;
  pointer-events: auto;
  font-size: 14px;
  line-height: 1.5;
  max-width: 400px;
  word-wrap: break-word;
}

/* Animation for notification entrance */
@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateX(400px);
  }

  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* Animation for notification exit */
@keyframes slideOut {
  from {
    opacity: 1;
    transform: translateX(0);
  }

  to {
    opacity: 0;
    transform: translateX(400px);
  }
}

.notification.closing {
  animation: slideOut 0.3s ease-in forwards;
}

/* Notification variants */
.notification.success {
  border-left-color: #10b981;
  background: #ecfdf5;
  color: #065f46;
}

.notification.success .notification-icon::before {
  content: '✓';
  color: #10b981;
  font-weight: bold;
  font-size: 18px;
}

.notification.error {
  border-left-color: #ef4444;
  background: #fff1f2;
  color: #7f1d1d;
}

.notification.error .notification-icon::before {
  content: '✕';
  color: #ef4444;
  font-weight: bold;
  font-size: 18px;
}

.notification.warning {
  border-left-color: #f59e0b;
  background: #fffbeb;
  color: #78350f;
}

.notification.warning .notification-icon::before {
  content: '⚠';
  color: #f59e0b;
  font-weight: bold;
  font-size: 16px;
}

.notification.info {
  border-left-color: #0ea5e9;
  background: #ecf7ff;
  color: #0c4a6e;
}

.notification.info .notification-icon::before {
  content: 'ℹ';
  color: #0ea5e9;
  font-weight: bold;
  font-size: 18px;
}

.notification-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  font-size: 14px;
}

.notification-content {
  flex: 1;
  word-break: break-word;
}

.notification-title {
  font-weight: 600;
  margin-bottom: 4px;
}

.notification-message {
  font-size: 13px;
  opacity: 0.9;
}

.notification-close {
  background: none;
  border: none;
  padding: 0;
  margin-left: 8px;
  cursor: pointer;
  font-size: 18px;
  color: currentColor;
  opacity: 0.6;
  transition: opacity 0.2s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.notification-close:hover {
  opacity: 1;
}

/* Responsive design for notifications */
@media (max-width: 640px) {
  .notification-container {
    left: 10px;
    right: 10px;
    max-width: none;
  }

  .notification {
    max-width: 100%;
  }
}