/* WooCommerce MyAccount Orders Search Styles */

/* Variables using CSS custom properties for consistency; override on the wrapper to theme. */
.wc-myaccount-orders-search-wrapper {
    --wc-myaccount-search-primary: #1f2937;
    --wc-myaccount-search-primary-hover: #111827;
    --wc-myaccount-search-focus: rgba(31, 41, 55, 0.12);
    --wc-myaccount-search-text: #111827;
    --wc-myaccount-search-muted: #6b7280;
    --wc-myaccount-search-border: #e5e7eb;
    --wc-myaccount-search-field-border: #d1d5db;
    --wc-myaccount-search-bg: #f9fafb;
    --wc-myaccount-search-radius: 12px;
    --wc-myaccount-search-transition: 0.18s ease;
}

/* Main wrapper */
.wc-myaccount-orders-search-wrapper {
    margin-bottom: 32px;
    padding: 20px;
    background: #fff;
    border: 1px solid var(--wc-myaccount-search-border);
    border-radius: 16px;
    box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 4px 16px rgba(16, 24, 40, 0.04);
    color: var(--wc-myaccount-search-text);
}

/* Form layout */
.wc-myaccount-orders-search-wrapper .wc-myaccount-orders-search-form {
    display: flex;
    gap: 10px;
    align-items: center;
    margin: 0;
}

.wc-myaccount-orders-search-wrapper .wc-myaccount-orders-search-input-wrapper {
    position: relative;
    flex: 1;
    min-width: 0;
}

/* Input styling */
.wc-myaccount-orders-search-wrapper .wc-myaccount-orders-search-input {
    width: 100%;
    height: 48px;
    margin: 0;
    padding: 0 48px 0 46px;
    border: 1px solid var(--wc-myaccount-search-field-border);
    border-radius: var(--wc-myaccount-search-radius);
    background: var(--wc-myaccount-search-bg);
    box-shadow: none;
    color: var(--wc-myaccount-search-text);
    font-size: 16px;
    line-height: 48px;
    box-sizing: border-box;
    -webkit-appearance: none;
    appearance: none;
    transition: border-color var(--wc-myaccount-search-transition), background-color var(--wc-myaccount-search-transition), box-shadow var(--wc-myaccount-search-transition);
}

.wc-myaccount-orders-search-wrapper .wc-myaccount-orders-search-input::placeholder {
    color: #9ca3af;
    opacity: 1;
}

/* The custom clear button replaces the browser's own. */
.wc-myaccount-orders-search-wrapper .wc-myaccount-orders-search-input::-webkit-search-cancel-button,
.wc-myaccount-orders-search-wrapper .wc-myaccount-orders-search-input::-webkit-search-decoration {
    -webkit-appearance: none;
    appearance: none;
}

.wc-myaccount-orders-search-wrapper .wc-myaccount-orders-search-input:hover {
    border-color: #9ca3af;
}

.wc-myaccount-orders-search-wrapper .wc-myaccount-orders-search-input:focus {
    outline: none;
    border-color: var(--wc-myaccount-search-primary);
    background: #fff;
    box-shadow: 0 0 0 4px var(--wc-myaccount-search-focus);
}

/* Search icon */
.wc-myaccount-orders-search-wrapper .wc-myaccount-orders-search-icon {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    color: #9ca3af;
    pointer-events: none;
    transition: color var(--wc-myaccount-search-transition);
}

.wc-myaccount-orders-search-wrapper .wc-myaccount-orders-search-input-wrapper:focus-within .wc-myaccount-orders-search-icon {
    color: var(--wc-myaccount-search-primary);
}

/* Clear button (inside the input) */
.wc-myaccount-orders-search-wrapper .wc-myaccount-orders-search-clear-btn {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    width: 32px;
    height: 32px;
    min-width: 0;
    margin: 0;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: var(--wc-myaccount-search-muted);
    box-shadow: none;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    line-height: 0;
    transition: background-color var(--wc-myaccount-search-transition), color var(--wc-myaccount-search-transition);
}

