// Subscription Product Display Styles

#woocommerce-product-data .arraysubs-fixed-end-heading {
  padding-bottom: 0 !important;
  margin-bottom: 0 !important;
}

.arraysubs-product-info {
  margin: 15px 0;
  padding: 15px;
  background: #f9f9f9;
  border-left: 3px solid #96588a;
  border-radius: 3px;

  .subscription-terms {
    p {
      margin: 0 0 8px 0;
      font-size: 14px;
      color: #555;

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

    .subscription-pricing {
      font-weight: 600;
      font-size: 16px;
      color: #333;
    }

    .subscription-length {
      font-size: 13px;
      color: #666;
    }
  }
}

#_arraysubs_shipping_type {
  width: 100%;
}

.arraysubs-custom-helptext {
  display: block !important;
  clear: both !important;
  margin: 6px 0 0 0 !important;
  font-size: 11px !important;
  line-height: 1.5 !important;
}

.arraysubs-product-helper-links {
  margin: 8px 0;

  &__header {
    margin-bottom: 0;
    font-size: 12px;
    letter-spacing: 0.04em;
    line-height: 1;
    opacity: 0;
  }

  &__row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
    min-width: 0;

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

  &__meta {
    display: flex;
    flex: 0 0 142px;
    flex-direction: column;
    gap: 2px;
    max-width: 142px;
  }

  &__label {
    font-size: 12px;
    font-weight: 600;
    color: #1d2327;
    line-height: 1.3;
  }

  &__copy-link {
    font-size: 9px;
    line-height: 1.2;
    text-decoration: none;
  }

  &__input {
    flex: 1 1 auto;
    width: auto;
    min-width: 0;
    min-height: 28px;
    padding: 4px 8px;
    border: 1px solid #8c8f94;
    border-radius: 3px;
    background: #fff;
    font-size: 11px;
    line-height: 1.2;
  }

  &__separator {
    margin: 8px 0;
    width: 100%;
    border: 0;
    border-top: 1px solid #dcdcde;
  }

  &--variation {
    margin: 6px 0;
  }
}

.arraysubs-product-list-indicator {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;

  &__tag {
    display: inline-flex;
    align-items: center;
    min-height: 20px;
    padding: 2px 8px;
    border-radius: 999px;
    background: #ede7f6;
    color: #5b3f8c;
    font-size: 11px;
    font-weight: 600;
    line-height: 1.4;

    &--type {
      background: #e7f0ff;
      color: #1d4f91;
    }

    &--subscription {
      background: #ede7f6;
      color: #5b3f8c;
    }

    &--trial {
      background: #e6f4ea;
      color: #1a6b2e;
    }
  }
}

.arraysubs-price-info {
  margin-top: 4px;
  line-height: 1.5;

  &__row {
    font-size: 11px;
    color: #646970;
    line-height: 1.4;
    margin-top: 2px;

    &--schedule {
      color: #50575e;
      font-weight: 500;
    }

    &--signup {
      color: #2271b1;
    }

    &--renewal {
      color: #996800;
    }
  }

  &__schedule {
    font-style: italic;
  }

  &__sep {
    opacity: 0.6;
  }
}

.wp-list-table .column-name {
  .arraysubs-product-list-indicator {
    line-height: 1;
  }
}
// Product Edit Page Styles
#arraysubs_product_data {
  display: none; // Hide by default, shown when subscription product type is selected
  .options_group {
    padding: 12px;
  }

  .hidden {
    display: none !important;
  }

  input[type="number"].short {
    width: 150px;
  }

  // Modern card layout inside the Subscription tab panel
  .arraysubs-simple-fields {
    margin: 12px;
  }
}

.woocommerce_variation,
#general_product_data {
  .arraysubs-product-helper-links {
    .arraysubs-product-helper-links__row {
      flex-wrap: nowrap;
    }
  }
}

#general_product_data .arraysubs-product-helper-links {
  margin: 8px 12px;
}

@media (max-width: 1200px) {
  .arraysubs-product-helper-links {
    &__row {
      flex-wrap: wrap;
    }

    &__label {
      max-width: none;
    }

    &__meta {
      flex-basis: 100%;
      max-width: none;
    }

    &__input {
      flex-basis: 100%;
    }
  }
}

