/**
 * Georgian Post Courier Shipping - frontend UI
 * Scoped for WooCommerce + CheckoutWC. No global Select2/checkout overrides.
 * @since 1.2.0
 */

:root {
    --gpost-accent: #006aa6;
    --gpost-accent-2: #00a7d7;
    --gpost-success: #0f8a5f;
    --gpost-danger: #c53030;
    --gpost-surface: rgba(255, 255, 255, 0.92);
    --gpost-border: rgba(15, 23, 42, 0.12);
    --gpost-shadow: 0 18px 46px rgba(15, 23, 42, 0.16), 0 4px 14px rgba(15, 23, 42, 0.08);
    --gpost-spring: cubic-bezier(0.2, 1.25, 0.32, 1);
}

.woocommerce-gpost-label {
    align-items: center;
    display: inline-flex;
    gap: 7px;
    line-height: 1.25;
    max-width: 100%;
    vertical-align: middle;
}

.woocommerce-gpost-label-icon {
    display: inline-block;
    flex: 0 0 auto;
    height: auto;
    margin: 0;
    max-height: 13px;
    max-width: 26px;
    vertical-align: middle;
    width: auto;
}

.woocommerce-gpost-label-text {
    display: inline;
    min-width: 0;
}

.gpost-help-tip {
    align-items: center;
    background: linear-gradient(135deg, rgba(0, 106, 166, 0.08), rgba(0, 167, 215, 0.14));
    border: 1px solid rgba(0, 106, 166, 0.32);
    border-radius: 999px;
    box-sizing: border-box;
    color: var(--gpost-accent);
    cursor: help;
    display: inline-flex;
    font-size: 10px;
    font-weight: 700;
    height: 17px;
    justify-content: center;
    line-height: 1;
    margin-left: 6px;
    position: relative;
    vertical-align: middle;
    width: 17px;
}

.gpost-help-tip::after {
    content: "i";
}

.gpost-help-tip::before {
    backdrop-filter: blur(18px) saturate(1.15);
    -webkit-backdrop-filter: blur(18px) saturate(1.15);
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid rgba(15, 23, 42, 0.1);
    border-radius: 12px;
    box-shadow: var(--gpost-shadow);
    box-sizing: border-box;
    color: #1f2937;
    content: attr(data-tooltip);
    font-size: 13px;
    font-weight: 400;
    left: 50%;
    line-height: 1.38;
    margin-bottom: 10px;
    max-width: min(300px, 82vw);
    opacity: 0;
    padding: 10px 12px;
    pointer-events: none;
    position: absolute;
    bottom: 100%;
    text-align: left;
    transform: translate(-50%, 8px) scale(0.98);
    transform-origin: bottom center;
    transition: opacity 180ms ease, transform 240ms var(--gpost-spring);
    white-space: normal;
    width: max-content;
    z-index: 100000;
}

.gpost-help-tip:hover,
.gpost-help-tip:focus {
    outline: none;
}

.gpost-help-tip:hover::before,
.gpost-help-tip:focus::before {
    opacity: 1;
    pointer-events: auto;
    transform: translate(-50%, 0) scale(1);
}

.gpost-city-input {
    transition: border-color 160ms ease, box-shadow 200ms ease, background-color 160ms ease;
}

.gpost-invalid-input {
    border-color: var(--gpost-danger) !important;
    box-shadow: 0 0 0 3px rgba(197, 48, 48, 0.12) !important;
    outline-color: var(--gpost-danger) !important;
}

.gpost-city-valid-input:not(.gpost-invalid-input) {
    border-color: rgba(15, 138, 95, 0.72) !important;
    box-shadow: 0 0 0 3px rgba(15, 138, 95, 0.12) !important;
}

.gpost-error-message {
    color: var(--gpost-danger);
    font-size: 12px;
    line-height: 1.35;
    margin-top: 6px;
}

.gpost-matching-cities-options {
    backdrop-filter: blur(18px) saturate(1.2);
    -webkit-backdrop-filter: blur(18px) saturate(1.2);
    background: var(--gpost-surface);
    border: 1px solid var(--gpost-border);
    border-radius: 16px;
    box-shadow: var(--gpost-shadow);
    box-sizing: border-box;
    color: #111827;
    font-size: 14px;
    line-height: 1.4;
    margin-top: 0;
    opacity: 0;
    overflow-y: auto;
    padding: 6px;
    position: absolute;
    transform: translateY(-5px) scale(0.985);
    transform-origin: top center;
    transition: opacity 150ms ease, transform 260ms var(--gpost-spring);
    z-index: 100000;
}

.gpost-matching-cities-options.gpost-dropdown-ready {
    opacity: 1;
    transform: translateY(0) scale(1);
}

