/**
 * HEALIST MODALS — Design 4 Prestige
 * ===================================
 * SINGLE SOURCE OF TRUTH for all modal styles.
 * Consolidated from: healist-modals.css + ModalBase.css + healist-components.css
 *
 * Modal Header: ALWAYS navy gradient + white text, NO EXCEPTIONS.
 * Zero !important — specificity managed by load order.
 */

/* ============================================
   MODAL OVERLAY
   ============================================ */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: var(--z-modal-backdrop, 1000);
  padding: var(--space-5);
}

/* ============================================
   MODAL CONTENT
   ============================================ */
.modal-content {
  background: var(--brand-surface);
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
  width: 100%;
  max-width: 800px;
  display: flex;
  flex-direction: column;
}

/* Size Variants */
.modal-content-xs {
  max-width: 400px;
}

.modal-content-sm {
  max-width: 500px;
}

.modal-content-md {
  max-width: 600px;
}

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

.modal-content-xl {
  max-width: 900px;
}

.modal-content-danger {
  border: 3px solid var(--color-error);
}

.modal-content-full {
  max-width: 95vw;
  width: 95vw;
}

/* ============================================
   MODAL HEADER — Navy Gradient + White Text
   ============================================ */
.modal-header {
  background: linear-gradient(135deg, var(--brand-primary-dark) 0%, var(--brand-primary) 100%);
  color: white;
  padding: var(--space-5) var(--space-6);
  border-radius: 16px 16px 0 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: none;
}

.modal-header h2,
.modal-header h3,
.modal-header .modal-title {
  margin: 0;
  font-size: 20px;
  font-weight: var(--font-semibold);
  color: white;
  font-family: var(--font-heading);
}

.modal-title {
  margin: 0;
  font-family: var(--font-heading);
  font-size: 20px;
  font-weight: var(--font-semibold);
  color: var(--brand-text);
}

.modal-title-danger {
  color: var(--color-error);
}

.modal-title-center {
  text-align: center;
}

.modal-subtitle {
  font-size: var(--text-base);
  color: var(--brand-text-muted);
  line-height: 1.6;
}

/* ============================================
   MODAL BODY
   ============================================ */

/* Forms directly in modal-content (no .modal-body wrapper) get auto-padding */
.modal-content > form {
  padding: var(--space-6);
}

.modal-body {
  padding: var(--space-6);
  flex: 1;
  overflow-y: auto;
}

.modal-description {
  margin-bottom: var(--space-5);
  line-height: 1.6;
  color: var(--brand-text-muted);
  font-size: var(--text-base);
}

.modal-text {
  font-size: var(--text-base);
  color: var(--brand-text-muted);
  line-height: 1.6;
  margin-bottom: var(--space-6);
}

/* ============================================
   MODAL FOOTER / ACTIONS
   ============================================ */
.modal-footer {
  display: flex;
  gap: var(--space-3);
  justify-content: flex-end;
  padding: var(--space-5) var(--space-6);
  border-top: 1px solid var(--brand-border);
  background-color: var(--brand-surface-elevated);
  border-radius: 0 0 16px 16px;
}

.modal-actions {
  display: flex;
  gap: var(--space-3);
  justify-content: flex-end;
}

.modal-actions-center {
  justify-content: center;
}

.modal-actions-spread {
  justify-content: space-between;
}

/* Full-width buttons inside modal-actions (column layout) */
.modal-actions.modal-actions-stacked {
  flex-direction: column;
}

.modal-actions.modal-actions-stacked .btn,
.modal-actions.modal-actions-stacked .btn-primary,
.modal-actions.modal-actions-stacked .btn-secondary,
.modal-actions.modal-actions-stacked .btn-ghost {
  width: 100%;
}

/* ============================================
   MODAL CLOSE BUTTON (absolute positioned)
   ============================================ */
.modal-close {
  position: absolute;
  top: var(--space-4);
  right: var(--space-4);
  width: 36px;
  height: 36px;
  border: none;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: white;
  transition: all var(--transition);
}

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

/* ============================================
   CLOSE BUTTON (in-header, non-absolute)
   Migrated from ModalBase.css
   ============================================ */
.close-button {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: white;
  padding: 0;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  line-height: 1;
}

.close-button:hover {
  background: rgba(255, 255, 255, 0.35);
  color: white;
}

/* ============================================
   CANCEL / SAVE BUTTONS
   Migrated from ModalBase.css
   ============================================ */
