.woocommerce-rma-manager {
    margin-bottom: 2em;
}

.rma-actions {
    margin-bottom: 2em;
}

.woocommerce-rma-form {
    background: #f8f8f8;
    padding: 20px;
    border: 1px solid #ddd;
    border-radius: 4px;
    margin-top: 2em;
}

.returnable-items {
    width: 100%;
    margin-bottom: 1.5em;
    border-collapse: collapse;
}

.returnable-items th,
.returnable-items td {
    padding: 12px;
    text-align: left;
    border: 1px solid #ddd;
}

.returnable-items th {
    background: #f5f5f5;
}

.return-quantity {
    width: 60px;
}

.item-condition {
    width: 100%;
    min-width: 150px;
}

.item-photos {
    max-width: 100%;
}

.rma-details {
    background: #f8f8f8;
    padding: 15px;
    border: 1px solid #ddd;
    border-radius: 4px;
    margin-bottom: 2em;
}

.rma-photos {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    padding: 10px 0;
}

.rma-item-photo {
    max-width: 100px;
    height: auto;
    border: 1px solid #ddd;
    border-radius: 4px;
}

.rma-item-photo:hover {
    border-color: #999;
}

.rma-notes {
    background: #fff;
    padding: 15px;
    border: 1px solid #ddd;
    border-radius: 4px;
    margin-bottom: 2em;
}

.rma-instructions {
    background: #e8f5e9;
    padding: 20px;
    border: 1px solid #a5d6a7;
    border-radius: 4px;
    margin: 2em 0;
}

.rma-instructions h3 {
    margin-top: 0;
    color: #2e7d32;
}

/* Status badges */
.rma-status {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 3px;
    font-size: 0.9em;
    font-weight: 500;
}

.status-pending {
    background: #fff3e0;
    color: #e65100;
}

.status-approved {
    background: #e8f5e9;
    color: #2e7d32;
}

.status-received {
    background: #e3f2fd;
    color: #1565c0;
}

.status-processing {
    background: #fff8e1;
    color: #f9a825;
}

.status-completed {
    background: #c8e6c9;
    color: #1b5e20;
}

.status-rejected {
    background: #ffebee;
    color: #c62828;
}

.status-cancelled {
    background: #f5f5f5;
    color: #616161;
}

/* Responsive */
@media screen and (max-width: 768px) {
    .returnable-items {
        display: block;
        overflow-x: auto;
    }
    
    .returnable-items th,
    .returnable-items td {
        padding: 8px;
        font-size: 0.9em;
    }
    
    .return-quantity {
        width: 50px;
    }
    
    .item-condition {
        min-width: 100px;
    }
}

/* Invoice Search Styles */
.rma-invoice-search-wrapper {
    position: relative;
    margin-bottom: 2em;
}

.invoice-search-input {
    width: 100%;
    max-width: 400px;
    padding: 8px 12px;
    font-size: 16px;
    border: 1px solid #ddd;
    border-radius: 4px;
}

.invoice-search-input:focus {
    outline: none;
    border-color: #007cba;
    box-shadow: 0 0 0 1px #007cba;
}

.invoice-search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    max-width: 500px;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    z-index: 1000;
    max-height: 300px;
    overflow-y: auto;
    margin-top: 5px;
}

.invoice-search-results-inner {
    padding: 15px;
}

.invoice-search-results h4 {
    margin: 0 0 10px 0;
    font-size: 14px;
    color: #666;
}

.invoice-results-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.invoice-result-item {
    padding: 12px 15px;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    background: #fff;
}

.invoice-result-item:hover {
    background: #f5f5f5;
    border-color: #007cba;
}

.invoice-result-main {
    margin-bottom: 5px;
}

.invoice-result-details {
    display: flex;
    gap: 15px;
    font-size: 13px;
    color: #666;
}

.invoice-total {
    font-weight: 600;
    color: #333;
}

.selected-invoice-display {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    padding: 15px;
    margin-top: 20px;
}

.selected-invoice-display h4 {
    margin: 0 0 10px 0;
    font-size: 16px;
}

.change-invoice {
    margin-top: 10px;
}

.search-loading,
.search-no-results,
.search-error {
    padding: 20px;
    text-align: center;
    color: #666;
}

.search-error {
    color: #dc3545;
}

/* ==========================================================================
   ABM portal UI (used when the ABM WooCommerce plugin is active). Layout, tables,
   buttons and the --abm-* tokens come from its css/styles.css; these rules only
   cover what the returns pages add: inputs inside tables, the invoice picker,
   hints and photo thumbnails.
   ========================================================================== */

.abm-portal .rma-new-form {
    margin-bottom: 24px;
}

.abm-portal .rma-hint {
    display: block;
    margin-top: 4px;
    font-size: .8rem;
    line-height: 1.4;
    white-space: normal;
    color: var(--abm-muted);
}

.abm-portal .rma-input {
    width: 100%;
    margin: 0;
    padding: 7px 10px;
    background-color: #fff;
    border: 1px solid var(--abm-line-strong);
    border-radius: var(--abm-radius-sm);
    box-shadow: none;
    font: inherit;
    font-size: .9rem;
    color: var(--abm-ink);
}

.abm-portal select.rma-input {
    min-width: 150px;
    height: 38px;
    padding-right: 32px;
    -webkit-appearance: none;
    appearance: none;
    background-image: var(--abm-chevron);
    background-repeat: no-repeat;
    background-position: right 9px center;
    background-size: 16px;
    cursor: pointer;
}

.abm-portal .rma-input:focus {
    outline: 2px solid var(--abm-focus);
    outline-offset: 1px;
}

