/**
 * ==========================================================================
 * VERIMUS DESIGN SYSTEM - MODAL COMPONENTS
 * ==========================================================================
 * 
 * Modal/dialog styling for Bootstrap 5 modals with custom theming.
 * 
 * Structure:
 * - .modal                = Bootstrap modal container
 * - .modal-dialog         = Dialog positioning wrapper
 * - .modal-content        = Card-like content container
 * - .modal-header         = Top section with title and close
 * - .modal-body           = Main content area
 * - .modal-footer         = Action buttons area
 * 
 * Size Variants:
 * - .modal-sm             = Small (300px)
 * - .modal-lg             = Large (800px)
 * - .modal-xl             = Extra large (1140px)
 * - .modal-fullscreen     = Full screen
 * 
 * Custom Classes:
 * - .v-modal              = Verimus-styled modal
 * - .v-modal--tip         = Tip/help modal
 * - .v-modal--confirm     = Confirmation dialog
 * - .v-modal--preview     = Preview modal
 * 
 * Depends on: _variables.css
 * ==========================================================================
 */

/* ==========================================================================
   MODAL BACKDROP
   ========================================================================== */

.modal-backdrop {
  background-color: rgba(0, 0, 0, 0.5);
}

.modal-backdrop.show {
  opacity: 1;
}

/* ==========================================================================
   MODAL CONTAINER
   ========================================================================== */

/* Layering is left to Bootstrap (dialog 1055, backdrop 1050). Setting the
 * dialog to --z-modal (1050) put it level with the backdrop, which Bootstrap
 * appends later in the page, so the backdrop covered the dialog. */

/* Centered dialog */
.modal-dialog-centered {
  min-height: calc(100% - var(--spacing-8));
}

/* ==========================================================================
   MODAL CONTENT
   ========================================================================== */

.modal-content {
  background-color: var(--card-bg);
  border: none;
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
}

/* ==========================================================================
   MODAL HEADER
   ========================================================================== */

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--spacing-6);
  border-bottom: 1px solid var(--border-color);
}

.modal-title {
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-semibold);
  color: var(--text-primary);
  margin: 0;
  line-height: var(--line-height-tight);
}

/* Large modal title */
.modal-title-lg {
  font-size: var(--font-size-2xl);
  font-weight: var(--font-weight-bold);
}

/* ==========================================================================
   CLOSE BUTTON
   ========================================================================== */

.btn-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 0;
  background-color: var(--gray-100);
  border: none;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: background-color var(--transition-base) var(--ease-in-out);
  opacity: 1;
  /* Grey X (palette muted text), not Bootstrap black. */
  color: var(--text-muted, #687588);
  --bs-btn-close-color: var(--text-muted, #687588);
  --bs-btn-close-bg: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%23687588'%3e%3cpath d='M.293.293a1 1 0 0 1 1.414 0L8 6.586 14.293.293a1 1 0 1 1 1.414 1.414L9.414 8l6.293 6.293a1 1 0 0 1-1.414 1.414L8 9.414l-6.293 6.293a1 1 0 0 1-1.414-1.414L6.586 8 .293 1.707a1 1 0 0 1 0-1.414z'/%3e%3c/svg%3e");
}

.btn-close:hover {
  background-color: var(--gray-200);
}

.btn-close:focus {
  outline: none;
  box-shadow: var(--shadow-focus);
}

/* Custom close icon (if not using Bootstrap's) */
.btn-close::before {
  content: "";
  width: 16px;
  height: 16px;
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%23687588'%3e%3cpath d='M.293.293a1 1 0 0 1 1.414 0L8 6.586 14.293.293a1 1 0 1 1 1.414 1.414L9.414 8l6.293 6.293a1 1 0 0 1-1.414 1.414L8 9.414l-6.293 6.293a1 1 0 0 1-1.414-1.414L6.586 8 .293 1.707a1 1 0 0 1 0-1.414z'/%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
}

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

.modal-body {
  padding: var(--spacing-6);
  color: var(--text-primary);
}

/* Body with scroll */
.modal-body-scroll {
  max-height: 60vh;
  overflow-y: auto;
}

/* ==========================================================================
   MODAL FOOTER
   ========================================================================== */

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--spacing-3);
  padding: var(--spacing-4) var(--spacing-6);
  border-top: 1px solid var(--border-color);
}

