.custom-bulk-order-flow {
  padding-top: 24px;
}
.flow-step {
  margin-bottom: 32px;
}

.flow-step-title {
  margin-bottom: 10px;
  line-height: 1.4;
  text-transform: uppercase;
}

.flow-step-note {
  font-size: 12px;
  color: #666;
  margin-bottom: 10px;
  font-style: italic;
}

.spf-type-indicator {
  font-size: 12px;
  color: #666;
  margin-top: 5px;
  font-style: italic;
}

.flow-selection {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.flow-option {
  position: relative;
  min-width: 122px;

  input {
    position: absolute;
    top: 0;
    left: 0;
    opacity: 0;
    visibility: hidden;
  }

  label {
    display: block;
    padding: 8px;
    font-size: 14px;
    line-height: 1.75;
    text-align: center;
    border: 1px solid rgba(92, 92, 92, 0.2);
    border-radius: 3px;
    cursor: pointer;
  }

  input:checked + label {
    border-color: rgba(92, 92, 92, 1);
  }
}

.flow-variants {
  .t4s-btn {
    --padding-btn: 15px 24px 15px 16px;
    --btn-size: 14px;
    --btn-radius: 3px;
    --btn-border: rgba(92, 92, 92, 0.2);
    --btn-border-hover: rgba(92, 92, 92, 1);

    width: 100%;
    justify-content: flex-start;
    gap: 16px;

    svg {
      color: #e5eefa;
    }

    span {
      margin-right: auto;
    }

    &::after {
      border-width: 1px;
    }
  }

  .t4s-btn[disabled] {
    opacity: 0.5;
    cursor: not-allowed;

    &::after {
      border-color: rgba(92, 92, 92, 0.2);
    }
  }
}

.flow-selection-header {
  padding: 60px 8.5% 30px;
  text-align: center;

  h3 {
    margin-bottom: 16px;
    font-size: 30px;
    color: var(--custombulk-color);
  }

  p {
    margin: 0;
    line-height: 1.533;
  }
}

.variant-selection {
  flex-grow: 1;
  overflow-y: auto;
  padding-bottom: 80px;

  .variant-item {
    border-top: 1px solid rgba(92, 92, 92, 0.15);
    padding: 12px 20px;
    transition: opacity 0.3s ease, transform 0.3s ease, max-height 0.3s ease;

    &.active {
      .variant-title,
      .variant-qty-input {
        opacity: 1;
      }
    }
  }

  .variant-item[style*="display: none"] {
    opacity: 0;
    transform: translateY(-10px);
    max-height: 0;
    overflow: hidden;
    pointer-events: none;
  }

  .variant-selector {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
  }

  .variant-title {
    line-height: 1.33;
    flex: 1;
    opacity: 0.7;
  }

  .quantity-selector {
    display: flex;
    align-items: center;
    gap: 5px;
  }

  .qty-btn {
    width: 20px;
    height: 20px;
    padding: 0;
    background: #EDF2F6;
    color: var(--custombulk-color);
    border-radius: 3px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .qty-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
  }

  .variant-qty-input {
    width: 46px;
    height: 24px;
    padding: 0;
    font-size: 14px;
    line-height: 24px;
    text-align: center;
    opacity: 0.7;
    border: 0;
  }

  .variant-qty-input::-webkit-inner-spin-button {
    display: none;
  }
}

.extras-selection {
  flex-grow: 1;
  overflow-y: auto;
  padding: 0 20px 80px;
  position: relative;
  
  /* Allow dropdown to extend beyond container */
  .custom-dropdown {
    overflow: visible;
  }

  .extra-item, .subscription-item {
    position: relative;
    z-index: 1;

    & + .extra-item, & + .subscription-item {
      margin-top: 28px;
    }

    li {
      list-style-type: disc;
    }
    .pdf-upload-warning {
      display: flex;
      justify-content: space-between;
      padding: 0px 18px 18px 48px;
      margin-top: -20px;
      background-color: #f9fafd;
      overflow: visible;
      opacity: 1;
      transition: max-height 0.3s ease, opacity 0.3s ease, padding 0.3s ease;
    }

    .subscription-option {
      display: flex;
      padding: 0 30px 30px;
      align-items: stretch;
      justify-content: flex-start;
      background-color: #f9fafd;
      border-top: none;
      border: 2px solid transparent;

      button {
        border: 1px solid rgba(92, 92, 92, .2);
        border-right: none;
        border-radius: 0;
        width: 280px;
        color: var(--text-color);
        text-transform: uppercase;
        cursor:default;
        background-color: #f9fafd;
      }
      
      select {
        padding: 10px 20px;
        border: 1px solid rgba(92, 92, 92, 0.2);
        border-radius: 0px;
        height: auto;
        color: var(--text-color);
        cursor: pointer;
      }
    }

    .subscription-item label[for="subscription-purchase"] {
      border-bottom: none;
    }

    #subscription-purchase:checked ~ .subscription-option {
      border: 2px solid var(--custombulk-color);
      border-top: none;
      border-radius: 0 0 3px 3px;
    }
    .subscription-option {
      border-top: none;
    }
    
    .pdf-upload {
      display: flex;
      justify-content: space-between;
      padding: 18px 18px 18px 48px;
      background-color: #f9fafd;
      overflow: visible;
      opacity: 1;
      transition: max-height 0.3s ease, opacity 0.3s ease, padding 0.3s ease;
      border: 2px solid var(--custombulk-color);
      border-bottom-right-radius: 3px;
      border-bottom-left-radius: 3px;
      border-top: none;
      
      &.show {
        max-height: 200px;
        opacity: 1;
        padding: 18px 18px 18px 48px;
      }

      .upload-design {
        display: flex;
        align-items: center;
        justify-content: space-between;
        width: 100%;

        .flow-step-upload-file {
          display: flex;
          gap: 15px;
          align-items: center;
          justify-content: flex-start;
          width: 100%;
          button {
            width: 200px;
          }
        }
        .template-link {
          white-space: nowrap;
        }
        .pdf-preview-wrapper {
          width: 100%;
          img {
            width:50px;
            display: block;
          }
        }
      }

      .t4s-btn {
        display: block;

        &.file-selected {
          margin-right: 20px;
        }
      }
    }

    #re-order-pdf-upload {
      flex-direction: column;

      .upload-design {
        margin-top: 10px;
      }
    }

    .customer-pdf-list-wrapper {
      display: flex;
      gap: 15px;
      align-content: center;
      justify-content: flex-start;
      flex-wrap: wrap;
      padding: 18px 18px 18px 48px;
      background-color: #f9fafd;
      overflow: visible;
      opacity: 1;
      transition: max-height 0.3s ease, opacity 0.3s ease, padding 0.3s ease;
      position: relative;
      z-index: 5;
      border: 2px solid #547CA9;
      border-bottom-right-radius: 3px;
      border-bottom-left-radius: 3px;
      border-top: none;
      
      &.show {
        max-height: 300px;
        opacity: 1;
        padding: 18px 18px 18px 48px;
      }

      li {
        border: 1px solid rgba(92, 92, 92, 0.2);
        border-radius: 3px;
        padding: 5px;
        cursor: pointer;

        &:hover {
          border-color: rgba(92, 92, 92, 1);
        }
        &.selected {
          border-color: var(--custombulk-color);
        }
      }
    }

    /* Custom Dropdown Styles */
    .custom-dropdown {
      position: relative;
      width: 100%;
      max-width: 400px;
      z-index: 10;
      overflow: visible;

        .custom-dropdown-trigger {
          display: flex;
          align-items: center;
          justify-content: space-between;
          width: 100%;
          padding: 12px 16px;
          border: 1px solid rgba(92, 92, 92, 0.2);
          border-radius: 3px;
          background: white;
          cursor: pointer;
          transition: border-color 0.3s ease, transform 0.2s ease;

          &:hover {
            border-color: rgba(92, 92, 92, 1);
            transform: translateY(-1px);
          }

          &:active {
            transform: translateY(0);
            animation: pulse 0.2s ease;
          }

        .dropdown-text {
          flex: 1;
          text-align: left;
          font-size: 14px;
          color: #333;
          display: flex;
          align-items: center;
          
          canvas {
            border: 1px solid rgba(92, 92, 92, 0.2);
            border-radius: 3px;
            margin-right: 8px;
            flex-shrink: 0;
          }
        }

        .dropdown-arrow {
          transition: transform 0.3s ease;
          margin-left: 8px;
        }

        &.open .dropdown-arrow {
          transform: rotate(180deg);
        }
      }

      .custom-dropdown-menu {
        position: relative;
        background: white;
        border: 1px solid rgba(92, 92, 92, 0.2);
        border-top: none;
        border-radius: 0 0 3px 3px;
        max-height: 0;
        overflow: hidden;
        opacity: 0;
        transform: translateY(-10px);
        z-index: 9999;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
        transition: max-height 0.3s ease, opacity 0.3s ease, transform 0.3s ease;

        &.open {
          max-height: 300px;
          opacity: 1;
          transform: translateY(0);
        }
      }

      .custom-dropdown-item {
        display: flex;
        align-items: center;
        padding: 12px 16px;
        cursor: pointer;
        transition: background-color 0.2s ease, transform 0.2s ease;
        border-bottom: 1px solid rgba(92, 92, 92, 0.1);
        transform: translateX(-10px);
        opacity: 1;
        animation: slideInItem 0.3s ease forwards;

        &:nth-child(1) { animation-delay: 0.05s; }
        &:nth-child(2) { animation-delay: 0.1s; }
        &:nth-child(3) { animation-delay: 0.15s; }
        &:nth-child(4) { animation-delay: 0.2s; }
        &:nth-child(5) { animation-delay: 0.25s; }
        &:nth-child(6) { animation-delay: 0.3s; }

        &:last-child {
          border-bottom: none;
        }

        &:hover {
          background-color: #f5f5f5;
          transform: translateX(0);
        }

        &.selected {
          background-color: #e8f4fd;
          color: var(--custombulk-color);
        }

        .pdf-preview-thumbnail {
          width: 50px;
          height: 50px;
          border: 1px solid rgba(92, 92, 92, 0.2);
          border-radius: 3px;
          margin-right: 12px;
          flex-shrink: 0;
        }

        .pdf-filename {
          flex: 1;
          font-size: 14px;
          line-height: 1.4;
          word-break: break-word;
        }
      }
    }

    /* Keyframe animations */
    @keyframes slideInItem {
      from {
        transform: translateX(-10px);
        opacity: 0;
      }
      to {
        transform: translateX(0);
        opacity: 1;
      }
    }

    @keyframes pulse {
      0% {
        transform: scale(1);
      }
      50% {
        transform: scale(0.98);
      }
      100% {
        transform: scale(1);
      }
    }

    .t4s-btn {
      --pri-cl: var(--custombulk-color);
      --padding-btn: 13px;
      --btn-size: 14px;
      --btn-fw: 700;
      --btn-color-hover: var(--custombulk-color);
      text-transform: uppercase;
    }

    input {
      position: absolute;
      top: 22px;
      left: 20px;
      z-index: 2;
      height: 16px;
      width: 16px;
      accent-color: var(--custombulk-color);
    }

    input.upload-design-file {
      position: relative;
      top: 0;
      left: 0;
      z-index: 2;
      height: auto;
      width: auto;
      accent-color: var(--custombulk-color);
    }

    label {
      display: block;
      padding: 18px 226px 18px 48px;
      background-color: #F9FAFD;
      border: 2px solid #F9FAFD;
      border-radius: 3px;
      border-bottom-right-radius: 0px;
      border-bottom-left-radius: 0px;
      cursor: pointer;
    }

    .extra-item-title {
      display: block;
      line-height: 1.4;
      text-transform: uppercase;
      color: var(--custombulk-color);
    }

    p {
      margin: 4px 0 0;
      font-size: 14px;
      line-height: 1.7;

      a {
        text-decoration: underline;

        &:hover {
          text-decoration: none;
        }
      }
    }

    input:checked + label {
      border-color: var(--custombulk-color);
    }

    #subscription-purchase:checked + label {
      border-bottom: none;
      border-radius: 3px;
    }

    #subscription-purchase + label {
      /*border-bottom: none;*/
    }

    #extra-item-1:checked + label {
      /*border-bottom: none;*/
      border-radius: 3px;
    }

    #extra-item-1 + label {
      /*border-bottom: none;*/
    }

    #first-order-pdf-upload {
      border-top: none;
      border: 2px solid transparent;
    }

    #extra-item-1:checked ~ #first-order-pdf-upload {
      border: 2px solid var(--custombulk-color);
      border-top: none;
      border-radius: 0 0 3px 3px;
    }

    .extra-item-price {
      position: absolute;
      right: 20px;
      top: 20px;
      z-index: 2;
      max-width: 210px;
      line-height: 1.4;
      text-align: right;
    }
  }

  @media screen and (max-width:1200px) {
    .extra-item, .subscription-item {
      label {
        padding-right: 116px;
      }

      .extra-item-price {
        max-width: 100px;
      }
    }
  }

  @media screen and (max-width: 767px) {
    .extra-item, .subscription-item {
      label {
        padding-right: 20px;
      }

      .extra-item-title {
        padding-right: 0;
      }

      .extra-item-price {
        position: static;
        display: block;
        max-width: 100%;
        margin-top: 4px;
        text-align: left;
      }
    }
  }
}

