/* ShipEngine delivery rates modal (detachable)
 * Remove with: ship-rates-addon.js, this file, modal markup + script/link tags in index.html,
 * and Orders/Workshop row-action items (when wired).
 */

.ship-rates-modal {
    z-index: 10620;
}

.ship-rates-modal .modal-content {
    max-width: 720px;
    width: 94vw;
    max-height: 92vh;
    display: flex;
    flex-direction: column;
    padding: 0;
    overflow: hidden;
}

.ship-rates-modal .modal-header {
    flex-shrink: 0;
    padding: 14px 18px;
    border-bottom: 1px solid #dee2e6;
}

.ship-rates-modal .modal-header h2 {
    margin: 0;
    font-size: 18px;
    color: #1a1f2e;
}

.ship-rates-modal .modal-close {
    background: #fff;
    border: 1.5px solid #1a1f2e;
    border-radius: 8px;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    color: #1a1f2e;
    width: 32px;
    height: 32px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.ship-rates-modal .modal-close:hover {
    color: #000;
    background: #f4f6f8;
}

.sr-order-meta {
    margin: 0;
    font-size: 12px;
    color: #6c757d;
}

.sr-body {
    padding: 16px 18px 18px;
    overflow-y: auto;
    flex: 1;
    min-height: 0;
    box-sizing: border-box;
}

.sr-ui-note {
    margin: 0 0 10px;
    padding: 0;
    font-size: 14px;
    color: #111827;
    line-height: 1.35;
}

.sr-ui-note .sr-non-pallet,
.sr-ack .sr-non-pallet {
    color: #dc2626;
    font-weight: 600;
    text-decoration: none;
}

.sr-ack.is-acked .sr-non-pallet {
    color: #dc2626;
}

.sr-section {
    margin-bottom: 14px;
}

.sr-section-card {
    padding: 14px 14px 12px;
    border: 1px solid #cfd6de;
    border-radius: 10px;
    background: #f7f9fb;
    box-sizing: border-box;
}

.sr-section-title {
    margin: 0 0 8px;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: #6c757d;
}

.sr-lane-head {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
    min-height: 18px;
}

.sr-lane-label {
    margin-bottom: 0;
    font-size: 12px;
    font-weight: 700;
    text-transform: none;
    letter-spacing: 0;
    color: #495057;
}

.sr-lane-flags {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
    min-height: 18px;
}

.sr-lane-flag {
    width: 22px;
    height: 15px;
    display: block;
    border-radius: 2px;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.12);
    object-fit: cover;
}

.sr-lane-flag-arrow {
    font-size: 12px;
    color: #6c757d;
    line-height: 1;
}

.sr-label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: #495057;
    margin-bottom: 4px;
}

.sr-field {
    margin-bottom: 10px;
}

.sr-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

@media (max-width: 560px) {
    .sr-row {
        grid-template-columns: 1fr;
    }
}

.sr-input,
.sr-select {
    width: 100%;
    box-sizing: border-box;
    padding: 8px 10px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 13px;
    font-family: inherit;
    background: #fff;
}

.sr-input:focus,
.sr-select:focus {
    outline: 2px solid rgba(11, 107, 203, 0.25);
    border-color: #0b6bcb;
}

#srWeightValue,
#srWeightUnit {
    background: #ecfdf3;
    border-color: #86efac;
}

#srWeightValue:focus,
#srWeightUnit:focus {
    outline: 2px solid rgba(22, 163, 74, 0.25);
    border-color: #16a34a;
}

.sr-hint {
    margin: 4px 0 0;
    font-size: 11px;
    color: #6c757d;
    line-height: 1.35;
}

.sr-from-row {
    display: flex;
    gap: 8px;
    align-items: flex-start;
}

.sr-from-row .sr-select {
    flex: 1;
}

.sr-btn {
    font: inherit;
    font-size: 13px;
    padding: 8px 12px;
    border-radius: 4px;
    border: 1px solid #ced4da;
    background: #fff;
    cursor: pointer;
    white-space: nowrap;
}

.sr-btn:hover {
    background: #f0f3f7;
}

.sr-btn-primary {
    background: #0b6bcb;
    border-color: #0b6bcb;
    color: #fff;
}

.sr-btn-primary:hover {
    background: #0956a3;
    color: #fff;
}

.sr-btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.sr-btn-danger {
    color: #b42318;
    border-color: #f0b4ae;
}

.sr-btn-danger:hover:not(:disabled) {
    background: #fef3f2;
    border-color: #b42318;
}

.sr-btn-danger:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.sr-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    margin-top: 4px;
}

.sr-status {
    min-height: 1.2em;
    margin: 8px 0 0;
    font-size: 12px;
    color: #6c757d;
}

.sr-status.error {
    color: #b42318;
}

.sr-status.busy {
    color: #0b6bcb;
}

.sr-status.ok {
    color: #067647;
}

.sr-textarea {
    resize: vertical;
    min-height: 4.2em;
    line-height: 1.35;
}

.sr-from-fields {
    margin-top: 10px;
    padding: 12px;
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 6px;
}