.cancel-button {
  background-color: var(--brand-surface);
  border: 1px solid var(--brand-border);
  color: var(--brand-text);
  padding: var(--space-3) var(--space-5);
  border-radius: 8px;
  cursor: pointer;
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 13px;
  transition: all 0.2s;
}

.cancel-button:hover {
  background-color: var(--brand-surface-elevated);
  border-color: var(--brand-primary);
  color: var(--brand-primary);
}

.save-button {
  background: linear-gradient(135deg, var(--brand-primary) 0%, var(--brand-primary-light) 100%);
  border: none;
  color: white;
  padding: var(--space-3) var(--space-5);
  border-radius: 8px;
  cursor: pointer;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 13px;
  transition: all 0.2s;
  box-shadow: 0 4px 12px rgba(30, 58, 95, 0.2);
}

.save-button:hover {
  background: linear-gradient(135deg, var(--brand-primary-dark) 0%, var(--brand-primary) 100%);
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(30, 58, 95, 0.3);
}

/* ============================================
   DATE INPUT (used in modals)
   Migrated from ModalBase.css
   ============================================ */
.date-input {
  width: 100%;
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--brand-border);
  border-radius: 6px;
  font-size: var(--text-base);
  font-family: var(--font-body);
  line-height: 1.4;
}

.date-input:focus {
  outline: none;
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 3px rgba(30, 58, 95, 0.1);
}

/* ============================================
   DATE OF BIRTH SECTION
   Migrated from ModalBase.css
   ============================================ */
.date-of-birth-section {
  margin-bottom: var(--space-6);
  padding: var(--space-4);
  background-color: var(--brand-surface-elevated);
  border-radius: var(--radius-md);
  border: 1px solid var(--brand-border);
}

.date-of-birth-section label {
  display: block;
  margin-bottom: var(--space-2);
  font-weight: var(--font-semibold);
  color: var(--brand-text);
  font-size: var(--text-base);
}

/* ============================================
   MODAL DIVIDER
   ============================================ */
.modal-divider {
  margin: var(--space-5) 0;
  border: none;
  border-top: 1px solid var(--brand-border);
}

/* ============================================
   MODAL GRID LAYOUT
   ============================================ */
.modal-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-8);
  margin-bottom: var(--space-8);
}

.modal-grid-single {
  grid-template-columns: 1fr;
}

/* ============================================
   MODAL SECTION
   ============================================ */
.modal-section {
  margin-bottom: var(--space-6);
}

.modal-section-title {
  font-size: var(--text-lg);
  font-weight: var(--font-semibold);
  margin-bottom: var(--space-4);
  color: var(--brand-primary-dark);
}

/* ============================================
   CHECKBOX LIST IN MODAL
   ============================================ */
.checkbox-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.checkbox-item {
  display: flex;
  align-items: center;
  cursor: pointer;
}

.checkbox-item input[type="checkbox"],
.checkbox-item input[type="radio"] {
  margin-right: var(--space-3);
  cursor: pointer;
  width: 16px;
  height: 16px;
  accent-color: var(--brand-primary);
}

.checkbox-item span {
  font-size: var(--text-base);
  color: var(--brand-text);
}

/* ============================================
   MODAL ALERT
   ============================================ */
.modal-alert {
  padding: var(--space-3);
  border-radius: var(--radius);
  margin-bottom: var(--space-5);
  font-size: var(--text-sm);
}

.modal-alert-error {
  background-color: var(--color-error-light);
  border: 1px solid var(--color-error-border);
  color: var(--color-error);
}

.modal-alert-success {
  background-color: var(--color-success-light);
  border: 1px solid var(--color-success-border);
  color: var(--color-success);
}

.modal-alert-info {
  background-color: var(--color-info-light);
  border: 1px solid var(--color-info-border);
  color: var(--color-info);
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
  .modal-overlay {
    padding: var(--space-3);
    align-items: center;
  }

  .modal-content {
    max-width: 100%;
    max-height: 95vh;
  }

  .modal-header {
    padding: var(--space-4) var(--space-5);
  }

  .modal-body {
    padding: var(--space-5);
  }

  .modal-footer {
    padding: var(--space-4) var(--space-5);
    flex-direction: column;
  }

  .modal-footer button,
  .cancel-button,
  .save-button {
    width: 100%;
    justify-content: center;
  }

  .modal-grid {
    grid-template-columns: 1fr;
  }
}