.flow-selection-footer {
  position: absolute;
  bottom: 0;
  left: 0;
  z-index: 10;
  width: 100%;
  padding: 20px;
  background: #fff;
  border-top: 1px solid rgba(92, 92, 92, 0.15);

  .t4s-btn {
  --padding-btn: 13px;
  --btn-size: 14px;
  --btn-fw: 700;

    width: 100%;
    text-transform: uppercase;
  }

  .t4s-btn[disabled] {
    opacity: 0.5;
    cursor: not-allowed;
  }
}

#add-to-cart {
  --padding-btn: 13px;
  --btn-size: 14px;
  --btn-fw: 700;

  width: 100%;
  text-transform: uppercase;
}

#add-to-cart[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ---------------- Custom CSS for bulk order flow ------------------- */
.t4sp-theme .t4s-close-overlay {
  background: rgba(63, 61, 61, 0.2);
}

.t4sp-theme .flow-selection-drawer {
  width: 100% !important;

  .t4s-drawer__close {
    position: absolute;
    top: 0;
    right: 0;

    &:hover {
      background: transparent;
    }
  }
}

@media screen and (min-width: 768px) {
  .t4sp-theme .flow-selection-drawer {
    width: 48% !important;
  }
}

/* Inkara */
.t4s-main-product-inkara {
  .flow-variants {
    .t4s-btn {
      svg {
        color: rgba(148, 89, 63, 0.2);
      }
    }
  }

  .variant-selection {
    .qty-btn {
      background-color: rgba(63, 61, 61, 0.1);
    }
  }
}