.sr-from-fields[hidden],
.sr-section-card[hidden],
#srResultsSection[hidden] {
    display: none !important;
}


.sr-results {
    border: 1px solid #dee2e6;
    border-radius: 6px;
    background: #fff;
    min-height: 72px;
}

.sr-results-empty {
    padding: 20px 14px;
    text-align: center;
    font-size: 13px;
    color: #6c757d;
}

.sr-rate-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.sr-rate-card {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 4px 12px;
    padding: 12px 14px;
    border-bottom: 1px solid #bbf7d0;
    align-items: baseline;
    background: #ecfdf3;
    transition: background 0.2s ease;
}

.sr-rate-card:last-child {
    border-bottom: none;
}

.sr-rate-card:nth-child(even) {
    background: #dcfce7;
}

.sr-rate-service {
    font-size: 13px;
    font-weight: 600;
    color: #1a1f2e;
}

.sr-rate-carrier {
    font-size: 11px;
    color: #6c757d;
    grid-column: 1;
}

.sr-rate-price {
    font-size: 15px;
    font-weight: 700;
    color: #0b6bcb;
    text-align: right;
    grid-column: 2;
    grid-row: 1 / span 2;
    align-self: center;
}

.sr-rate-days {
    font-size: 11px;
    color: #6c757d;
}

.sr-shipping-value {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    justify-content: flex-end;
}

.sr-shipping-btn {
    font: inherit;
    font-size: 12px;
    font-weight: 600;
    padding: 6px 10px;
    border: 1px solid #0b6bcb;
    border-radius: 4px;
    background: #fff;
    color: #0b6bcb;
    cursor: pointer;
    white-space: nowrap;
    line-height: 1.2;
}

.sr-shipping-btn:hover {
    background: #e7f1ff;
}

.sr-ack {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin: 0 0 14px;
    padding: 10px 12px;
    border: 1px solid #f0b4ae;
    border-radius: 8px;
    background: #fef3f2;
    font-size: 12px;
    line-height: 1.4;
    color: #7a271a;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.sr-ack.is-acked {
    border-color: #86efac;
    background: #ecfdf3;
    color: #166534;
}

.sr-ack input {
    margin-top: 2px;
    flex-shrink: 0;
}

.sr-ack em {
    font-style: normal;
    font-weight: 700;
}

.sr-btn-estimate {
    border-color: #b42318;
    background: #fef3f2;
    color: #b42318;
}

.sr-btn-estimate:disabled {
    opacity: 1;
    cursor: not-allowed;
}

.sr-btn-estimate.is-ready {
    border-color: #067647;
    background: #067647;
    color: #fff;
}

.sr-btn-estimate.is-ready:hover {
    background: #05603a;
    border-color: #05603a;
    color: #fff;
}

.sr-btn-estimate.is-busy {
    position: relative;
    pointer-events: none;
    opacity: 0.92;
}

.sr-btn-estimate.is-busy::after {
    content: '';
    display: inline-block;
    width: 14px;
    height: 14px;
    margin-left: 8px;
    border: 2px solid rgba(255, 255, 255, 0.35);
    border-top-color: #fff;
    border-radius: 50%;
    vertical-align: -2px;
    animation: sr-spin 0.7s linear infinite;
}

.sr-btn-estimate:not(.is-ready).is-busy::after {
    border-color: rgba(180, 35, 24, 0.25);
    border-top-color: #b42318;
}

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

.sr-to-address-preview {
    margin: 0 0 10px;
    padding: 8px 10px;
    font-size: 12px;
    line-height: 1.4;
    color: #495057;
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 4px;
    white-space: pre-wrap;
}

.sr-input.sr-input-needed,
.sr-select.sr-input-needed {
    background: #fff8e6;
    border-color: #f0d78c;
}

.sr-input.sr-input-needed:focus {
    outline: 2px solid rgba(196, 146, 0, 0.35);
    border-color: #c49200;
}

.sr-country-combo {
    position: relative;
}

.sr-country-list {
    position: absolute;
    left: 0;
    right: 0;
    top: calc(100% + 2px);
    max-height: 220px;
    overflow-y: auto;
    background: #fff;
    border: 1px solid #ced4da;
    border-radius: 4px;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.12);
    z-index: 20;
}

.sr-country-option {
    display: block;
    width: 100%;
    text-align: left;
    padding: 8px 10px;
    border: none;
    background: #fff;
    font: inherit;
    font-size: 13px;
    cursor: pointer;
    color: #212529;
}

.sr-country-option:hover,
.sr-country-option.is-active {
    background: #e7f1ff;
    color: #0a58ca;
}

.sr-country-option-code {
    float: right;
    color: #6c757d;
    font-size: 11px;
    font-weight: 700;
}

.sr-country-empty {
    padding: 10px;
    font-size: 12px;
    color: #6c757d;
}

.row-actions-item.row-actions-item-ship-rates {
    color: #0d6efd;
}

.row-actions-item.row-actions-item-ship-rates:hover {
    background: #e7f1ff;
    color: #0a58ca;
}