// Variation Fields - Improved Layout
// Shared by variation rows and the simple product Subscription tab panel
// (.arraysubs-simple-fields) so both render the same modern card layout.
.arraysubs-variation-fields,
.arraysubs-simple-fields {
  padding: 15px;
  background: #f8f9fa;
  border: 1px solid #c3c4c7;
  border-radius: 4px;
  margin: 12px 0;

  .show_if_variation_subscription,
  .show_if_variation_renewal_price,
  .show_if_subscription,
  .show_if_renewal_price {
    transition: all 0.2s ease;
  }

  // Section styling
  .arraysubs-variation-section {
    margin-bottom: 16px;
    padding-bottom: 16px;
    border-bottom: 1px solid #c3c4c7;

    &:last-child {
      margin-bottom: 0;
      padding-bottom: 0;
      border-bottom: none;
    }

    &.arraysubs-variation-header {
      margin-bottom: 12px;
      padding-bottom: 12px;
    }
  }

  // Section title
  .arraysubs-section-title {
    font-weight: 600;
    font-size: 13px;
    color: #1d2327;
    margin-bottom: 12px;
  }

  // Section description
  .arraysubs-section-description {
    display: block;
    font-size: 12px;
    color: #646970;
    margin-bottom: 8px;
    line-height: 1.4;
  }

  // Checkbox label styling
  .arraysubs-checkbox-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    // Neutralize WooCommerce options-panel label floats (simple product panel)
    float: none;
    width: auto;
    margin: 0;
    padding: 0;
    font-weight: 500;
    cursor: pointer;

    input[type="checkbox"] {
      float: none;
      width: 16px;
      height: 16px;
      margin: 0;
    }

    &.arraysubs-checkbox-disabled {
      cursor: default;
      opacity: 0.7;

      input[type="checkbox"] {
        cursor: not-allowed;
      }

      .arraysubs-controlled-note {
        font-weight: 400;
        font-size: 11px;
        color: #888;
        font-style: italic;
      }
    }
  }

  // Price info display
  .arraysubs-variation-price-info {
    .arraysubs-price-display {
      display: flex;
      flex-wrap: wrap;
      gap: 16px;
      margin-top: 8px;
      padding: 10px;
      background: #fff;
      border: 1px solid #c3c4c7;
      border-radius: 3px;
    }

    .arraysubs-variation-regular-price-display,
    .arraysubs-variation-sale-price-display {
      display: inline-flex;
      align-items: center;
      gap: 6px;
      font-size: 13px;

      strong {
        color: #50575e;
        font-weight: 500;
      }

      .price-value {
        color: #1d2327;
      }

      .sale-schedule {
        font-size: 11px;
        color: #646970;
        margin-left: 4px;
      }
    }
  }

  // Two-column row layout (matching WooCommerce variation fields)
  .arraysubs-variation-row {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
  }

  // Column system
  .arraysubs-variation-col {
    display: flex;
    flex-direction: column;
    gap: 4px;

    // Half width column (50%)
    &.arraysubs-variation-col-half {
      flex: 0 0 calc(50% - 6px);
      max-width: calc(50% - 6px);
    }

    // Full width column (100%)
    &.arraysubs-variation-col-full {
      flex: 0 0 100%;
      max-width: 100%;
    }

    // Split column (two items side by side within a column)
    .arraysubs-variation-col-split {
      display: flex;
      gap: 12px;

      .arraysubs-variation-col-split-item {
        flex: 1;
        display: flex;
        flex-direction: column;
        gap: 4px;
      }
    }

    label {
      // Neutralize WooCommerce options-panel label floats (simple product panel)
      display: block;
      float: none;
      width: auto;
      padding: 0;
      margin: 0 0 2px;
      font-size: 12px;
      font-weight: 500;
      color: #1d2327;
    }

    input[type="number"],
    input[type="text"],
    select {
      width: 100%;
      height: auto;
      padding: 6px 8px;
      border: 1px solid #8c8f94;
      border-radius: 3px;
      font-size: 13px;
      line-height: 1.4;
      background-color: #fff;
      box-sizing: border-box;

      &:focus {
        border-color: #2271b1;
        box-shadow: 0 0 0 1px #2271b1;
        outline: none;
      }
    }

    .description {
      display: block;
      margin: 0;
      font-size: 11px;
      font-style: normal;
      color: #646970;
      line-height: 1.3;
    }
  }

  // Legacy field classes (keep for backward compatibility)
  .arraysubs-variation-field {
    display: flex;
    flex-direction: column;
    gap: 4px;

    label {
      font-size: 12px;
      font-weight: 500;
      color: #1d2327;
      margin-bottom: 2px;
    }

    input[type="number"],
    input[type="text"],
    select {
      width: 100%;
      padding: 6px 8px;
      border: 1px solid #8c8f94;
      border-radius: 3px;
      font-size: 13px;
      line-height: 1.4;
      background-color: #fff;
      box-sizing: border-box;

      &:focus {
        border-color: #2271b1;
        box-shadow: 0 0 0 1px #2271b1;
        outline: none;
      }
    }

    .description {
      font-size: 11px;
      color: #646970;
      line-height: 1.3;
    }
  }
}

// Responsive: the card measures its own width (container query), because the
// panel width depends on the admin sidebar/postbox layout, not the viewport.
.arraysubs-variation-fields,
.arraysubs-simple-fields {
  container-type: inline-size;
}

@container (max-width: 500px) {
  .arraysubs-variation-col.arraysubs-variation-col-half {
    flex: 0 0 100% !important;
    max-width: 100% !important;
  }
}

@container (max-width: 380px) {
  .arraysubs-variation-col .arraysubs-variation-col-split {
    flex-direction: column;
    gap: 12px;
  }

  .arraysubs-variation-price-info .arraysubs-price-display {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }
}

// Fallback for browsers without container query support
@supports not (container-type: inline-size) {
  @media (max-width: 960px) {
    .arraysubs-variation-fields,
    .arraysubs-simple-fields {
      .arraysubs-variation-col.arraysubs-variation-col-half {
        flex: 0 0 100%;
        max-width: 100%;
      }

      .arraysubs-variation-price-info .arraysubs-price-display {
        flex-direction: column;
        align-items: flex-start;
        gap: 6px;
      }
    }
  }
}

// Cart & Checkout
.woocommerce-cart,
.woocommerce-checkout {
  .subscription-schedule {
    small {
      display: block;
      color: #666;
      font-size: 0.9em;
      margin-top: 3px;
    }
  }
}
