/*
 * Novarune – Product Page Custom Fields (customer view)
 * - Styles the "Customize Your Order" card
 * - Provides a modern theme for jQuery UI datepicker inside this section only
 * - Tries to inherit the site’s primary color via common CSS vars
 */

.novr-sched-plugin-wrap .novr-sched-custom-fields {
  /* Inherit from Bricks Add to Cart element and global theme */
  --novr-primary: var(--bricks-color-primary, var(--woocommerce-primary, #1e62d0));
  --novr-secondary: var(--bricks-color-secondary, #fc5778);
  --novr-text-dark: var(--bricks-text-dark, #212121);
  --novr-text-medium: var(--bricks-text-medium, #616161);
  --novr-text-light: var(--bricks-text-light, #9e9e9e);
  --novr-border-color: var(--bricks-border-color, rgba(0,0,0,0.08));
  --novr-border-radius: var(--bricks-border-radius, 4px);
  --novr-bg-light: var(--bricks-bg-light, #f5f6f7);
  --novr-transition: var(--bricks-transition, all 0.2s);

  /* Inherit styling from parent Bricks Add to Cart element */
  background: inherit;
  border: inherit;
  border-radius: inherit;
  padding: 20px;
  margin: 20px 0;
  font-family: inherit;
  color: inherit;
}

.novr-sched-plugin-wrap .novr-sched-custom-fields h4 {
  margin: 0 0 12px 0;
  font-size: 20px;
  line-height: 1.3;
  color: inherit;
  font-weight: 600;
}

.novr-sched-plugin-wrap .novr-sched-custom-fields .novr-form-row {
  margin-bottom: 16px;
}

.novr-sched-plugin-wrap .novr-sched-custom-fields label {
  display: block;
  margin: 0 0 6px 0;
  font-weight: 600;
}

.novr-sched-plugin-wrap .novr-sched-custom-fields input[type="text"],
.novr-sched-plugin-wrap .novr-sched-custom-fields textarea {
  width: 100%;
  border: 1px solid var(--novr-border-color);
  border-radius: var(--novr-border-radius);
  padding: 10px 12px;
  font-size: 16px; /* Prevents iOS auto-zoom on focus */
  background: inherit;
  transition: var(--novr-transition);
  color: inherit;
}

.novr-sched-plugin-wrap .novr-sched-custom-fields textarea { min-height: 90px; resize: vertical; }

.novr-sched-plugin-wrap .novr-sched-custom-fields input[type="text"]:focus,
.novr-sched-plugin-wrap .novr-sched-custom-fields textarea:focus {
  outline: none;
  border-color: var(--novr-primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--novr-primary) 20%, transparent);
}

.novr-sched-plugin-wrap .novr-sched-custom-fields small.description,
.novr-sched-plugin-wrap .novr-sched-custom-fields .description {
  display: block;
  margin-top: 6px;
  color: #666;
}

/* jQuery UI datepicker inside product form */
.novr-sched-plugin-wrap .novr-sched-custom-fields .ui-datepicker {
  width: 100%;
  border: 1px solid var(--novr-border);
  border-radius: 8px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.04);
  padding: 6px;
  background: inherit;
  font-size: inherit;
}

.novr-sched-plugin-wrap .novr-sched-custom-fields .ui-datepicker .ui-datepicker-header {
  background: var(--novr-primary);
  color: #fff;
  border: 0;
  border-radius: 6px;
  padding: 8px 10px;
}

.novr-sched-plugin-wrap .novr-sched-custom-fields .ui-datepicker .ui-datepicker-title select { color: #222; }

.novr-sched-plugin-wrap .novr-sched-custom-fields .ui-datepicker .ui-datepicker-prev,
.novr-sched-plugin-wrap .novr-sched-custom-fields .ui-datepicker .ui-datepicker-next {
  top: 6px;
  width: 28px; height: 28px;
  border-radius: 4px;
}

.novr-sched-plugin-wrap .novr-sched-custom-fields .ui-datepicker table {
  width: 100%;
  margin: 6px 0 0 0;
}

.novr-sched-plugin-wrap .novr-sched-custom-fields .ui-datepicker th {
  color: #666;
  font-weight: 600;
}

.novr-sched-plugin-wrap .novr-sched-custom-fields .ui-datepicker td a,
.novr-sched-plugin-wrap .novr-sched-custom-fields .ui-datepicker td span {
  display: block;
  padding: 8px 0;
  line-height: 1;
  text-align: center;
  border-radius: 6px;
  border: 0;
  background: #f6f7f9;
  color: #222;
}

.novr-sched-plugin-wrap .novr-sched-custom-fields .ui-state-active,
.novr-sched-plugin-wrap .novr-sched-custom-fields .ui-datepicker td .ui-state-active {
  background: var(--novr-primary) !important;
  color: #fff !important;
}

.novr-sched-plugin-wrap .novr-sched-custom-fields .ui-state-hover,
.novr-sched-plugin-wrap .novr-sched-custom-fields .ui-datepicker td .ui-state-hover {
  background: var(--novr-primary-600) !important;
  color: #fff !important;
}

.novr-sched-plugin-wrap .novr-sched-custom-fields .ui-state-disabled { opacity: .5; }

/* File input alignment */
.novr-sched-plugin-wrap .novr-sched-custom-fields input[type="file"] {
  width: 100%;
}

/* Image preview (scoped) */
.novr-sched-plugin-wrap .novr-image-preview {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
}
.novr-sched-plugin-wrap .novr-image-preview img {
  max-width: 96px;
  max-height: 96px;
  border-radius: 6px;
  border: 1px solid var(--novr-border, rgba(0,0,0,0.08));
  object-fit: cover;
}
.novr-sched-plugin-wrap .novr-image-preview .button.novr-remove-image {
  line-height: 1.8;
}

/* Mobile: Smaller preview on phones */
@media (max-width: 480px) {
  .novr-sched-plugin-wrap .novr-image-preview img {
    max-width: 80px;
    max-height: 80px;
  }
}

/* Enhanced Custom Fields System */
.novr-custom-fields-container {
    margin: 20px 0;
    padding: 0;
}

.novr-custom-field-wrapper {
    margin-bottom: 20px;
    border: inherit;
    padding: 15px;
    background: inherit;
    border-radius: inherit;
    box-shadow: inherit;
    transition: var(--novr-transition);
}

.novr-custom-field-wrapper.has-error {
    border-color: #d63638;
    background: #fef7f7;
}

.novr-field-label {
    display: block;
    font-weight: 600;
    margin-bottom: 8px;
    color: inherit;
    font-size: inherit;
}

.novr-field-label .required {
    color: #d63638;
    margin-left: 4px;
}

.novr-field-description {
    font-size: 12px;
    color: #666;
    margin-bottom: 10px;
    line-height: inherit;
}

/* Text and Textarea Fields */
.novr-text-field,
.novr-textarea-field {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--novr-border-color);
    border-radius: var(--novr-border-radius);
    font-size: inherit;
    line-height: inherit;
    background: rgba(255,255,255,0.9);
    color: inherit;
    transition: var(--novr-transition);
}

.novr-text-field:focus,
.novr-textarea-field:focus {
    outline: none;
    border-color: var(--novr-primary);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--novr-primary) 20%, transparent);
}

.novr-textarea-field {
    resize: vertical;
    min-height: 80px;
}

/* Radio Button Fields */
.novr-radio-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Radio Button Layout Variations */
.novr-radio-layout-horizontal {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 15px;
}

/* Mobile: Stack radio buttons vertically for better UX */
@media (max-width: 768px) {
    .novr-radio-layout-horizontal {
        flex-direction: column;
        gap: 10px;
    }
}

.novr-radio-option {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 0;
}

.novr-radio-input {
    margin: 0;
}

.novr-radio-label {
    font-weight: normal;
    margin: 0;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-grow: 1;
    color: inherit;
}

.novr-option-price {
    font-size: 12px;
    color: #666;
    font-weight: normal;
}

/* Checkbox Fields */
.novr-checkbox-group {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

/* Checkbox Layout Variations */
.novr-checkbox-layout-horizontal {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 15px;
}

.novr-checkbox-layout-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 8px;
}

/* Mobile: Single column for checkboxes on small screens */
@media (max-width: 480px) {
    .novr-checkbox-layout-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }
}

.novr-checkbox-option {
    display: flex;
    align-items: center;
    gap: 8px;
}

.novr-checkbox-input {
    margin: 0;
}

.novr-checkbox-label {
    font-weight: normal;
    margin: 0;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-grow: 1;
    color: inherit;
}

.novr-selection-limits {
    font-size: 11px;
    color: #666;
    margin-top: 5px;
    font-style: italic;
}

/* Error Messages */
.novr-custom-field-wrapper.has-error {
    border: 1px solid var(--woocommerce-error, #d63638);
    background: var(--woocommerce-error-background, #fff7f1);
    border-radius: 6px;
    padding: 12px;
}

.novr-custom-field-wrapper.has-error .novr-field-label,
.novr-custom-field-wrapper.has-error label {
    color: var(--woocommerce-error, #d63638);
}

.novr-custom-field-wrapper.has-error input,
.novr-custom-field-wrapper.has-error select,
.novr-custom-field-wrapper.has-error textarea,
.novr-custom-field-wrapper.has-error .novr-file-upload-wrapper {
    border-color: var(--woocommerce-error, #d63638);
    box-shadow: 0 0 0 1px rgba(214, 54, 56, 0.2);
}

.novr-custom-field-wrapper.has-error .novr-field-error-message {
    margin-top: 8px;
    background: rgba(214, 54, 56, 0.1);
    border: 1px solid var(--woocommerce-error, #d63638);
    border-radius: 4px;
    padding: 6px 10px;
    color: var(--woocommerce-error, #d63638);
    font-size: 13px;
    word-wrap: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
}

/* Accessibility improvements */
.novr-radio-input:focus + .novr-radio-label,
.novr-checkbox-input:focus + .novr-checkbox-label {
    outline: 2px solid var(--novr-primary, #1e62d0);
    outline-offset: 2px;
}

/* Integration with WooCommerce themes */
.woocommerce .novr-custom-fields-container {
    margin: 20px 0;
}

.woocommerce div.product form.cart .novr-custom-fields-container {
    margin-bottom: 20px;
}

/* Bricks Builder Add to Cart element styling inheritance */
.brxe-product-add-to-cart .novr-sched-custom-fields {
    /* Inherit all styling from Bricks Add to Cart element */
    background: inherit !important;
    border: inherit !important;
    border-radius: inherit !important;
    padding: inherit !important;
    margin: inherit !important;
    font-family: inherit !important;
    font-size: inherit !important;
    color: inherit !important;
    box-shadow: inherit !important;
}

.brxe-product-add-to-cart .novr-custom-field-wrapper {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
}

.brxe-product-add-to-cart .novr-field-label,
.brxe-product-add-to-cart .novr-custom-field-label,
.brxe-product-add-to-cart .novr-radio-label,
.brxe-product-add-to-cart .novr-checkbox-label {
    color: inherit !important;
    font-family: inherit !important;
    font-size: inherit !important;
}

.brxe-product-add-to-cart .novr-text-field,
.brxe-product-add-to-cart .novr-textarea-field,
.brxe-product-add-to-cart input[type="text"],
.brxe-product-add-to-cart textarea {
    background: rgba(255,255,255,0.1) !important;
    border-color: currentColor !important;
    color: inherit !important;
    font-family: inherit !important;
    font-size: inherit !important;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .novr-custom-field-wrapper {
        border-color: #000;
        background: inherit;
    }

    .novr-custom-field-wrapper.has-error {
        border-color: #d63638;
        background: inherit;
    }

    .novr-field-label {
        color: #000;
    }

    .novr-field-description {
        color: #333;
    }
}

/* Responsive */
@media (max-width: 768px) {
    .novr-custom-field-wrapper {
        padding: 12px;
        margin-bottom: 15px;
    }

    .novr-text-field,
    .novr-textarea-field {
        font-size: 16px; /* Prevent zoom on iOS */
    }
}

@media (min-width: 768px) {
  .novr-sched-plugin-wrap .novr-sched-custom-fields { padding: 24px; }
}

/* Cart Display Formatting - Force separate lines for each field */

/* Standard WooCommerce cart item data display */
.cart_item .product-name dl,
.cart_item .product-name .wc-item-meta {
    margin: 8px 0 !important;
}

.cart_item .product-name dl dt,
.cart_item .product-name .wc-item-meta dt {
    display: inline !important;
    font-weight: 600 !important;
    margin-right: 4px !important;
}

.cart_item .product-name dl dd,
.cart_item .product-name .wc-item-meta dd {
    display: block !important;
    margin: 4px 0 !important;
    padding: 0 !important;
    line-height: 1.4 !important;
}

/* Force line breaks between each meta item */
.cart_item .product-name .wc-item-meta p,
.cart_item .product-name .variation p {
    display: block !important;
    margin: 4px 0 !important;
    line-height: 1.4 !important;
}

/* Bricks Builder specific styling */
.brxe-cart .cart_item .product-name dl,
.brxe-woocommerce-cart .cart_item .product-name dl,
.brxe-cart .cart_item .product-name .wc-item-meta,
.brxe-woocommerce-cart .cart_item .product-name .wc-item-meta {
    display: block !important;
    margin: 8px 0 !important;
}

.brxe-cart .cart_item .product-name dl dd,
.brxe-woocommerce-cart .cart_item .product-name dl dd,
.brxe-cart .cart_item .product-name .wc-item-meta dd,
.brxe-woocommerce-cart .cart_item .product-name .wc-item-meta dd {
    display: block !important;
    margin: 4px 0 !important;
    padding: 0 !important;
}

/* Ensure each custom field appears on its own line */
.cart_item .product-name .variation,
.cart_item .product-name .wc-item-meta-li {
    display: block !important;
    margin: 6px 0 !important;
    border-bottom: none !important;
    padding-bottom: 2px !important;
}

th > dl > dd > p {
    font-weight: 400;
}

dl.variation {
    flex-direction: column;
}
