/**
 * CourseFlow Modern Modal Styles
 * Clean, maintainable CSS for all modal components
 */

/* ========================================
   Modal Overlay
   ======================================== */
.cf-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.9);
  backdrop-filter: blur(15px);
  -webkit-backdrop-filter: blur(15px);
  z-index: 99999999 !important;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 20px;
  overflow-y: auto;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.cf-modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

/* ========================================
   Modal Content
   ======================================== */
.cf-modal-content {
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 20px;
  padding: 30px;
  max-width: 650px;
  width: 100%;
  margin: 60px auto 40px;
  box-shadow: 0 30px 60px -12px rgba(0, 0, 0, 0.8);
  position: relative;
  transform: translateY(-20px);
  transition: transform 0.3s ease;
  color: #f8fafc;
}

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

/* ========================================
   Modal Header
   ======================================== */
.cf-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 20px;
  border-bottom: 1px solid #334155;
  margin-bottom: 20px;
}

.cf-modal-title {
  color: #fff;
  font-size: 22px;
  font-weight: 800;
  margin: 0;
  letter-spacing: -0.5px;
  line-height: 1.3;
}

.cf-modal-close {
  background: #334155;
  border: none;
  color: #fff;
  cursor: pointer;
  font-size: 20px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, transform 0.2s;
  flex-shrink: 0;
  margin-left: 10px;
}

.cf-modal-close:hover {
  background: #475569;
  transform: scale(1.1);
}

.cf-modal-close:active {
  transform: scale(0.95);
}

/* ========================================
   Modal Body
   ======================================== */
.cf-modal-body {
  padding: 10px 0;
}

/* ========================================
   Loading Spinner
   ======================================== */
.cf-spinner {
  display: inline-block;
  width: 40px;
  height: 40px;
  border: 4px solid rgba(255, 255, 255, 0.1);
  border-radius: 50%;
  border-top-color: #2872fa;
  animation: cf-spin 1s linear infinite;
}

.cf-spinner.small {
  width: 16px;
  height: 16px;
  border-width: 2px;
  border-top-color: #ffffff;
}

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

/* ========================================
   Payment Card
   ======================================== */
.cf-payment-card {
  background: #0f172a;
  border: 1px solid #334155;
  padding: 20px;
  border-radius: 12px;
  margin: 20px 0;
  text-align: left;
}

.cf-payment-card-title {
  color: #3b82f6;
  font-size: 12px;
  font-weight: bold;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 10px;
}

.cf-payment-card-content {
  color: #cbd5e1;
  font-size: 14px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-all;
}

/* ========================================
   Buttons
   ======================================== */
.cf-btn {
  display: inline-block;
  padding: 12px 30px;
  border: none;
  border-radius: 30px;
  cursor: pointer;
  font-weight: bold;
  font-size: 16px;
  transition: all 0.2s;
  text-decoration: none;
  text-align: center;
}

.cf-btn-primary {
  background: #2872fa;
  color: white;
}

.cf-btn-primary:hover {
  background: #1d5ed6;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(40, 114, 250, 0.4);
}

.cf-btn-primary:active {
  transform: translateY(0);
}

.cf-btn-primary:disabled {
  background: #64748b;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.cf-btn-secondary {
  background: #334155;
  color: white;
}

.cf-btn-secondary:hover {
  background: #475569;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(51, 65, 85, 0.4);
}

.cf-btn-success {
  background: #2ecc71;
  color: white;
}

.cf-btn-success:hover {
  background: #27ae60;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(46, 204, 113, 0.4);
}

.cf-btn-full {
  width: 100%;
}

/* ========================================
   Success Icon
   ======================================== */
.cf-success-icon {
  font-size: 50px;
  margin-bottom: 15px;
  display: block;
  line-height: 1;
}

/* ========================================
   Text Utilities
   ======================================== */
.cf-text-center {
  text-align: center;
}

.cf-text-muted {
  color: #94a3b8;
}

.cf-text-success {
  color: #2ecc71;
}

.cf-text-error {
  color: #e74c3c;
}

.cf-mb-20 {
  margin-bottom: 20px;
}

.cf-mb-25 {
  margin-bottom: 25px;
}

.cf-mt-20 {
  margin-top: 20px;
}

/* ========================================
   Message Utilities
   ======================================== */
.cf-msg-success {
  color: #27ae60;
  font-weight: bold;
}

.cf-msg-error {
  color: #c0392b;
  font-weight: bold;
}

/* ========================================
   Payment Form Styles
   ======================================== */
.cf-payment-form {
  max-width: 800px;
  margin: 0 auto;
  padding-bottom: 80px;
  /* Space for fixed button on mobile */
}

.cf-payment-form label {
  display: block;
  margin-bottom: 8px;
  font-weight: bold;
  color: #cbd5e1;
  font-size: 14px;
}

.cf-payment-form input[type="text"],
.cf-payment-form input[type="number"],
.cf-payment-form select,
.cf-payment-form textarea {
  width: 100%;
  background: #0f172a;
  color: #fff;
  border: 1px solid #475569;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 14px;
  box-sizing: border-box;
  transition: all 0.3s ease;
}

