/* Media with Text Section */

.media-with-text-section {
  /* Max Height Settings */
  @media screen and (min-width: 769px) {
    & .media-with-text-container[style*="--max-height-desktop"] {
      max-height: var(--max-height-desktop);
      overflow-y: auto;

      & .media-column {
        max-height: 100%;
        overflow: hidden;
      }

      & .content-column {
        max-height: 100%;
        overflow-y: auto;
      }
    }
  }

  @media screen and (max-width: 768px) {
    & .media-with-text-container[style*="--max-height-mobile"] {
      max-height: var(--max-height-mobile);
      overflow-y: auto;

      & .media-column {
        max-height: 100%;
        overflow: hidden;
      }

      & .content-column {
        max-height: 100%;
        overflow-y: auto;
      }
    }
  }

  &.full-width {
    width: 100%;
    margin-left: 0;
    margin-right: 0;

    & .media-with-text-container {
      max-width: 100%;
    }
  }

  & .media-with-text-container {
    display: flex;
    flex-direction: column-reverse;


    @media screen and (min-width: 769px) {
      align-items: stretch;
      overflow: visible;
      display: grid;
      grid-template-columns: 1fr 1fr;
      grid-template-rows: 1fr;
    }

    /* Media Column */
    & .media-column {
      width: 100%;
      grid-row: 1;
      display: flex;
      align-items: stretch;
      min-height: 100%;
      position: relative;
      overflow: hidden;

      & .media-image-wrapper {
        width: 100%;
        height: 100%;
        overflow: hidden;
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
      }

      & .media-image {
        width: 100%;
        height: 100%;
        display: block;
        object-fit: cover;
        object-position: center;
      }

      &.media-fit-contain {
        & .media-image {
          object-fit: contain;
        }
      }

      /* Video Player Container */
      & .media-video-wrapper {
        width: 100%;
        height: 100%;
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        overflow: hidden;

        &.media-fit-contain {
          display: flex;
          align-items: center;
          justify-content: center;

          & media-video-player {
            position: relative;
            width: auto;
            height: auto;
            max-width: 100%;
            max-height: 100%;
            flex-shrink: 0;

            & video {
              position: relative;
              width: 100%;
              height: 100%;
              object-fit: contain;
              object-position: center;
              display: block;
            }
          }
        }

        & media-video-player {
          display: block;
          width: 100%;
          height: 100%;
          position: absolute;
          top: 0;
          left: 0;
          right: 0;
          bottom: 0;
          overflow: hidden;

          & video {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            object-fit: cover;
            object-position: center;
          }
        }
      }

      /* Before/After Slider */
      & before-after-slider {
        display: block;
        width: 100%;
        height: 100%;
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;

        & .before-after-container {
          width: 100%;
          height: 100%;
          position: relative;
        }

        & .before-after-wrapper {
          width: 100%;
          height: 100%;
          position: relative;
          overflow: hidden;
          cursor: col-resize;
          user-select: none;
        }

        & .before-image-container,
        & .after-image-container {
          position: absolute;
          top: 0;
          left: 0;
          width: 100%;
          height: 100%;
        }

        & .before-image-container {
          z-index: 1;
        }

        & .after-image-container {
          z-index: 2;
          clip-path: inset(0 50% 0 0);
        }

        & .before-image,
        & .after-image {
          width: 100%;
          height: 100%;
          object-fit: cover;
          object-position: center;
          display: block;
        }

        & .before-label,
        & .after-label {
          position: absolute;
          padding: 8px 16px;
          background: rgba(0, 0, 0, 0.7);
          color: #fff;
          font-size: 14px;
          font-weight: 600;
          text-transform: uppercase;
          z-index: 10;
          pointer-events: none;
        }

        & .before-label {
          top: 20px;
          left: 20px;
        }

        & .after-label {
          top: 20px;
          right: 20px;
        }

        & .slider-handle {
          position: absolute;
          top: 0;
          bottom: 0;
          width: 4px;
          left: 50%;
          z-index: 3;
          cursor: col-resize;
          transform: translateX(-50%);
        }

        & .slider-line {
          width: 100%;
          height: 100%;
          background: #fff;
          box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
        }

        & .slider-button {
          position: absolute;
          top: 50%;
          left: 50%;
          transform: translate(-50%, -50%);
          width: 48px;
          height: 48px;
          background: #fff;
          border-radius: 50%;
          display: flex;
          align-items: center;
          justify-content: center;
          box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
          color: #333;

          & svg {
            width: 24px;
            height: 24px;
          }
        }

        @media screen and (max-width: 768px) {
          & .before-label,
          & .after-label {
            font-size: 12px;
            padding: 6px 12px;
          }

          & .before-label {
            top: 10px;
            left: 10px;
          }

          & .after-label {
            top: 10px;
            right: 10px;
          }

          & .slider-button {
            width: 40px;
            height: 40px;

            & svg {
              width: 20px;
              height: 20px;
            }
          }
        }
      }
    }

    /* Content Column */
    & .content-column {
      width: 100%;
      display: flex;
      flex-direction: column;
      gap: 24px;
      grid-row: 1;
      padding: 40px;
      box-sizing: border-box;

      @media screen and (max-width: 768px) {
        padding: 20px;
      }

      /* Figtree Font Support */
      &.font-figtree,
      &.font-figtree * {
        font-family: 'Figtree', sans-serif !important;
      }

      &.font-figtree {
        & .heading-text,
        & h2.heading-text,
        & h3.copy-heading,
        & h5.copy-heading,
        & .copy-text,
        & .copy-text p,
        & .block-image-caption,
        & .btn,
        & .btn-primary,
        & .btn-secondary,
        & .block-button-group,
        & .block-button-group .btn,
        & .block-button-group .btn-primary,
        & .block-button-group .btn-secondary,
        & .block-button-group a.btn,
        & .block-button-group a.btn-primary,
        & .block-button-group a.btn-secondary {
          font-family: 'Figtree', sans-serif !important;
        }
      }

      /* Content Alignment */
      &.content-align-left {
        text-align: left;
        align-items: flex-start;

        & .block-image,
        & .block-heading,
        & .block-copy,
        & .block-button-group {
          text-align: left;
          align-self: flex-start;
        }

        & .block-image {
          margin-left: 0;
          margin-right: auto;
        }
      }

      &.content-align-center {
        text-align: center;
        align-items: center;

        & .block-image,
        & .block-heading,
        & .block-copy,
        & .block-button-group {
          text-align: center;
          align-self: center;
        }

        & .block-image {
          margin-left: auto;
          margin-right: auto;
        }
      }

      &.content-align-right {
        text-align: right;
        align-items: flex-end;

        & .block-image,
        & .block-heading,
        & .block-copy,
        & .block-button-group {
          text-align: right;
          align-self: flex-end;
        }

        & .block-image {
          margin-left: auto;
          margin-right: 0;
        }
      }

      /* Block Styles */
      & .block-image {
        margin-bottom: 16px;
        width: 100%;

        & .block-image-img {
          width: 100%;
          height: auto;
          display: block;
          border-radius: 8px;
          max-width: 100%;
        }

        @media screen and (max-width: 768px) {
          &[style*="--min-width-mobile"] {
            min-width: var(--min-width-mobile);

            & .block-image-img {
              min-width: var(--min-width-mobile);
            }
          }
        }
      }

      & .block-image-caption {
        margin-top: 8px;
        font-family: "Poppins", sans-serif;
        font-size: 14px;
        font-weight: 400;
        line-height: 1.6;
        color: #666;
        font-style: italic;
        text-align: inherit;
      }

      &.font-figtree {
        & .block-image-caption {
          font-family: 'Figtree', sans-serif !important;
        }
      }

      & .heading-text {
        font-size: 2em;
        font-weight: 600;
        line-height: 1.5;
        color: #8f2e60;
        margin: 0;
      }

      & .block-copy {
        margin-bottom: 16px;
      }

      & .copy-heading {
        font-weight: 600;
        line-height: 1.5;
        color: #8f2e60;
        margin: 0;
        font-size: 0.875em;
      }

      & .copy-text {
        font-size: 14px;
        font-weight: 400;
        line-height: 1.8;
        color: #666;

        @media screen and (min-width: 768px) {
          font-size: 16px;
        }

        & p {
          margin: 0 0 16px 0;
          font-size: 0.875rem;

          &:last-child {
            margin-bottom: 0;
          }
        }
      }

      /* Button Group */
      & .block-button-group {
        display: flex;
        gap: 16px;
        flex-wrap: wrap;
        margin-top: 8px;
        --button-bg-color: transparent;
        --button-text-color: inherit;
        --button-border-color: transparent;

        & .btn {
          margin: 0;
          border: 1px solid var(--button-border-color);
          transition: opacity 0.2s ease-out;
          background-color: var(--button-bg-color);
          color: var(--button-text-color);

          &:hover {
            opacity: 0.9;
          }
        }

        & .btn-primary {
          background-color: var(--button-bg-color);
          color: var(--button-text-color);
          border-color: var(--button-border-color);
        }

        & .btn-secondary {
          background-color: transparent;
          color: var(--button-border-color);
          border-color: var(--button-border-color);
        }
      }

      /* Button Style Variants */
      &.button-style-square {
        & .block-button-group .btn {
          border-radius: 0;
        }
      }

      &.button-style-slightly_rounded {
        & .block-button-group .btn {
          border-radius: 4px;
        }
      }

      &.button-style-pill {
        & .block-button-group .btn {
          border-radius: 9999px;
        }
      }

      /* Ensure Figtree font applies to buttons */
      &.font-figtree {
        & .block-button-group .btn,
        & .block-button-group .btn-primary,
        & .block-button-group .btn-secondary,
        & .block-button-group a {
          font-family: 'Figtree', sans-serif !important;
        }
      }
    }

    /* Position Variants - Using Grid Column Order */
    @media screen and (min-width: 769px) {
      &.media-position-left {
        & .media-column {
          grid-column: 1;
          grid-row: 1;
        }

        & .content-column {
          grid-column: 2;
          grid-row: 1;
        }
      }

      &.media-position-right {
        & .media-column {
          grid-column: 2;
          grid-row: 1;
        }

        & .content-column {
          grid-column: 1;
          grid-row: 1;
        }
      }
    }

    /* Responsive Styles */
    @media screen and (max-width: 768px) {
      gap: unset;
      grid-template-columns: 1fr;

      & .media-column {
        display: flex;
        grid-column: 1;
        grid-row: auto;
        min-height: 300px;
        position: relative;

        &:not(.hide-on-mobile) {
          min-height: 300px;
        }

        &.hide-on-mobile {
          display: none !important;
        }
      }

      & .content-column {
        grid-column: 1;
        grid-row: auto;

        & .heading-text {
          font-size: 24px;
        }

        & .block-button-group {
          flex-direction: column;
          width: 100%;

          & .btn {
            width: 100%;
          }
        }
      }
    }

    @media screen and (max-width: 480px) {
      & .content-column {
        gap: 20px;

        & .heading-text {
          font-size: 22px;
        }

        & .copy-text {
          font-size: 14px;
        }
      }
    }
  }
}
