/**
 * NACIFY CJ Live Shipping — frontend styles.
 * Namespaced to .nacify-cj-shipping — never touches WoodMart/WooCommerce globals.
 */
.nacify-cj-shipping {
    --nacify-primary: #0B3A8C;
    --nacify-secondary: #143471;
    --nacify-accent: #395077;
    --nacify-background: #F5F5F5;
    --nacify-surface: #FFFFFF;
    --nacify-text: #15171A;
    --nacify-secondary-text: #395077;
    --nacify-border: #D7D8DA;
    --nacify-light-accent: #BEC4CC;

    background: var(--nacify-surface);
    border: 1px solid var(--nacify-border);
    border-radius: 10px;
    padding: 16px;
    margin: 16px 0;
    color: var(--nacify-text);
    font-size: 14px;
    line-height: 1.45;
    box-sizing: border-box;
}

.nacify-cj-shipping *,
.nacify-cj-shipping *::before,
.nacify-cj-shipping *::after {
    box-sizing: border-box;
}

.nacify-cj-shipping__header {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 15px;
    font-weight: 500;
    margin-bottom: 14px;
    color: var(--nacify-text);
}

.nacify-cj-shipping__header svg {
    color: var(--nacify-primary);
    flex: none;
}

.nacify-cj-shipping__label {
    font-size: 12px;
    color: var(--nacify-secondary-text);
    margin: 12px 0 6px;
}

.nacify-cj-shipping__label:first-of-type {
    margin-top: 0;
}

/* Warehouse cards */
.nacify-cj-shipping__warehouses {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.nacify-cj-shipping__wh {
    display: flex;
    align-items: center;
    gap: 10px;
    border: 1px solid var(--nacify-border);
    border-radius: 8px;
    padding: 10px 12px;
    cursor: pointer;
    transition: border-color .15s ease, background .15s ease;
    background: var(--nacify-surface);
    position: relative;
}

.nacify-cj-shipping__wh:hover {
    border-color: var(--nacify-light-accent);
}

.nacify-cj-shipping__wh.selected {
    border-color: var(--nacify-primary);
    background: var(--nacify-background);
}

.nacify-cj-shipping__wh.disabled {
    opacity: .45;
    cursor: not-allowed;
}

.nacify-cj-shipping__wh input[type="radio"],
.nacify-cj-shipping__rate input[type="radio"] {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.nacify-cj-shipping__wh-radio {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 1.5px solid var(--nacify-light-accent);
    flex: none;
    display: flex;
    align-items: center;
    justify-content: center;
}

.nacify-cj-shipping__wh.selected .nacify-cj-shipping__wh-radio,
.nacify-cj-shipping__rate.selected .nacify-cj-shipping__wh-radio {
    border-color: var(--nacify-primary);
}

.nacify-cj-shipping__wh-radio::after {
    content: "";
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--nacify-primary);
    opacity: 0;
}

.nacify-cj-shipping__wh.selected .nacify-cj-shipping__wh-radio::after,
.nacify-cj-shipping__rate.selected .nacify-cj-shipping__wh-radio::after {
    opacity: 1;
}

.nacify-cj-shipping__wh-body {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.nacify-cj-shipping__wh-name {
    font-size: 14px;
    font-weight: 500;
    color: var(--nacify-text);
}

.nacify-cj-shipping__wh-stock {
    font-size: 12px;
    color: var(--nacify-secondary-text);
    margin-top: 1px;
}

.nacify-cj-shipping__wh-tag {
    margin-left: auto;
    font-size: 11px;
    color: var(--nacify-primary);
    border: 1px solid var(--nacify-primary);
    border-radius: 6px;
    padding: 1px 6px;
    white-space: nowrap;
}

/* Destination grid */
.nacify-cj-shipping__grid {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.nacify-cj-shipping__field {
    flex: 1;
    min-width: 120px;
}

.nacify-cj-shipping__field--qty {
    max-width: 84px;
}

.nacify-cj-shipping__field label {
    display: block;
    font-size: 12px;
    color: var(--nacify-secondary-text);
    margin-bottom: 4px;
}

.nacify-cj-shipping__field select,
.nacify-cj-shipping__field input {
    width: 100%;
    padding: 8px 10px;
    border-radius: 8px;
    border: 1px solid var(--nacify-border);
    background: var(--nacify-surface);
    color: var(--nacify-text);
    font-size: 14px;
    height: auto;
}

.nacify-cj-shipping__field select:focus,
.nacify-cj-shipping__field input:focus {
    outline: 2px solid var(--nacify-primary);
    outline-offset: 1px;
    border-color: var(--nacify-primary);
}

/* Rates */
.nacify-cj-shipping__rates {
    margin-top: 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.nacify-cj-shipping__rate {
    display: flex;
    align-items: center;
    gap: 10px;
    border: 1px solid var(--nacify-border);
    border-radius: 8px;
    padding: 10px 12px;
    cursor: pointer;
    transition: border-color .15s ease, background .15s ease;
    position: relative;
    background: var(--nacify-surface);
}

.nacify-cj-shipping__rate:hover {
    border-color: var(--nacify-light-accent);
}

.nacify-cj-shipping__rate.selected {
    border-color: var(--nacify-primary);
    background: var(--nacify-background);
}

.nacify-cj-shipping__rate-body {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.nacify-cj-shipping__rate-name {
    font-size: 14px;
    font-weight: 500;
    color: var(--nacify-text);
}

.nacify-cj-shipping__rate-days {
    font-size: 12px;
    color: var(--nacify-secondary-text);
    margin-top: 2px;
}

.nacify-cj-shipping__rate-price {
    margin-left: auto;
    font-size: 15px;
    font-weight: 500;
    color: var(--nacify-primary);
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.nacify-cj-shipping__rate-rec {
    position: absolute;
    top: -8px;
    right: 10px;
    font-size: 10px;
    letter-spacing: .04em;
    background: var(--nacify-primary);
    color: #fff;
    border-radius: 4px;
    padding: 1px 6px;
}

/* States */
.nacify-cj-shipping__loading,
.nacify-cj-shipping__hint,
.nacify-cj-shipping__error {
    font-size: 14px;
    padding: 10px 2px;
}

.nacify-cj-shipping__loading,
.nacify-cj-shipping__hint {
    color: var(--nacify-secondary-text);
}

.nacify-cj-shipping__error {
    color: #B3261E;
}

.nacify-cj-shipping__spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid var(--nacify-light-accent);
    border-top-color: var(--nacify-primary);
    border-radius: 50%;
    animation: nacify-cj-spin .8s linear infinite;
    vertical-align: -2px;
}

@keyframes nacify-cj-spin {
    to { transform: rotate(360deg); }
}

/* Mobile */
@media (max-width: 480px) {
    .nacify-cj-shipping { padding: 14px; }
    .nacify-cj-shipping__rate-price { font-size: 14px; }
}