/* Footer alignment variants */
.modal-footer-start {
  justify-content: flex-start;
}

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

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

/* ==========================================================================
   SIZE VARIANTS
   ========================================================================== */

.modal-sm .modal-dialog {
  max-width: 300px;
}

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

.modal-xl .modal-dialog {
  max-width: 1140px;
}

/* Custom HR Command tip modal */
.modal-hr-command-tip .modal-dialog {
  max-width: 1024px;
}

.modal-hr-command-tip .modal-title {
  font-size: var(--font-size-3xl);
  font-weight: var(--font-weight-bold);
  flex: 1;
}

.modal-hr-command-tip .modal-header {
  border: 0;
}

.modal-hr-command-tip .modal-content {
  padding: var(--spacing-8) var(--spacing-5);
  border: 0;
}

.modal-hr-command-tip .modal-footer {
  justify-content: unset;
  border: 0;
}

.modal-hr-command-tip .modal-image {
  position: absolute;
  height: 100%;
  top: 0;
  right: 70px;
  width: 35%;
  padding-block: var(--spacing-5);
  box-sizing: border-box;
}

.modal-hr-command-tip .modal-content.has-image .modal-title,
.modal-hr-command-tip .modal-content.has-image .modal-body {
  padding-right: 40%;
}

.modal-hr-command-tip .modal-image img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* Modal close button variant (dark background) */
.modal-bday-preview .btn-close,
.modal-hr-command-tip .btn-close {
  background-color: var(--color-secondary);
  opacity: 1;
  background-image: unset;
  position: relative;
  height: 44px;
  width: 44px;
  padding: 0;
  border-radius: var(--radius-lg);
  margin-top: 0;
  margin-right: 0; /* Consolidated from birthday-banner.css */
}

.modal-bday-preview .btn-close::after,
.modal-bday-preview .btn-close::before,
.modal-hr-command-tip .btn-close::after,
.modal-hr-command-tip .btn-close::before {
  content: "";
  height: 1px;
  width: 30px;
  background-color: var(--white);
  transform: rotate(45deg);
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  bottom: 0;
  margin: auto;
}

.modal-bday-preview .btn-close::after,
.modal-hr-command-tip .btn-close::after {
  transform: rotate(-45deg);
}

/* ==========================================================================
   MODAL BODY TABLE STYLING
   ========================================================================== */

.modal-body h3 {
  font-size: var(--font-size-lg);
}

.modal-body table,
.modal-body table th,
.modal-body table td {
  border: 1px solid var(--grayscale-400);
}

.modal-body table th,
.modal-body table td {
  padding: var(--spacing-2);
}

.modal-header h2 {
  margin-bottom: 0;
}

h5.modal-title {
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-bold);
}

/* ==========================================================================
   VERIMUS MODAL VARIANTS
   ========================================================================== */

/* Confirmation Modal */
.v-modal--confirm .modal-body {
  text-align: center;
  padding: var(--spacing-8);
}

.v-modal--confirm .modal-icon {
  width: 64px;
  height: 64px;
  margin: 0 auto var(--spacing-4);
}

.v-modal--confirm .modal-icon--warning {
  color: var(--color-warning);
}

.v-modal--confirm .modal-icon--danger {
  color: var(--color-error);
}

.v-modal--confirm .modal-icon--success {
  color: var(--color-success);
}

.v-modal--confirm .modal-message {
  font-size: var(--font-size-lg);
  color: var(--text-primary);
  margin-bottom: var(--spacing-2);
}

