/*
 * Service product styling.
 * All rules are scoped under body.service-product-page, which is added by
 * Era_ServiceProduct/js/order-number only on service-product pages, so other
 * products are never affected.
 */

/* Order-number field on its own row on top; price and the qty / add-to-cart
   controls share the next row. The price sizes to its content and the form
   takes the remaining width, so they fit on one row without overlapping.
   Selectors include .product-info-main to outrank the theme's fixed 200px
   width / float rules on the price and form. */
body.service-product-page .product-info-main .buy-it-container {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
}

body.service-product-page .product-info-main .buy-it-container > .era-service-order-number {
    order: 1;
    flex: 1 1 100%;
    width: 100%;
}

body.service-product-page .product-info-main .buy-it-container .product-info-price {
    order: 2;
    float: none;
    flex: 0 0 auto;
    width: auto;
    margin: 0 20px 0 0;
    white-space: nowrap;
}

body.service-product-page .product-info-main .buy-it-container .product-add-form {
    order: 3;
    float: none;
    flex: 1 1 auto;
    width: auto;
    /* allow the form to shrink so it stays on the same row as the price */
    min-width: 0;
    clear: none;
}

/* Neutralise the clearfix pseudo-elements as flex items. */
body.service-product-page .product-info-main .buy-it-container::after,
body.service-product-page .product-info-main .buy-it-container .product-add-form::after {
    display: none;
}

/* Order-number field */
body.service-product-page .era-service-order-number {
    margin-bottom: 20px;
    padding-bottom: 20px;
    border-bottom: 1px solid #d9d9d9;
}

body.service-product-page .era-order-number-heading {
    display: flex;
    align-items: center;
    margin-bottom: 8px;
}

body.service-product-page .era-order-number-label {
    margin: 0;
    font-weight: 700;
}

/* Tooltip */
body.service-product-page .era-order-number-tooltip {
    position: relative;
    display: inline-flex;
    margin-left: 8px;
}

body.service-product-page .era-tooltip-toggle {
    width: 18px;
    height: 18px;
    padding: 0;
    border: 1px solid #2f5d3f;
    border-radius: 50%;
    background: #fff;
    color: #2f5d3f;
    font-size: 12px;
    font-weight: 700;
    line-height: 16px;
    text-align: center;
    cursor: pointer;
}

body.service-product-page .era-tooltip-content {
    display: none;
    position: absolute;
    left: 50%;
    bottom: calc(100% + 10px);
    transform: translateX(-50%);
    width: 260px;
    max-width: 78vw;
    padding: 10px 12px;
    background: #333;
    color: #fff;
    border-radius: 4px;
    font-size: 13px;
    font-weight: 400;
    line-height: 1.4;
    text-align: left;
    white-space: normal;
    z-index: 20;
}

/* Little arrow under the bubble */
body.service-product-page .era-tooltip-content::after {
    content: "";
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: #333;
}

body.service-product-page .era-order-number-tooltip:hover .era-tooltip-content,
body.service-product-page .era-tooltip-toggle:focus + .era-tooltip-content {
    display: block;
}

body.service-product-page .era-order-number-field {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: stretch;
}

body.service-product-page .era-order-number-input {
    flex: 1 1 180px;
    min-width: 0;
    height: 44px;
}

body.service-product-page .era-order-number-submit {
    flex: 0 0 auto;
    height: 44px;
    padding: 0 20px;
    background: #2f5d3f;
    border: 1px solid #2f5d3f;
    color: #fff;
    cursor: pointer;
    white-space: nowrap;
    transition: background-color .2s ease;
}

body.service-product-page .era-order-number-submit:hover {
    background: #26492f;
}

/* Validation messages */
body.service-product-page .era-order-number-message {
    margin-top: 8px;
    font-size: 14px;
    min-height: 1em;
}

body.service-product-page .era-service-order-number.has-error .era-order-number-message {
    color: #e02b27;
}

body.service-product-page .era-service-order-number.has-success .era-order-number-message {
    color: #2f5d3f;
}

body.service-product-page .era-service-order-number.has-error .era-order-number-input {
    border-color: #e02b27;
}

body.service-product-page .era-service-order-number.is-confirmed .era-order-number-input {
    border-color: #2f5d3f;
    background: #f3f8f4;
}

/* Show a check mark once confirmed */
body.service-product-page .era-service-order-number.is-confirmed .era-order-number-submit span::before {
    content: "\2713 ";
}

/* Disabled add-to-cart state while the order number is not confirmed */
body.service-product-page .box-tocart .action.tocart[disabled],
body.service-product-page .box-tocart .action.tocart.disabled {
    opacity: .5;
    cursor: not-allowed;
}