.gpost-city-option,
.gpost-city-option[type="button"] {
    align-items: center;
    appearance: none;
    background: transparent;
    border: 0;
    border-radius: 12px;
    box-shadow: none;
    box-sizing: border-box;
    color: inherit;
    cursor: pointer;
    display: flex;
    font: inherit;
    justify-content: space-between;
    line-height: 1.35;
    margin: 0;
    min-height: 0;
    padding: 11px 12px;
    text-align: left;
    text-decoration: none;
    text-transform: none;
    transform: translateZ(0);
    transition: background 160ms ease, transform 220ms var(--gpost-spring), color 160ms ease;
    width: 100%;
}

.gpost-city-option__text {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}

.gpost-city-option__check {
    align-items: center;
    background: linear-gradient(135deg, var(--gpost-accent), var(--gpost-accent-2));
    border-radius: 999px;
    color: #fff;
    display: inline-flex;
    flex: 0 0 auto;
    font-size: 10px;
    height: 18px;
    justify-content: center;
    margin-left: 10px;
    opacity: 0;
    transform: scale(0.75);
    transition: opacity 160ms ease, transform 220ms var(--gpost-spring);
    width: 18px;
}

.gpost-city-option:hover,
.gpost-city-option:focus,
.gpost-city-option.is-active {
    background: linear-gradient(135deg, rgba(0, 106, 166, 0.08), rgba(0, 167, 215, 0.14));
    color: #0f172a;
    outline: none;
    transform: translateX(2px);
}

.gpost-city-option:hover .gpost-city-option__check,
.gpost-city-option:focus .gpost-city-option__check,
.gpost-city-option.is-active .gpost-city-option__check,
.gpost-city-option.gpost-option-selected .gpost-city-option__check {
    opacity: 1;
    transform: scale(1);
}

.gpost-city-option:active {
    transform: translateX(2px) scale(0.985);
}

.gpost-free-shipping-notice {
    align-items: center;
    background: linear-gradient(135deg, rgba(15, 138, 95, 0.09), rgba(0, 167, 215, 0.08));
    border: 1px solid rgba(15, 138, 95, 0.22);
    border-radius: 12px;
    color: #0f6b4e;
    display: inline-flex;
    font-size: 13px;
    gap: 7px;
    line-height: 1.35;
    margin-top: 7px;
    padding: 7px 10px;
}

.gpost-free-shipping-notice::before {
    align-items: center;
    background: var(--gpost-success);
    border-radius: 999px;
    color: #fff;
    content: "✓";
    display: inline-flex;
    flex: 0 0 auto;
    font-size: 10px;
    height: 17px;
    justify-content: center;
    width: 17px;
}

.cfw-checkout-container .gpost-error-message,
.woocommerce-checkout .gpost-error-message {
    clear: both;
}

.cfw-checkout-container .gpost-matching-cities-options {
    font-size: 15px;
}

@media (prefers-reduced-motion: reduce) {
    .gpost-help-tip::before,
    .gpost-city-input,
    .gpost-matching-cities-options,
    .gpost-city-option,
    .gpost-city-option__check {
        transition: none !important;
    }
}

/* CheckoutWC 11.x shipping row hardening: keep GPost logo/title/price in the same left-aligned flow. */
main.checkoutwc ul.cfw-shipping-methods-list li .cfw-shipping-method-inner input.shipping_method[value^="gpost_courier_shipping_method"] + label,
.checkoutwc ul.cfw-shipping-methods-list li .cfw-shipping-method-inner input.shipping_method[value^="gpost_courier_shipping_method"] + label,
.woocommerce-checkout ul#shipping_method li input.shipping_method[value^="gpost_courier_shipping_method"] + label {
    align-items: center !important;
    display: flex !important;
    flex: 1 1 auto !important;
    gap: 10px !important;
    justify-content: flex-start !important;
    line-height: 1.15 !important;
    min-width: 0 !important;
    white-space: nowrap !important;
    width: 100% !important;
}

main.checkoutwc input.shipping_method[value^="gpost_courier_shipping_method"] + label span,
.checkoutwc input.shipping_method[value^="gpost_courier_shipping_method"] + label span,
.woocommerce-checkout input.shipping_method[value^="gpost_courier_shipping_method"] + label span {
    margin-inline-start: 0 !important;
}

.gpost-label-inline,
.woocommerce-gpost-brand {
    align-items: center;
    display: inline-flex;
    flex: 0 1 auto;
    gap: 10px;
    max-width: 100%;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    vertical-align: middle;
    white-space: nowrap;
}