.wc-myaccount-orders-search-wrapper .wc-myaccount-orders-search-clear-btn:hover {
    background: #e5e7eb;
    color: var(--wc-myaccount-search-text);
}

/* Submit button */
.wc-myaccount-orders-search-wrapper .wc-myaccount-orders-search-btn {
    flex: 0 0 auto;
    height: 48px;
    margin: 0;
    padding: 0 24px;
    border: none;
    border-radius: var(--wc-myaccount-search-radius);
    background: var(--wc-myaccount-search-primary);
    color: #fff;
    font-size: 15px;
    font-weight: 600;
    line-height: 1;
    letter-spacing: normal;
    text-transform: none;
    box-shadow: none;
    cursor: pointer;
    transition: background-color var(--wc-myaccount-search-transition), box-shadow var(--wc-myaccount-search-transition);
}

.wc-myaccount-orders-search-wrapper .wc-myaccount-orders-search-btn:hover {
    background: var(--wc-myaccount-search-primary-hover);
    color: #fff;
}

/* Focus states for accessibility */
.wc-myaccount-orders-search-wrapper .wc-myaccount-orders-search-btn:focus-visible,
.wc-myaccount-orders-search-wrapper .wc-myaccount-orders-search-clear-btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 4px var(--wc-myaccount-search-focus);
}

/* Loading state */
.wc-myaccount-orders-search-loading {
    display: none;
    align-items: center;
    gap: 10px;
    margin-top: 16px;
    color: var(--wc-myaccount-search-muted);
    font-size: 14px;
}

.wc-myaccount-orders-search-loading.active {
    display: flex;
}

.wc-myaccount-orders-search-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid var(--wc-myaccount-search-border);
    border-top-color: var(--wc-myaccount-search-primary);
    border-radius: 50%;
    animation: wcMyAccountOrdersSearchSpin 0.7s linear infinite;
}

@keyframes wcMyAccountOrdersSearchSpin {
    to {
        transform: rotate(360deg);
    }
}

/* Results */
.wc-myaccount-orders-search-results:empty {
    display: none;
}

.wc-myaccount-orders-search-results {
    margin-top: 20px;
    animation: wcMyAccountOrdersSearchFadeIn 0.25s ease-out;
}

.wc-myaccount-orders-search-results-header {
    margin-bottom: 8px;
    color: var(--wc-myaccount-search-muted);
    font-size: 14px;
    font-weight: 500;
}

.wc-myaccount-orders-search-no-results {
    margin: 0;
    padding: 28px 20px;
    border: 1px dashed var(--wc-myaccount-search-field-border);
    border-radius: var(--wc-myaccount-search-radius);
    background: var(--wc-myaccount-search-bg);
    color: var(--wc-myaccount-search-muted);
    font-size: 15px;
    text-align: center;
}

/* Search results table */
.wc-myaccount-orders-search-results .woocommerce-orders-table {
    width: 100%;
    margin: 0;
    border: none;
    border-collapse: collapse;
    background: transparent;
}

.wc-myaccount-orders-search-results .woocommerce-orders-table th {
    padding: 10px 16px;
    border: none;
    border-bottom: 1px solid var(--wc-myaccount-search-border);
    background: transparent;
    color: var(--wc-myaccount-search-muted);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-align: left;
    text-transform: uppercase;
}

.wc-myaccount-orders-search-results .woocommerce-orders-table td {
    padding: 14px 16px;
    border: none;
    border-bottom: 1px solid #f1f2f4;
    background: transparent;
    vertical-align: middle;
}

.wc-myaccount-orders-search-results .woocommerce-orders-table tbody tr:last-child td {
    border-bottom: none;
}

.wc-myaccount-orders-search-results .woocommerce-orders-table tbody tr {
    transition: background-color var(--wc-myaccount-search-transition);
}

.wc-myaccount-orders-search-results .woocommerce-orders-table tbody tr:hover {
    background: var(--wc-myaccount-search-bg);
}

