/**
 * Custom Modal Styles
 * 
 * Modern, accessible modal dialogs that match the app's design system.
 * Works consistently across all modern browsers and tablets.
 */

/* Overlay */
.modal-overlay {
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0);
  backdrop-filter: blur(0px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  opacity: 0;
  visibility: hidden;
  transition: all 0.2s ease-out;
  padding: 1rem;
}

.modal-overlay.visible {
  opacity: 1;
  visibility: visible;
  background-color: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
}

/* Modal Container */
.modal-container {
  width: 100%;
  max-width: 400px;
  pointer-events: none;
}

/* Modal Dialog */
.modal-dialog {
  background: white;
  border-radius: 16px;
  box-shadow: 
    0 25px 50px -12px rgba(0, 0, 0, 0.25),
    0 0 0 1px rgba(0, 0, 0, 0.05);
  transform: scale(0.95) translateY(-10px);
  opacity: 0;
  transition: all 0.2s ease-out;
  pointer-events: auto;
  overflow: hidden;
}

.modal-dialog.visible {
  transform: scale(1) translateY(0);
  opacity: 1;
}

/* Modal Content */
.modal-content {
  padding: 1.5rem;
  text-align: center;
}

/* Modal Icon */
.modal-icon {
  width: 56px;
  height: 56px;
  margin: 0 auto 1rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-icon svg {
  width: 28px;
  height: 28px;
}

.modal-icon.info {
  background-color: #dbeafe;
  color: #2563eb;
}

.modal-icon.success {
  background-color: #dcfce7;
  color: #16a34a;
}

.modal-icon.error {
  background-color: #fee2e2;
  color: #dc2626;
}

.modal-icon.warning {
  background-color: #fef3c7;
  color: #d97706;
}

.modal-icon.question {
  background-color: #e0e7ff;
  color: #4f46e5;
}

.modal-icon.edit {
  background-color: #f3e8ff;
  color: #9333ea;
}

/* Modal Title */
.modal-title {
  font-size: 1.125rem;
  font-weight: 600;
  color: #111827;
  margin: 0 0 0.5rem;
  line-height: 1.4;
}

/* Modal Message */
.modal-message {
  font-size: 0.9375rem;
  color: #6b7280;
  margin: 0 0 1.25rem;
  line-height: 1.5;
}

/* Modal Input */
.modal-input-wrapper {
  margin-bottom: 1.25rem;
}

.modal-input {
  width: 100%;
  padding: 0.75rem 1rem;
  font-size: 0.9375rem;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  background-color: #f9fafb;
  color: #111827;
  transition: all 0.15s ease;
  outline: none;
  box-sizing: border-box;
}

.modal-input:focus {
  border-color: #2563eb;
  background-color: white;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.modal-input.modal-input-error {
  border-color: #dc2626;
  background-color: #fef2f2;
}

.modal-input.modal-input-error:focus {
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.1);
}

.modal-input::placeholder {
  color: #9ca3af;
}

/* Modal Buttons */
.modal-buttons {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
}

.modal-btn {
  flex: 1;
  max-width: 140px;
  padding: 0.625rem 1.25rem;
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  transition: all 0.15s ease;
  outline: none;
}

.modal-btn:focus-visible {
  box-shadow: 0 0 0 2px white, 0 0 0 4px #2563eb;
}

.modal-btn-primary {
  background-color: #2563eb;
  color: white;
}

.modal-btn-primary:hover {
  background-color: #1d4ed8;
}

.modal-btn-primary:active {
  background-color: #1e40af;
}

.modal-btn-secondary {
  background-color: #f3f4f6;
  color: #374151;
}

.modal-btn-secondary:hover {
  background-color: #e5e7eb;
}

.modal-btn-secondary:active {
  background-color: #d1d5db;
}

.modal-btn-danger {
  background-color: #dc2626;
  color: white;
}

.modal-btn-danger:hover {
  background-color: #b91c1c;
}

.modal-btn-danger:active {
  background-color: #991b1b;
}

/* Responsive Adjustments - Mobile (2025 Standards) */
@media (max-width: 480px) {
  .modal-overlay {
    padding: 0.75rem;
  }

  .modal-container {
    max-width: 100%;
  }

  .modal-content {
    padding: 1.5rem 1.25rem;
  }

  .modal-icon {
    width: 52px;
    height: 52px;
    margin-bottom: 1.25rem;
  }

  .modal-icon svg {
    width: 26px;
    height: 26px;
  }

  .modal-title {
    font-size: 1.125rem;
    margin-bottom: 0.625rem;
  }

  .modal-message {
    font-size: 0.9375rem;
    line-height: 1.5;
    margin-bottom: 1.5rem;
  }

  /* Input - larger for mobile */
  .modal-input {
    min-height: 48px;
    padding: 0.875rem 1rem;
    font-size: 16px; /* Prevents iOS zoom */
    border-radius: 12px;
  }

  .modal-input-wrapper {
    margin-bottom: 1.5rem;
  }

  .modal-buttons {
    flex-direction: column-reverse;
    gap: 0.75rem;
  }

  .modal-btn {
    max-width: none;
    width: 100%;
    min-height: 48px;
    padding: 0.875rem 1.5rem;
    font-size: 1rem;
    font-weight: 600;
    border-radius: 12px;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
  }
  
  /* Active state for touch feedback */
  .modal-btn:active {
    transform: scale(0.98);
    opacity: 0.9;
  }
}

/* Tablet optimizations */
@media (min-width: 481px) and (max-width: 1024px) {
  .modal-container {
    max-width: 360px;
  }
}

/* Animation preference */
@media (prefers-reduced-motion: reduce) {
  .modal-overlay,
  .modal-dialog {
    transition: none;
  }
}

/* Print - hide modals */
@media print {
  .modal-overlay {
    display: none !important;
  }
}