.v-modal--confirm .modal-submessage {
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
}

.v-modal--confirm .modal-footer {
  justify-content: center;
}

/* Preview Modal */
.v-modal--preview .modal-body {
  padding: 0;
}

.v-modal--preview .preview-content {
  max-height: 70vh;
  overflow: auto;
}

/* Scrollable Modal */
.modal-dialog-scrollable .modal-body {
  overflow-y: auto;
}

/* ==========================================================================
   DELETE/DANGER MODALS
   ========================================================================== */

.delete-training-modal .modal-content,
.delete-user-modal .modal-content,
.archive-user-modal .modal-content,
.reactivate-user-modal .modal-content {
  border-radius: var(--radius-xl);
}

/* ==========================================================================
   SPECIFIC MODAL CLASSES (Legacy Support)
   ========================================================================== */

.modal-bday-preview .modal-content {
  border-radius: var(--radius-xl);
}

.review-link-modal .modal-dialog {
  max-width: 600px;
}

/* ==========================================================================
   ANIMATIONS
   ========================================================================== */

.modal.fade .modal-dialog {
  transform: translateY(-20px);
  transition: transform var(--transition-slow) var(--ease-out);
}

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

/* Slide up animation */
.modal.fade.modal-slide-up .modal-dialog {
  transform: translateY(100%);
}

.modal.show.modal-slide-up .modal-dialog {
  transform: translateY(0);
}

/* ==========================================================================
   DARK MODE
   ========================================================================== */

.dark-mode .modal-content {
  background-color: var(--dark-bg-secondary);
  border-color: var(--dark-border);
}

.dark-mode .modal-header {
  border-color: var(--dark-border);
}

.dark-mode .modal-title {
  color: var(--dark-text-primary);
}

.dark-mode .modal-body {
  color: var(--dark-text-primary);
}

.dark-mode .modal-footer {
  border-color: var(--dark-border);
}

.dark-mode .btn-close {
  background-color: var(--dark-bg-tertiary);
}

.dark-mode .btn-close:hover {
  background-color: var(--gray-600);
}

.dark-mode .btn-close::before {
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%23ffffff'%3e%3cpath d='M.293.293a1 1 0 0 1 1.414 0L8 6.586 14.293.293a1 1 0 1 1 1.414 1.414L9.414 8l6.293 6.293a1 1 0 0 1-1.414 1.414L8 9.414l-6.293 6.293a1 1 0 0 1-1.414-1.414L6.586 8 .293 1.707a1 1 0 0 1 0-1.414z'/%3e%3c/svg%3e");
}

/* ==========================================================================
   RESPONSIVE
   ========================================================================== */

@media screen and (max-width: 767px) {
  .modal-dialog {
    margin: var(--spacing-3);
    max-width: calc(100% - var(--spacing-6));
  }
  
  .modal-header,
  .modal-body,
  .modal-footer {
    padding: var(--spacing-4);
  }
  
  .modal-title {
    font-size: var(--font-size-base);
  }
  
  .modal-footer {
    flex-direction: column;
  }
  
  .modal-footer > * {
    width: 100%;
  }
  
  .modal-hr-command-tip .modal-title {
    font-size: var(--font-size-xl);
  }
}

/* Every button in a dialog footer is the same standard size, whichever button family it comes from (BugHerd #3867). Not on the Dashboard (body.home), which keeps its own look. */
body:not(.home) .modal-footer :is(.verimus-btn, .v-btn, .btn, .hrc-btn, button.button):not(.btn-close):not(#_) {
  height: var(--btn-height-md, 40px);
  min-height: var(--btn-height-md, 40px);
  padding: var(--btn-padding-y, 8px) var(--btn-padding-x, 16px);
  font-size: var(--btn-font-size, 14px);
  line-height: var(--line-height-tight, 1.25);
}
