/**
 * Quantum Theme Utility Classes
 *
 * This file contains utility classes for the Quantum theme.
 * These classes are designed to be reusable across different components
 * and provide consistent functionality throughout the theme.
 */

/* Layout Utilities
--------------------------------------------- */
.position-relative {
  position: relative !important;
}

.overflow-hidden {
  overflow: hidden;
}

.overflow-visible {
  overflow: visible;
}

.display-none {
  display: none !important;
}

.cursor-pointer {
  cursor: pointer;
}

.sticky-sidebar {
  top: calc(
    var(--header-height-desktop) + var(--wp--preset--spacing--20)
  ) !important; /* Position for sticky sidebar elements */
  z-index: 1 !important;
}

body.admin-bar .sticky-sidebar {
  top: calc(
    var(--header-height-desktop) + var(--wp-admin--admin-bar--position-offset) +
      var(--wp--preset--spacing--20)
  ) !important; /* Position for sticky sidebar elements */
  z-index: 1 !important;
}

/* Z-index Utilities
--------------------------------------------- */
.z-index-1 {
  z-index: 1;
}

.z-index-2 {
  z-index: 2;
}

.z-index-10 {
  z-index: 10;
}

.z-index-100 {
  position: relative;
  z-index: 100;
}

.z-index-1000 {
  position: relative;
  z-index: 1000;
}

.z-index-10000 {
  position: relative;
  z-index: 10000;
}

/* Flex & Layout Utilities
--------------------------------------------- */
.space-between {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.clickable-parent {
  cursor: pointer;
}

/* Flex Display */
.display-flex {
  display: flex !important;
}

.display-inline-flex {
  display: inline-flex !important;
}

/* Flex Direction */
.flex-row {
  flex-direction: row !important;
}

.flex-column {
  flex-direction: column !important;
}

.flex-row-reverse {
  flex-direction: row-reverse !important;
}

.flex-column-reverse {
  flex-direction: column-reverse !important;
}

/* Flex Wrap */
.flex-wrap {
  flex-wrap: wrap !important;
}

.flex-nowrap {
  flex-wrap: nowrap !important;
}

/* Flex Properties */
.flex-grow {
  flex-grow: 1 !important;
}

.flex-no-grow {
  flex-grow: 0 !important;
}

.flex-shrink {
  flex-shrink: 1 !important;
}

.flex-no-shrink {
  flex-shrink: 0 !important;
}

/* Justify Content */
.justify-start {
  justify-content: flex-start !important;
}

.justify-end {
  justify-content: flex-end !important;
}

.justify-center {
  justify-content: center !important;
}

.justify-between {
  justify-content: space-between !important;
}

.justify-around {
  justify-content: space-around !important;
}

.justify-evenly {
  justify-content: space-evenly !important;
}

/* Align Items */
.align-start {
  align-items: flex-start !important;
}

.align-end {
  align-items: flex-end !important;
}

.align-center {
  align-items: center !important;
}

.align-baseline {
  align-items: baseline !important;
}

.align-stretch {
  align-items: stretch !important;
}

/* Align Self */
.self-start {
  align-self: flex-start !important;
}

.self-end {
  align-self: flex-end !important;
}

.self-center {
  align-self: center !important;
}

.self-baseline {
  align-self: baseline !important;
}

.self-stretch {
  align-self: stretch !important;
}

/* Position Utilities
--------------------------------------------- */
.position-absolute {
  position: absolute !important;
}

.position-fixed {
  position: fixed !important;
}

.position-sticky {
  position: sticky !important;
}

/* Position Values */
.top-0 {
  top: 0 !important;
}

.right-0 {
  right: 0 !important;
}

.bottom-0 {
  bottom: 0 !important;
}

.left-0 {
  left: 0 !important;
}

.inset-0 {
  top: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  left: 0 !important;
}

/* Center Absolute */
.absolute-center {
  position: absolute !important;
  top: 50% !important;
  left: 50% !important;
  transform: translate(-50%, -50%) !important;
}

.absolute-center-x {
  position: absolute !important;
  left: 50% !important;
  transform: translateX(-50%) !important;
}

.absolute-center-y {
  position: absolute !important;
  top: 50% !important;
  transform: translateY(-50%) !important;
}

/* Gap Utilities
--------------------------------------------- */
.gap-0 {
  gap: 0 !important;
}

.gap-1 {
  gap: var(--wp--preset--spacing--10) !important;
}

.gap-2 {
  gap: var(--wp--preset--spacing--20) !important;
}

.gap-3 {
  gap: var(--wp--preset--spacing--30) !important;
}

.gap-4 {
  gap: var(--wp--preset--spacing--40) !important;
}

.gap-5 {
  gap: var(--wp--preset--spacing--50) !important;
}

/* Grid Layout Utilities
--------------------------------------------- */

.two-item-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
}