.gpost-label-title,
.woocommerce-gpost-label-text {
    display: inline-block;
    flex: 0 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.gpost-label-price {
    align-items: center;
    display: inline-flex;
    flex: 0 0 auto;
    gap: 3px;
    white-space: nowrap;
}

.gpost-label-price .woocommerce-Price-amount {
    font-weight: 500;
    white-space: nowrap;
}

.gpost-label-side {
    align-items: center;
    display: inline-flex;
    flex: 0 0 auto;
    gap: 7px;
    margin-left: 0;
    white-space: nowrap;
}

.woocommerce-gpost-logo-mark {
    background-image: url('../gpost.svg');
    background-position: center;
    background-repeat: no-repeat;
    background-size: contain;
    display: inline-block;
    flex: 0 0 43px;
    height: 20px;
    width: 43px;
}

main.checkoutwc .gpost-help-tip,
.checkoutwc .gpost-help-tip,
.woocommerce-checkout .gpost-help-tip {
    flex: 0 0 auto;
    margin-left: 1px;
}

@media (max-width: 480px) {
    main.checkoutwc ul.cfw-shipping-methods-list li .cfw-shipping-method-inner input.shipping_method[value^="gpost_courier_shipping_method"] + label,
    .checkoutwc ul.cfw-shipping-methods-list li .cfw-shipping-method-inner input.shipping_method[value^="gpost_courier_shipping_method"] + label {
        gap: 8px !important;
    }

    .gpost-label-inline,
    .woocommerce-gpost-brand {
        gap: 8px;
    }

    .woocommerce-gpost-logo-mark {
        flex-basis: 36px;
        height: 18px;
        width: 36px;
    }
}

/* v1.2.1 CheckoutWC tooltip hardening. Keep the row stable and the popup visible. */
main.checkoutwc input.shipping_method[value^="gpost_courier_shipping_method"] + label,
.checkoutwc input.shipping_method[value^="gpost_courier_shipping_method"] + label,
.woocommerce-checkout input.shipping_method[value^="gpost_courier_shipping_method"] + label {
    overflow: visible !important;
}

.gpost-label-inline,
.woocommerce-gpost-brand {
    overflow: visible !important;
}

.gpost-label-title,
.woocommerce-gpost-label-text {
    overflow: hidden;
}

.gpost-help-tip {
    isolation: isolate;
    overflow: visible !important;
}

.gpost-help-tip::before {
    left: auto;
    right: -10px;
    transform: translateY(8px) scale(0.98);
    transform-origin: bottom right;
}

.gpost-help-tip:hover::before,
.gpost-help-tip:focus::before {
    transform: translateY(0) scale(1);
}

main.checkoutwc input.shipping_method[value^="gpost_courier_shipping_method"] + label:hover,
.checkoutwc input.shipping_method[value^="gpost_courier_shipping_method"] + label:hover,
.woocommerce-checkout input.shipping_method[value^="gpost_courier_shipping_method"] + label:hover {
    background: transparent !important;
}

/* v1.2.2 tooltip: never cover the shipping option above it and never block clicks. */
.gpost-help-tip,
main.checkoutwc .gpost-help-tip,
.checkoutwc .gpost-help-tip,
.woocommerce-checkout .gpost-help-tip {
    position: relative !important;
    overflow: visible !important;
    z-index: 3;
}

.gpost-help-tip::before,
main.checkoutwc .gpost-help-tip::before,
.checkoutwc .gpost-help-tip::before,
.woocommerce-checkout .gpost-help-tip::before {
    bottom: auto !important;
    top: calc(100% + 8px) !important;
    left: auto !important;
    right: -8px !important;
    margin-bottom: 0 !important;
    max-width: min(240px, 72vw) !important;
    pointer-events: none !important;
    transform: translateY(-4px) scale(0.98) !important;
    transform-origin: top right !important;
    white-space: normal !important;
    z-index: 100000 !important;
}

.gpost-help-tip:hover::before,
.gpost-help-tip:focus::before,
main.checkoutwc .gpost-help-tip:hover::before,
main.checkoutwc .gpost-help-tip:focus::before,
.checkoutwc .gpost-help-tip:hover::before,
.checkoutwc .gpost-help-tip:focus::before,
.woocommerce-checkout .gpost-help-tip:hover::before,
.woocommerce-checkout .gpost-help-tip:focus::before {
    opacity: 1 !important;
    pointer-events: none !important;
    transform: translateY(0) scale(1) !important;
}

main.checkoutwc input.shipping_method[value^="gpost_courier_shipping_method"] + label:hover,
main.checkoutwc input.shipping_method[value^="gpost_courier_shipping_method"] + label:focus,
.checkoutwc input.shipping_method[value^="gpost_courier_shipping_method"] + label:hover,
.checkoutwc input.shipping_method[value^="gpost_courier_shipping_method"] + label:focus,
.woocommerce-checkout input.shipping_method[value^="gpost_courier_shipping_method"] + label:hover,
.woocommerce-checkout input.shipping_method[value^="gpost_courier_shipping_method"] + label:focus {
    background: transparent !important;
}
