@use '_theme.scss';

.item-box-container {
  display: flex;
  position: relative;
  max-height: 1000px;
  transition: max-height 1s 2s;

  &.close-item {
    overflow: hidden;
    max-height: 0;
  }

  .item-box {
    width: 100%;
    padding: 20px;
    border-bottom: 2px solid var(--color-line);
    flex-direction: column;
    position: relative;
    transition: left 1.1s;
    left: 0;
    display: inline-grid;
    grid-template-columns: 20px min-content minmax(0, auto) min-content;
    grid-template-rows: min-content min-content;
    grid-column-gap: 20px;
    grid-row-gap: 0;

    .icon {
      svg {
        path[fill], circle[fill], ellipse[fill], rect[fill] {
          fill: var(--color-icon);
        }

        path[stroke], circle[stroke], ellipse[fill], rect[stroke] {
          stroke: var(--color-icon);
        }
      }
    }

    @media (min-width: theme.$lg) {
      &:not(.has-selection)  {
        grid-template-columns: min-content minmax(0, auto) min-content;
      }
    }

    @media (max-width: theme.$lg) {
      padding: 20px 30px;
      grid-template-columns: min-content minmax(0, auto) min-content;
      grid-template-rows: min-content min-content min-content;
      grid-column-gap: 20px;
      grid-row-gap: 12px;
    }

    @media (max-width: theme.$md) {
      grid-template-columns: min-content minmax(0, 1fr);
      grid-template-rows: min-content min-content min-content min-content;
      grid-column-gap: 20px;
      grid-row-gap: 12px;
    }
    &.move-right {
      left: 110%;
    }

    .cart-item-checkbox-cell {
      align-self: center;

      @media (max-width: theme.$md) {
        display: none;
      }

      @media (max-width: theme.$lg) {
        display: none;
      }

    }

    .item-description {
      display: flex;
      flex-direction: column;
      overflow: hidden;
      height: 100%;

      @media (max-width: theme.$md) {
        grid-row: 2;
        grid-column: 2 / -1;
        width: 100%;

        // CartUnitInfo (Total / Recipients) rendered here on mobile — keep at end of column
        > .cart-quantity-unit-info {
          order: 6;
        }
      }

      .title-box {
        order: 1;
        @media (max-width: theme.$lg) {
          display: none;
        }
      }

      .price {
        display: none;
        order: 2;

        @media (max-width: theme.$md) {
          display: block;
          font-size: var(--text-size-label);
          margin-bottom: 8px;
        }
      }

      .cart-item-properties {
        order:4;
      }

      .total {
        font-size: var(--text-size-regular);
        color: var(--text-color-ultra-dark);
        position: relative;
        top: 5px;
        flex: 1;
        display: flex;
        align-items: flex-end;
        order:5;
        gap: 3px;

        @media (max-width: theme.$md) {
          order:3;
          top:0;
          font-size: var(--text-size-fineprint);
          color: var(--text-color-dark);
          flex:0;
          padding-bottom: 8px;
          .total-quantity, .quantity-units, .total-label, .product-units-singular, .product-units-plural {
            display: none;
          }
        }
      }
    }

    .item-actions {
      display: flex;
      flex-direction: column;
      justify-content: flex-end;
      align-items: center;
      width: 160px;
      min-width: 160px;

      @media (max-width: theme.$md) {
        grid-row: 3;
        grid-column: 1 / -1;
        width: 100%;
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        gap: 12px;

        .cart-quantity-wrapper {
          flex: 1 1 auto;
          min-width: 0;
        }

        .actions-list {
          flex: 0 0 auto;
          width: auto;
          margin-top: 0;
        }

        .bracket-open, .quantity, .quantity-base, .dividing-slash, .pack-singular, .bracket-close {
          display: none;
        }

        // Total rendered in .item-description on mobile — hide duplicate inside .item-actions
        .cart-quantity-unit-info {
          display: none;
        }
      }

      .total {
        display: none;
        color: var(--text-color-ultra-dark);

        // On mobile, Total is rendered in .item-description via CartUnitInfo — keep hidden here
        // (was: display: block on $md before the Total relocation)
        @media (max-width: theme.$md) {
          display: none;
        }
      }

      .price {
        font-size: var(--text-size-label);
        align-self: flex-end;
        margin: 0;

        @media (max-width: theme.$md) {
          display: none;
        }

        &.highlight {
          font-size: var(--text-size-h4);
          color: var(--color-highlight);

          @media (max-width: theme.$lg) {
            font-size: var(--text-size-h4);
          }
        }
      }

    }

    .cart-item-warning-error-messages {
      grid-column: 3;
      grid-row: 2;

      &.warning-in-list-mode{
        grid-column: 2;

        @media (max-width: theme.$lg) {
          grid-column: 1 / -1;
        }

      }

      @media (max-width: theme.$lg) {
        grid-column: 1 / -1;
        grid-row: 4;
      }

      @media (max-width: theme.$md) {
        grid-row: 5;
      }

      @media (min-width: theme.$lg) {
        padding-top: 15px;
      }

    }

    .cart-quantity-error {
      display: flex;
      align-items: center;
      gap: 4px;
      color: var(--color-error);
      font-size: var(--text-size-regular);
      line-height: 1.3;
      padding-top: 20px;

      @media (max-width: theme.$md) {
        padding-top: 0;
        grid-column: 1 / -1;
        grid-row: 4;
      }

      .icon.icon-holder.error-icon {
        display: flex;
        flex-shrink: 0;
        margin-right: 4px;

        svg {
          path[fill]:first-child {
            fill: var(--color-error);
          }
          path[fill]:nth-child(2) {
            fill: white;
          }
        }
      }
    }

    .mobile-title-container {
        display: none;

      @media (max-width: theme.$lg) {
        display: flex;
        flex-direction: column;
        justify-content: flex-start;
        align-items: flex-start;
        grid-row:1;
        grid-column: 1 / -1;

        .mobile-product-name {
          display: flex;

          .cart-item-checkbox-cell {
            margin-top: 5px;
            display: block;
          }

          .nickname-box {
            display: none;
          }
        }


      }
    }
  }
}

.wish-list {
  .item-box {
    .cart-item-warning-error-messages {
      @media (min-width: theme.$lg) {
        grid-column: 2;
      }
    }
  }
}