.abm-portal .rma-input:disabled {
    background-color: var(--abm-subtle);
    color: var(--abm-muted);
    cursor: not-allowed;
}

.abm-portal input.rma-qty {
    width: 72px;
    height: 38px;
    text-align: right;
}

.abm-portal .rma-items td {
    vertical-align: top;
}

/* Condition notes and photos fold into the item cell */
.abm-portal .rma-more {
    margin-top: 8px;
}

.abm-portal .rma-more summary {
    font-size: .84rem;
    font-weight: 600;
    color: var(--abm-ink);
    cursor: pointer;
}

.abm-portal .rma-more[open] summary {
    margin-bottom: 8px;
}

.abm-portal .rma-more .item-condition {
    min-width: 0;
    margin-bottom: 8px;
}

.abm-portal .rma-more .item-photos {
    max-width: 100%;
    font-size: .84rem;
}

/* Invoice picker */
.abm-portal .rma-invoice-search-wrapper {
    margin-bottom: 16px;
}

.abm-portal .rma-search-field {
    max-width: 420px;
}

.abm-portal .invoice-search-input {
    max-width: none;
}

.abm-portal .invoice-search-results {
    max-width: 420px;
    margin-top: 6px;
    border-color: var(--abm-line);
    border-radius: var(--abm-radius-sm);
    box-shadow: 0 8px 24px rgba(16, 24, 40, .12);
}

.abm-portal .invoice-search-results-inner {
    padding: 8px;
}

.abm-portal .invoice-search-results h4 {
    margin: 4px 8px 8px;
    font-size: .74rem;
    font-weight: 600;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--abm-muted);
}

.abm-portal .invoice-result-item {
    margin: 0 0 4px;
    padding: 10px 12px;
    border: 0;
    border-radius: var(--abm-radius-sm);
}

.abm-portal .invoice-result-item:hover {
    background: var(--abm-hover);
}

.abm-portal .invoice-result-details {
    font-size: .84rem;
    color: var(--abm-muted);
}

.abm-portal .invoice-total {
    color: var(--abm-ink);
}

.abm-portal .selected-invoice-display {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px 16px;
    margin-top: 0;
    padding: 12px 14px;
    background: var(--abm-subtle);
    border: 1px solid var(--abm-line);
    border-radius: var(--abm-radius-sm);
    line-height: 1.5;
}

.abm-portal .selected-invoice-display .change-invoice {
    margin-top: 0;
}

.abm-portal #invoice-items {
    margin-bottom: 16px;
}

.abm-portal .rma-notes-field {
    margin-bottom: 16px;
}

.abm-portal .rma-form-actions {
    display: flex;
    justify-content: flex-end;
}

/* Photo thumbnails on the return detail page */
.abm-portal .rma-thumbs {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}

.abm-portal .rma-thumbs img {
    display: block;
    width: 44px;
    height: 44px;
    object-fit: cover;
    border: 1px solid var(--abm-line);
    border-radius: 6px;
}

/* Phone width: the ABM stylesheet stacks rows into cards with the label in the left 45%;
   the item cell holds a form, so it gets the full card width with its label above. */
@container (max-width: 640px) {
    .abm-portal .rma-items td.rma-item-cell {
        padding: 30px 14px 10px;
        text-align: left;
    }

    .abm-portal .rma-items select.rma-input {
        min-width: 0;
    }

    .abm-portal .rma-form-actions .abm-btn {
        width: 100%;
    }

    .abm-portal .rma-search-field,
    .abm-portal .invoice-search-results {
        max-width: none;
    }
}
/* Return shipment: the carrier and tracking number on the return page */
.rma-tracking {
    margin-bottom: 16px;
}

.rma-tracking__intro,
.rma-tracking__current {
    margin: 0 0 12px;
}

.rma-tracking-form {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: flex-end;
}

.rma-tracking__field {
    flex: 1 1 200px;
    max-width: 280px;
    margin: 0;
}

.rma-tracking__field label {
    display: block;
    margin-bottom: 4px;
    font-weight: 600;
}

.rma-tracking__field .rma-input,
.rma-tracking__field input,
.rma-tracking__field select {
    width: 100%;
    box-sizing: border-box;
}

.rma-tracking__message {
    flex-basis: 100%;
    margin: 0;
}

.rma-tracking__message--error {
    color: #b42318;
}

@container (max-width: 640px) {
    .abm-portal .rma-tracking__field {
        max-width: none;
        flex-basis: 100%;
    }

    .abm-portal .rma-tracking__actions,
    .abm-portal .rma-tracking__actions .abm-btn {
        width: 100%;
    }
}

/* Return form: whole invoice and one reason for every item */
.rma-bulk {
    display: flex;
    flex-wrap: wrap;
    gap: 12px 16px;
    align-items: flex-end;
    margin: 16px 0 12px;
}

.rma-bulk__buttons {
    display: flex;
    gap: 8px;
}

.rma-bulk__reason {
    flex: 1 1 260px;
    max-width: 360px;
    margin: 0;
}

.rma-bulk__reason label {
    display: block;
    margin-bottom: 4px;
    font-weight: 600;
}

.rma-bulk__reason select {
    width: 100%;
    box-sizing: border-box;
}

.rma-bulk__hint {
    flex-basis: 100%;
    margin: 0;
}

@container (max-width: 640px) {
    .abm-portal .rma-bulk__reason {
        max-width: none;
        flex-basis: 100%;
    }

    .abm-portal .rma-bulk__buttons,
    .abm-portal .rma-bulk__buttons .abm-btn {
        width: 100%;
    }

    .abm-portal .rma-bulk__buttons {
        flex-direction: column;
    }
}
