/**
 * ProRank Design System - Modal Components
 * 
 * Modal dialogs, overlays, and popup components.
 * Includes various modal sizes and types.
 * 
 * @module components/modals
 * @since 3.0.0
 */

/* ============================================
   MODAL OVERLAY
   Background overlay for modals
   ============================================ */

.prorank-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: var(--prorank-z-modal, 2000);
  padding: 20px;
  animation: fadeIn 0.2s ease-out;
}

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

/* Click outside to close */
.prorank-modal-overlay--closeable {
  cursor: pointer;
}

/* ============================================
   WORDPRESS MODAL COMPATIBILITY
   Styles for WordPress Modal component
   ============================================ */

.components-modal__screen-overlay {
  z-index: 100000 !important;
}

.components-modal__frame {
  z-index: 100001 !important;
}

/* ============================================
   BASE MODAL
   Core modal dialog styles
   ============================================ */

.prorank-modal {
  position: relative;
  background: white;
  border-radius: var(--prorank-radius);
  box-shadow: var(--prorank-shadow-lg);
  max-width: 600px;
  width: 100%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  animation: slideUp 0.3s ease-out;
  cursor: default;
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Prevent closing when clicking modal content */
.prorank-modal-overlay--closeable .prorank-modal {
  pointer-events: auto;
}

/* ============================================
   MODAL SIZES
   Different modal width presets
   ============================================ */

.prorank-modal--small {
  max-width: 400px;
}

.prorank-modal--medium {
  max-width: 600px;
}

.prorank-modal--large {
  max-width: 900px;
}

.prorank-modal--fullscreen {
  max-width: calc(100vw - 40px);
  max-height: calc(100vh - 40px);
  width: 100%;
  height: 100%;
}

/* ============================================
   MODAL STRUCTURE
   Header, body, and footer sections
   ============================================ */

/* Modal Header */
.prorank-modal-header {
  padding: 24px;
  border-bottom: 1px solid var(--prorank-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.prorank-modal-title {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
  color: var(--prorank-text);
  display: flex;
  align-items: center;
  gap: 12px;
}

.prorank-modal-subtitle {
  margin: 4px 0 0;
  font-size: 14px;
  color: var(--prorank-text-secondary);
}

/* Close Button */
.prorank-modal-close {
  background: none;
  border: none;
  font-size: 24px;
  color: var(--prorank-text-secondary);
  cursor: pointer;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: var(--prorank-transition);
}

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

/* Modal Body */
.prorank-modal-body {
  padding: 24px;
  flex: 1;
  overflow-y: auto;
}

.prorank-modal-body--flush {
  padding: 0;
}

/* Modal Footer */
.prorank-modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--prorank-border);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  flex-shrink: 0;
  background: var(--prorank-bg-secondary);
}

.prorank-modal-footer--left {
  justify-content: flex-start;
}

.prorank-modal-footer--center {
  justify-content: center;
}

.prorank-modal-footer--space-between {
  justify-content: space-between;
}

/* Footer Info Section */
.prorank-modal-footer-info {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--prorank-text-secondary);
  font-size: 13px;
}

/* Footer Actions */
.prorank-modal-footer-actions {
  display: flex;
  gap: 12px;
}

/* ============================================
   MODAL VARIANTS
   Different modal types and styles
   ============================================ */

/* Confirmation Modal */
.prorank-modal--confirm .prorank-modal-icon {
  width: 64px;
  height: 64px;
  margin: 0 auto 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-size: 32px;
}

.prorank-modal--confirm .prorank-modal-icon--warning {
  background: rgba(251, 191, 36, 0.1);
  color: var(--prorank-warning);
}

.prorank-modal--confirm .prorank-modal-icon--error {
  background: rgba(239, 68, 68, 0.1);
  color: var(--prorank-error);
}

.prorank-modal--confirm .prorank-modal-icon--success {
  background: rgba(16, 185, 129, 0.1);
  color: var(--prorank-success);
}

.prorank-modal--confirm .prorank-modal-icon--info {
  background: rgba(37, 99, 235, 0.1);
  color: var(--prorank-primary);
}

.prorank-modal--confirm .prorank-modal-body {
  text-align: center;
}

/* Task Modal */
.prorank-modal--task {
  background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
}

.prorank-modal--task .prorank-modal-header {
  background: var(--prorank-gradient);
  color: white;
  border: none;
}

.prorank-modal--task .prorank-modal-title {
  color: white;
}

.prorank-modal--task .prorank-modal-close {
  color: rgba(255, 255, 255, 0.8);
}

.prorank-modal--task .prorank-modal-close:hover {
  background: rgba(255, 255, 255, 0.1);
  color: white;
}

/* Premium Modal */
.prorank-modal--premium {
  border: 2px solid var(--prorank-pink);
  background: linear-gradient(135deg, #fef3ff 0%, #f3e8ff 100%);
}

.prorank-modal--premium .prorank-modal-header {
  background: linear-gradient(135deg, var(--prorank-pink) 0%, var(--prorank-accent) 100%);
  color: white;
  border: none;
}

.prorank-modal--premium .prorank-modal-title {
  color: white;
}

.prorank-modal--premium::before {
  content: 'PRO';
  position: absolute;
  top: 20px;
  right: 60px;
  background: white;
  color: var(--prorank-pink);
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
}

/* ============================================
   MODAL ANIMATIONS
   Entry and exit animations
   ============================================ */

.prorank-modal--slide-left {
  animation: slideLeft 0.3s ease-out;
}

@keyframes slideLeft {
  from {
    transform: translateX(100%);
  }
  to {
    transform: translateX(0);
  }
}

.prorank-modal--zoom {
  animation: zoomIn 0.2s ease-out;
}

@keyframes zoomIn {
  from {
    transform: scale(0.9);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

/* Exit animations */
.prorank-modal-overlay--closing {
  animation: fadeOut 0.2s ease-out forwards;
}

@keyframes fadeOut {
  to {
    opacity: 0;
  }
}

.prorank-modal-overlay--closing .prorank-modal {
  animation: slideDown 0.2s ease-out forwards;
}

@keyframes slideDown {
  to {
    transform: translateY(20px);
    opacity: 0;
  }
}

/* ============================================
   MODAL LOADING STATE
   Loading spinner for async content
   ============================================ */

.prorank-modal--loading .prorank-modal-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 200px;
}

.prorank-modal-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--prorank-border);
  border-top-color: var(--prorank-primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ============================================
   RESPONSIVE DESIGN
   Mobile adjustments
   ============================================ */

@media (max-width: 768px) {
  .prorank-modal-overlay {
    padding: 0;
  }
  
  .prorank-modal {
    max-width: 100%;
    max-height: 100%;
    height: 100%;
    border-radius: 0;
  }
  
  .prorank-modal--small,
  .prorank-modal--medium,
  .prorank-modal--large {
    max-width: 100%;
  }
  
  .prorank-modal-header {
    padding: 16px;
  }
  
  .prorank-modal-body {
    padding: 16px;
  }
  
  .prorank-modal-footer {
    padding: 12px 16px;
    flex-direction: column;
  }
  
  .prorank-modal-footer-actions {
    width: 100%;
  }
  
  .prorank-modal-footer-actions button {
    flex: 1;
  }
}