/* Error state for fields */
.cf-payment-form input.cf-field-error,
.cf-payment-form select.cf-field-error,
.cf-payment-form textarea.cf-field-error {
  border-color: #e74c3c;
  box-shadow: 0 0 0 3px rgba(231, 76, 60, 0.2);
  background: rgba(231, 76, 60, 0.05);
}

/* Speech bubble error tooltip */
.cf-error-bubble {
  background: #e74c3c;
  color: white;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: bold;
  margin-top: 5px;
  margin-bottom: 10px;
  position: relative;
  animation: slideDown 0.3s ease;
  box-shadow: 0 4px 12px rgba(231, 76, 60, 0.3);
}

.cf-error-bubble::before {
  content: '';
  position: absolute;
  top: -6px;
  left: 20px;
  width: 0;
  height: 0;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-bottom: 6px solid #e74c3c;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.cf-payment-form input[type="number"]:focus,
.cf-payment-form input[type="text"]:focus,
.cf-payment-form select:focus,
.cf-payment-form textarea:focus {
  outline: none;
  border-color: #2872fa;
  box-shadow: 0 0 0 3px rgba(40, 114, 250, 0.1);
}

.cf-payment-form textarea {
  min-height: 80px;
  resize: vertical;
}

.cf-payment-form .cf-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 15px;
  margin-bottom: 20px;
}

.cf-payment-form .cf-form-group {
  margin-bottom: 20px;
}

.cf-payment-form .cf-btn-submit {
  width: 100%;
  padding: 12px;
  font-size: 16px;
  letter-spacing: 0.5px;
  margin-top: 10px;
}

/* Mobile Optimization - Single Page View */
@media (max-width: 768px) {
  .cf-payment-form {
    padding: 10px;
    padding-bottom: 20px;
    /* More space for fixed button */
  }

  .cf-payment-form label {
    font-size: 13px;
    margin-bottom: 6px;
  }

  .cf-payment-form input[type="text"],
  .cf-payment-form input[type="number"],
  .cf-payment-form select,
  .cf-payment-form textarea {
    padding: 8px 10px;
    font-size: 13px;
    -webkit-appearance: none;
    /* Remove iOS default styling */
    appearance: none;
  }

  .cf-payment-form .cf-form-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .cf-payment-form .cf-form-group {
    margin-bottom: 15px;
  }

  /* Fixed submit button for mobile - works better than sticky on iOS */
  .cf-payment-form .cf-btn-submit {
    padding-bottom: 20px;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 14px 20px;
    font-size: 15px;
    z-index: 999;
    box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.3);
    background: linear-gradient(135deg, #2872fa 0%, #1d5ed6 100%);
    margin: 0;
    border-radius: 0;
  }

  .cf-payment-form .cf-btn-submit:active {
    background: linear-gradient(135deg, #1d5ed6 0%, #164bb3 100%);
  }

  /* Reduce heading size on mobile */
  .cf-payment-form+div h3,
  .cf-payment-form~h3 {
    font-size: 20px !important;
  }

  /* Compact spacing */
  .cf-payment-form~div {
    margin-bottom: 15px !important;
    padding-bottom: 15px !important;
  }
}

/* Extra Small Screens (iPhone SE, etc.) */
@media (max-width: 375px) {
  .cf-payment-form {
    padding: 5px;
    padding-bottom: 20px;
  }

  .cf-payment-form label {
    font-size: 12px;
  }

  .cf-payment-form input[type="text"],
  .cf-payment-form input[type="number"],
  .cf-payment-form select,
  .cf-payment-form textarea {
    padding: 6px 8px;
    font-size: 12px;
  }

  .cf-payment-form .cf-btn-submit {
    padding: 12px 16px;
    font-size: 14px;
  }
}

/* ========================================
   Modal Variants
   ======================================== */
.cf-modal-content.cf-modal-sm {
  max-width: 400px;
}

.cf-modal-content.cf-modal-lg {
  max-width: 800px;
}

/* ========================================
   Responsive
   ======================================== */
@media (max-width: 768px) {
  .cf-modal-overlay {
    padding: 10px;
  }

  .cf-modal-content {
    padding: 20px;
    margin: 20px auto;
  }

  .cf-modal-title {
    font-size: 18px;
  }

  .cf-modal-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }

  .cf-modal-close {
    position: absolute;
    top: 20px;
    right: 20px;
    margin-left: 0;
  }

  .cf-btn {
    padding: 10px 20px;
    font-size: 14px;
  }
}

/* ========================================
   Loading Overlay (Full Screen)
   ======================================== */
.cf-loading-overlay {
  padding-bottom: 20px;
  inset: 0;
  background: rgba(15, 23, 42, 0.8);
  backdrop-filter: blur(3px);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.cf-loading-content {
  background: #1e293b;
  border: 1px solid #334155;
  padding: 40px;
  border-radius: 12px;
  text-align: center;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.3);
}

.cf-loading-text {
  color: #f8fafc;
  margin: 20px 0 0;
  font-size: 18px;
  font-weight: 500;
}