@media (max-width: 768px) {
  .two-item-grid {
    grid-template-columns: 1fr;
  }
}

/* Three-item Grid */

.three-item-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
}

@media (max-width: 1024px) {
  .three-item-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 768px) {
  .three-item-grid {
    grid-template-columns: 1fr;
  }
}

/* Four-item Grid */
.four-item-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
}

@media (max-width: 1024px) {
  .four-item-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 768px) {
  .four-item-grid {
    grid-template-columns: 1fr;
  }
}

/* Interactive Elements
--------------------------------------------- */
.card-hover {
  transition: transform 0.3s ease-in-out;
}

.card-hover:hover,
.card-hover:focus {
  transform: translateY(-5px);
}

.hover-scale {
  transition: transform 0.3s ease-in-out;
}

.hover-scale:hover,
.hover-scale:focus {
  transform: scale(1.05);
}

.hover-lift {
  transition: transform 0.3s ease-in-out, box-shadow 0.3s ease-in-out;
}

.hover-lift:hover,
.hover-lift:focus {
  transform: translateY(-3px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.hover-brighten {
  transition: filter 0.3s ease-in-out;
}

.hover-brighten:hover,
.hover-brighten:focus {
  filter: brightness(1.1);
}

.hover-darken {
  transition: filter 0.3s ease-in-out;
}

.hover-darken:hover,
.hover-darken:focus {
  filter: brightness(0.9);
}

.focus-outline:focus {
  outline: 2px solid var(--wp--preset--color--accent) !important;
  outline-offset: 2px !important;
}

.no-focus-outline:focus {
  outline: none !important;
}

.hover-shadow {
  transition: all 0.3s ease-in-out;
}

.hover-shadow:hover,
.hover-shadow:focus {
  box-shadow: 0 4px 4px -10px rgba(0, 0, 0, 0.04),
    0 13px 13px -10px rgba(0, 0, 0, 0.06), 0 40px 60px -10px rgba(0, 0, 0, 0.08);
}

/* Form Accessibility Utilities
--------------------------------------------- */
.jsf-no-form-labels .jet-form-builder__label-text,
.jfb-no-form-labels .jet-form-builder__label-text {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

/* JetFormBuilder Description Before Label */
.jfb-description-before {
  display: flex !important;
  flex-direction: column !important;
}

/* Universal order for ALL JetFormBuilder field types */
.jfb-description-before .jet-form-builder__label {
  order: 1 !important; /* Label always first */
  margin-bottom: 0rem !important; /* Small gap after label */
}

.jfb-description-before .jet-form-builder__label-text {
  margin-bottom: 0.5rem !important;
  margin-top: 0.5rem;
}

.jfb-description-before .jet-form-builder__desc {
  order: 2 !important; /* Description always second */
  margin-bottom: 0.5rem !important; /* Small gap after description */
  line-height: 1.2 !important;
}

.jfb-description-before .jet-form-builder__field-wrap,
.jfb-description-before .jet-form-builder__fields-group,
.jfb-description-before .checkradio-wrap {
  order: 3 !important; /* Field/fields always third */
}

/* Gutenberg Editor Support */
.jfb-description-before .components-base-control__field {
  display: flex !important;
  flex-direction: column !important;
}

.jfb-description-before .components-base-control__label {
  order: 1 !important; /* Label first in editor */
  margin-bottom: 0 !important; /* Remove default label spacing in editor */
}

.jfb-description-before .jet-form-builder__desc--wrapper {
  order: 2 !important; /* Description second in editor */
  margin-bottom: 0.5rem !important;
  line-height: 1.2 !important;
}

.jfb-description-before .jet-form-builder__field-preview {
  order: 3 !important; /* Field third in editor */
}

/* Animation Utilities
--------------------------------------------- */
.animate-fade-in {
  animation: fadeIn 0.5s ease-in-out;
}

.animate-slide-up {
  animation: slideUp 0.5s ease-in-out;
}

.animate-slide-down {
  animation: slideDown 0.5s ease-in-out;
}

.animate-slide-left {
  animation: slideLeft 0.5s ease-in-out;
}

.animate-slide-right {
  animation: slideRight 0.5s ease-in-out;
}

.transition-all {
  transition: all 0.3s ease-in-out;
}

.transition-transform {
  transition: transform 0.3s ease-in-out;
}

.transition-opacity {
  transition: opacity 0.3s ease-in-out;
}

/* Animation Keyframes
--------------------------------------------- */
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

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

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

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

@keyframes slideRight {
  from {
    transform: translateX(-20px);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

/* Text Effects
--------------------------------------------- */
.text-shadow {
  text-shadow: 0.09375em 0 0.1875em rgba(0, 0, 0, 0.25);
}

/* External Link Styles
--------------------------------------------- */
.wp-block-navigation .external-link a::after {
  content: "\2197";
  margin-left: 5px;
  display: inline-block;
  vertical-align: middle;
}

/* User Role Visibility
--------------------------------------------- */
.user-logged-out .show-logged-in,
.user-logged-in .show-logged-out,
:not(.user-admin) .show-admin,
.user-logged-in .hide-logged-in,
.user-logged-out .hide-logged-out,
.user-admin .hide-admin {
  display: none !important;
}

/* Responsive Utilities
--------------------------------------------- */

/* Extra large screens (1200px and up) */
@media (min-width: 1200px) {
}

/* Large screens (1024px to 1199px) */
@media (min-width: 1024px) and (max-width: 1199.98px) {
}

/* Medium screens (768px to 1023px) */
@media (min-width: 768px) and (max-width: 1023.98px) {
  .md-stack-blocks {
    flex-direction: column;
  }

  .md-text-left {
    text-align: left !important;
  }

  .md-text-center {
    text-align: center !important;
  }

  .md-text-right {
    text-align: right !important;
  }

  .md-justify-start {
    justify-content: flex-start !important;
  }

  .md-justify-center {
    justify-content: center !important;
  }

  .md-justify-end {
    justify-content: flex-end !important;
  }

  .md-align-center {
    align-items: center !important;
  }

  .md-order-first {
    order: -1;
  }

  .md-order-last {
    order: 99;
  }

  .md-width-100 {
    width: 100% !important;
    max-width: 100% !important;
  }
}

/* Small screens (less than 768px) */
@media (max-width: 767px) {
  .sm-stack-blocks {
    flex-direction: column;
  }

  .sm-text-left {
    text-align: left !important;
  }

  .sm-text-center {
    text-align: center !important;
  }

  .sm-text-right {
    text-align: right !important;
  }

  .sm-justify-start {
    justify-content: flex-start !important;
  }

  .sm-justify-center {
    justify-content: center !important;
  }

  .sm-justify-end {
    justify-content: flex-end !important;
  }

  .sm-align-center {
    align-items: center !important;
  }

  .sm-order-first {
    order: -1;
  }

  .sm-order-last {
    order: 99;
  }

  .sm-width-100 {
    width: 100% !important;
    max-width: 100% !important;
  }

  /* Button full width on mobile */
  .wp-block-button,
  .wp-block-button__link,
  .wp-block-button a {
    width: 100% !important;
  }
}

/* Color Utilities
--------------------------------------------- */
.current-color {
  color: currentColor !important;
  fill: currentColor !important;
}