.wc-myaccount-orders-search-results .woocommerce-orders-table__cell-order-number a {
    font-weight: 600;
}

.wc-myaccount-orders-search-results .woocommerce-orders-table__cell-order-actions {
    text-align: right;
    white-space: nowrap;
}

.wc-myaccount-orders-search-results .woocommerce-orders-table__header-order-actions {
    text-align: right;
}

/* Pagination */
.wc-myaccount-orders-search-pagination {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--wc-myaccount-search-border);
}

.wc-myaccount-orders-search-pagination-info {
    margin-bottom: 12px;
    color: var(--wc-myaccount-search-muted);
    font-size: 14px;
    text-align: center;
}

.wc-myaccount-orders-search-pagination-links {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.wc-myaccount-orders-search-pagination-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 38px;
    height: 38px;
    padding: 0 12px;
    border: 1px solid var(--wc-myaccount-search-border);
    border-radius: 10px;
    background: #fff;
    color: var(--wc-myaccount-search-text);
    font-size: 14px;
    font-weight: 500;
    line-height: 1;
    text-decoration: none;
    cursor: pointer;
    transition: background-color var(--wc-myaccount-search-transition), border-color var(--wc-myaccount-search-transition), color var(--wc-myaccount-search-transition);
}

.wc-myaccount-orders-search-pagination-link:hover {
    border-color: var(--wc-myaccount-search-field-border);
    background: var(--wc-myaccount-search-bg);
    color: var(--wc-myaccount-search-text);
}

.wc-myaccount-orders-search-pagination-link.current {
    border-color: var(--wc-myaccount-search-primary);
    background: var(--wc-myaccount-search-primary);
    color: #fff;
    font-weight: 600;
}

.wc-myaccount-orders-search-pagination-ellipsis {
    padding: 0 6px;
    color: var(--wc-myaccount-search-muted);
}

/* Error message */
.wc-myaccount-orders-search-error {
    padding: 14px 16px;
    border: 1px solid #fecaca;
    border-radius: var(--wc-myaccount-search-radius);
    background: #fef2f2;
    color: #991b1b;
    font-size: 14px;
}

/* Responsive Design */
@media (max-width: 768px) {
    .wc-myaccount-orders-search-wrapper {
        padding: 16px;
        margin-bottom: 24px;
    }

    /* WooCommerce stacks responsive table cells as "label: value" rows here. */
    .wc-myaccount-orders-search-results .woocommerce-orders-table tbody tr {
        display: block;
        padding: 6px 0;
        border-bottom: 1px solid var(--wc-myaccount-search-border);
    }

    .wc-myaccount-orders-search-results .woocommerce-orders-table tbody tr:last-child {
        border-bottom: none;
    }

    .wc-myaccount-orders-search-results .woocommerce-orders-table tbody tr:hover {
        background: transparent;
    }

    .wc-myaccount-orders-search-results .woocommerce-orders-table td,
    .wc-myaccount-orders-search-results .woocommerce-orders-table tbody tr:last-child td {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
        padding: 8px 0;
        border-bottom: none;
        text-align: right;
    }

    .wc-myaccount-orders-search-results .woocommerce-orders-table td::before {
        float: none;
        margin: 0;
    }
}

@media (max-width: 480px) {
    .wc-myaccount-orders-search-wrapper .wc-myaccount-orders-search-form {
        flex-direction: column;
        align-items: stretch;
    }

    .wc-myaccount-orders-search-wrapper .wc-myaccount-orders-search-btn {
        width: 100%;
    }

    .wc-myaccount-orders-search-pagination-link {
        min-width: 34px;
        height: 34px;
        padding: 0 8px;
        font-size: 13px;
    }
}

/* Animations */
@keyframes wcMyAccountOrdersSearchFadeIn {
    from {
        opacity: 0;
        transform: translateY(6px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (prefers-reduced-motion: reduce) {
    .wc-myaccount-orders-search-results,
    .wc-myaccount-orders-search-spinner {
        animation: none;
    }
}
