/**
 * QCC Modal System Styles
 * Enhanced Bootstrap 5 modal styling for the QCC design system
 */

/* Modal Base Styles */
.modal-content {
  border: none;
  border-radius: 0.75rem;
  box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
  overflow: hidden;
}

.modal-header {
  background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
  padding: 1.5rem 1.5rem 1rem;
  border-bottom: 1px solid #e9ecef;
}

.modal-title {
  font-weight: 600;
  color: #1e2f49;
  display: flex;
  align-items: center;
  font-size: 1.125rem;
}

.modal-title i {
  font-size: 1.25rem;
}

.modal-body {
  padding: 1.5rem;
  color: #495057;
  line-height: 1.6;
}

.modal-footer {
  padding: 1rem 1.5rem 1.5rem;
  background: #f8f9fa;
  border-top: 1px solid #e9ecef;
  justify-content: flex-end;
  gap: 0.75rem;
}

/* Button Styles */
.modal .btn {
  border-radius: 0.375rem;
  font-weight: 500;
  padding: 0.5rem 1rem;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  transition: all 0.2s ease-in-out;
}

.modal .btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.modal .btn:active {
  transform: translateY(0);
}

.modal .btn-primary {
  background: linear-gradient(135deg, #007bff 0%, #0056b3 100%);
  border: none;
  color: white;
}

.modal .btn-primary:hover,
.modal .btn-primary:focus {
  background: linear-gradient(135deg, #0056b3 0%, #004085 100%);
  color: white;
}

.modal .btn-secondary {
  background: linear-gradient(135deg, #6c757d 0%, #545b62 100%);
  border: none;
  color: white;
}

.modal .btn-secondary:hover,
.modal .btn-secondary:focus {
  background: linear-gradient(135deg, #545b62 0%, #495057 100%);
  color: white;
}

.modal .btn-danger {
  background: linear-gradient(135deg, #dc3545 0%, #c82333 100%);
  border: none;
  color: white;
}

.modal .btn-danger:hover,
.modal .btn-danger:focus {
  background: linear-gradient(135deg, #c82333 0%, #a71e2a 100%);
  color: white;
}

.modal .btn-success {
  background: linear-gradient(135deg, #28a745 0%, #1e7e34 100%);
  border: none;
  color: white;
}

.modal .btn-success:hover,
.modal .btn-success:focus {
  background: linear-gradient(135deg, #1e7e34 0%, #155724 100%);
  color: white;
}

.modal .btn-warning {
  background: linear-gradient(135deg, #ffc107 0%, #d39e00 100%);
  border: none;
  color: #212529;
}

.modal .btn-warning:hover,
.modal .btn-warning:focus {
  background: linear-gradient(135deg, #d39e00 0%, #b68500 100%);
  color: #212529;
}

.modal .btn-info {
  background: linear-gradient(135deg, #17a2b8 0%, #117a8b 100%);
  border: none;
  color: white;
}

.modal .btn-info:hover,
.modal .btn-info:focus {
  background: linear-gradient(135deg, #117a8b 0%, #0c5460 100%);
  color: white;
}

/* Close button */
.modal .btn-close {
  opacity: 0.5;
  transition: opacity 0.2s ease-in-out;
}

.modal .btn-close:hover {
  opacity: 0.8;
}

/* Form elements in modals */
.modal .form-control {
  border-radius: 0.375rem;
  border: 1px solid #ced4da;
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  transition: border-color 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
}

.modal .form-control:focus {
  border-color: #007bff;
  box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

.modal .form-label {
  font-weight: 500;
  color: #495057;
  margin-bottom: 0.5rem;
}

/* Alert styles within modals */
.modal .alert {
  border-radius: 0.375rem;
  border: none;
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
}

.modal .alert-warning {
  background: rgba(255, 193, 7, 0.1);
  color: #856404;
  border-left: 4px solid #ffc107;
}

.modal .alert-danger {
  background: rgba(220, 53, 69, 0.1);
  color: #721c24;
  border-left: 4px solid #dc3545;
}

.modal .alert-success {
  background: rgba(40, 167, 69, 0.1);
  color: #155724;
  border-left: 4px solid #28a745;
}

.modal .alert-info {
  background: rgba(23, 162, 184, 0.1);
  color: #0c5460;
  border-left: 4px solid #17a2b8;
}

/* Animation enhancements */
.modal.fade .modal-dialog {
  transform: translate(0, -50px);
  transition: transform 0.3s ease-out;
}

.modal.show .modal-dialog {
  transform: translate(0, 0);
}

/* Responsive adjustments */
@media (max-width: 576px) {
  .modal-dialog {
    margin: 0.5rem;
    max-width: calc(100% - 1rem);
  }
  
  .modal-header,
  .modal-body,
  .modal-footer {
    padding-left: 1rem;
    padding-right: 1rem;
  }
  
  .modal-footer {
    flex-direction: column;
    gap: 0.5rem;
  }
  
  .modal-footer .btn {
    width: 100%;
    justify-content: center;
  }
}

/* Dark theme support */
@media (prefers-color-scheme: dark) {
  .modal-content {
    background-color: #2d3748;
    color: #e2e8f0;
  }
  
  .modal-header {
    background: linear-gradient(135deg, #2d3748 0%, #1a202c 100%);
    border-bottom-color: #4a5568;
  }
  
  .modal-title {
    color: #e2e8f0;
  }
  
  .modal-footer {
    background: #2d3748;
    border-top-color: #4a5568;
  }
  
  .modal .form-control {
    background-color: #4a5568;
    border-color: #718096;
    color: #e2e8f0;
  }
  
  .modal .form-control:focus {
    background-color: #4a5568;
    border-color: #4299e1;
    color: #e2e8f0;
  }
  
  .modal .form-label {
    color: #e2e8f0;
  }
}

/* QCC Theme overrides */
.qcc-theme-healthcare .modal-header {
  background: linear-gradient(135deg, #f0f8ff 0%, #e6f3ff 100%);
}

.qcc-theme-healthcare .modal-title {
  color: #1e40af;
}

.qcc-theme-healthcare .modal .btn-primary {
  background: linear-gradient(135deg, #1e40af 0%, #1e3a8a 100%);
}

.qcc-theme-healthcare .modal .btn-primary:hover,
.qcc-theme-healthcare .modal .btn-primary:focus {
  background: linear-gradient(135deg, #1e3a8a 0%, #1e3a8a 100%);
}

/* Accessibility enhancements */
.modal {
  --bs-modal-zindex: 1055;
}

.modal-backdrop {
  backdrop-filter: blur(2px);
}

/* Focus management */
.modal:not(.show) .modal-dialog {
  pointer-events: none;
}

.modal.show .modal-dialog {
  pointer-events: auto;
}

/* Loading state for buttons */
.modal .btn[data-loading="true"] {
  position: relative;
  color: transparent !important;
  pointer-events: none;
}

.modal .btn[data-loading="true"]:before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 1rem;
  height: 1rem;
  margin-top: -0.5rem;
  margin-left: -0.5rem;
  border: 2px solid currentColor;
  border-radius: 50%;
  border-top-color: transparent;
  animation: btn-loading-spin 0.75s linear infinite;
}

@keyframes btn-loading-spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  .modal-content {
    border: 2px solid #000;
  }
  
  .modal .btn {
    border: 2px solid currentColor;
  }
  
  .modal .form-control {
    border: 2px solid #000;
  }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
  .modal.fade .modal-dialog {
    transition: none;
  }
  
  .modal .btn {
    transition: none;
  }
  
  @keyframes btn-loading-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
  }
}