/* Priority RXU Connector Frontend Styles */

.prc-orders-container {
    margin: 20px 0;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.prc-orders-header {
    background: #f8f9fa;
    padding: 20px;
    border-bottom: 1px solid #ddd;
}

.prc-orders-header h2 {
    margin: 0;
    color: #333;
    font-size: 24px;
}

.prc-orders-content {
    padding: 20px;
}

/* Loading States */
.prc-loading {
    text-align: center;
    padding: 40px;
    color: #666;
    font-style: italic;
}

.prc-loading:before {
    content: "";
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #007cba;
    border-radius: 50%;
    animation: prc-spin 1s linear infinite;
    margin-right: 10px;
    vertical-align: middle;
}

@keyframes prc-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Error States */
.prc-error {
    background: #f8d7da;
    color: #721c24;
    padding: 15px;
    border: 1px solid #f5c6cb;
    border-radius: 4px;
    margin: 10px 0;
}

/* Orders Table */
.prc-orders-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
}

.prc-orders-table th {
    background: #f8f9fa;
    padding: 12px;
    text-align: left;
    border-bottom: 2px solid #dee2e6;
    font-weight: 600;
    color: #495057;
}

.prc-orders-table td {
    padding: 12px;
    border-bottom: 1px solid #dee2e6;
    vertical-align: top;
}

.prc-orders-table tr:hover {
    background: #f8f9fa;
}

.prc-orders-table tr.matched {
    border-left: 4px solid #309748;
}

.prc-orders-table tr.unmatched {
    border-left: 4px solid #309748;
}

/* Status Indicators */
.status-matched {
    background: #d4edda;
    color: #155724;
    padding: 4px 8px;
    border-radius: 3px;
    font-size: 12px;
    font-weight: bold;
}

.status-unmatched {
    background: #f8d7da;
    color: #721c24;
    padding: 4px 8px;
    border-radius: 3px;
    font-size: 12px;
    font-weight: bold;
}

.match-indicator {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    margin-right: 8px;
}

.match-indicator.matched {
    background: #309748;
}

.match-indicator.unmatched {
    background: #309748;
}

/* Order Lookup Form */
.prc-order-lookup {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 8px;
    margin: 20px 0;
}

.prc-order-lookup h3 {
    margin-top: 0;
    color: #333;
}

.prc-lookup-form {
    display: flex;
    gap: 10px;
    align-items: end;
}

.prc-lookup-form input[type="text"] {
    flex: 1;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 16px;
}

.prc-lookup-form button {
    padding: 10px 20px;
    background: #007cba;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 16px;
    white-space: nowrap;
}

.prc-lookup-form button:hover {
    background: #005a87;
}

/* Order Details */
.prc-order-details {
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 20px;
    margin: 20px 0;
}

.prc-order-details h3 {
    margin-top: 0;
    color: #333;
    border-bottom: 2px solid #007cba;
    padding-bottom: 10px;
}

.prc-order-sections {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
    margin-top: 20px;
}

.prc-section {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 8px;
    border: 1px solid #e9ecef;
}

.prc-section h4 {
    margin-top: 0;
    color: #495057;
    border-bottom: 1px solid #dee2e6;
    padding-bottom: 10px;
}

.prc-section.priority-section h4 {
    color: #007cba;
}

.prc-section.rxu-section h4 {
    color: #309748;
}

.prc-section.rxu-section.no-match {
    background: #fff5f5;
    border-color: #fed7d7;
}

.prc-no-match {
    color: #e53e3e;
    font-style: italic;
    text-align: center;
    padding: 20px;
}

.prc-field {
    display: flex;
    margin-bottom: 10px;
    align-items: flex-start;
}

.prc-field label {
    font-weight: 600;
    color: #495057;
    min-width: 120px;
    margin-right: 10px;
}

.prc-field span {
    color: #6c757d;
    word-break: break-word;
}

/* Responsive Design */
@media (max-width: 768px) {
    .prc-order-sections {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    
    .prc-lookup-form {
        flex-direction: column;
        align-items: stretch;
    }
    
    .prc-lookup-form input[type="text"] {
        margin-bottom: 10px;
    }
    
    .prc-orders-table {
        font-size: 14px;
    }
    
    .prc-orders-table th,
    .prc-orders-table td {
        padding: 8px;
    }
    
    .prc-field {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .prc-field label {
        min-width: auto;
        margin-bottom: 5px;
    }
}

@media (max-width: 480px) {
    .prc-orders-container {
        margin: 10px 0;
    }
    
    .prc-orders-header,
    .prc-orders-content {
        padding: 15px;
    }
    
    .prc-orders-header h2 {
        font-size: 20px;
    }
    
    .prc-section {
        padding: 15px;
    }
}

/* Print Styles */
@media print {
    .prc-orders-container {
        box-shadow: none;
        border: 1px solid #000;
    }
    
    .prc-lookup-form,
    .prc-order-lookup {
        display: none;
    }
    
    .prc-orders-table {
        font-size: 12px;
    }
    
    .prc-orders-table th,
    .prc-orders-table td {
        padding: 6px;
    }
}

/* Accessibility */
.prc-orders-table th[scope="col"] {
    text-align: left;
}

.prc-orders-table th[scope="row"] {
    text-align: right;
    font-weight: 600;
}

/* Focus States */
.prc-lookup-form input[type="text"]:focus,
.prc-lookup-form button:focus {
    outline: 2px solid #007cba;
    outline-offset: 2px;
}

/* WooCommerce Order Links */
.woo-order-link {
    color: #007cba;
    text-decoration: none;
    font-weight: 500;
    padding: 2px 6px;
    border-radius: 3px;
    background: #e3f2fd;
    border: 1px solid #bbdefb;
    display: inline-block;
    transition: all 0.2s ease;
}

.woo-order-link:hover {
    background: #bbdefb;
    border-color: #90caf9;
    text-decoration: none;
    color: #0056b3;
}

.woo-order-link:focus {
    outline: 2px solid #007cba;
    outline-offset: 2px;
}

/* Find Orders (My Account) */
.prc-find-orders {
    position: relative;
    margin: 20px 0;
}

.prc-find-orders .prc-description {
    margin-bottom: 16px;
}

.prc-find-orders-account {
    margin-bottom: 16px;
}

.prc-find-orders-form {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
}

.prc-mode-toggle {
    border: 0;
    margin: 0 0 16px;
    padding: 0;
}

.prc-mode-toggle legend {
    font-weight: 600;
    margin-bottom: 8px;
}

.prc-mode-segments {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 0;
    border: 1px solid #c5d4de;
    border-radius: 8px;
    overflow: hidden;
    background: #fff;
}

.prc-mode-segment {
    position: relative;
    margin: 0;
    cursor: pointer;
}

.prc-mode-segment input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.prc-mode-segment span {
    display: inline-block;
    padding: 10px 16px;
    font-weight: 600;
    color: #495057;
    background: #fff;
    border-right: 1px solid #c5d4de;
    transition: background 0.15s ease, color 0.15s ease;
}

.prc-mode-segment:last-child span {
    border-right: 0;
}

.prc-mode-segment:hover span {
    background: #eef6fb;
}

.prc-mode-segment input:checked + span {
    background: #007cba;
    color: #fff;
}

.prc-mode-segment input:focus-visible + span {
    outline: 2px solid #007cba;
    outline-offset: -2px;
}

.prc-find-fields {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    margin-bottom: 16px;
}

.prc-find-fields label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-weight: 600;
}

.prc-find-fields input[type="date"],
.prc-find-fields input[type="text"] {
    min-width: 220px;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 16px;
    font-weight: 400;
}

.prc-find-actions {
    margin-top: 8px;
}

.prc-find-status {
    background: #e7f3fb;
    color: #0b4f75;
    padding: 12px 15px;
    border: 1px solid #b6daf2;
    border-radius: 4px;
    margin: 10px 0;
}

.prc-find-orders-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 12px;
}

.prc-find-orders-table th,
.prc-find-orders-table td {
    padding: 12px;
    border-bottom: 1px solid #dee2e6;
    text-align: left;
    vertical-align: top;
}

.prc-find-orders-table th {
    background: #f8f9fa;
    font-weight: 600;
}

.prc-find-orders-table .prc-sort-row th[data-sortable="true"] {
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
}

.prc-find-orders-table .prc-sort-row th[data-sortable="true"]:hover {
    background: #e9ecef;
}

.prc-find-orders-table .sort-indicator {
    display: inline-block;
    width: 0;
    height: 0;
    margin-left: 6px;
    vertical-align: middle;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-bottom: 5px solid #adb5bd;
}

.prc-find-orders-table .sort-indicator.sort-asc {
    border-bottom: 5px solid #007cba;
    border-top: 0;
}

.prc-find-orders-table .sort-indicator.sort-desc {
    border-bottom: 0;
    border-top: 5px solid #007cba;
}

.prc-find-orders-table .prc-filter-row th {
    background: #fff;
    padding: 8px 12px;
    font-weight: 400;
}

.prc-find-orders-table .prc-col-filter {
    width: 100%;
    min-width: 0;
    padding: 6px 8px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 13px;
    font-weight: 400;
}

.prc-find-orders-table .prc-order-row {
    cursor: pointer;
}

.prc-find-orders-table .prc-order-row:hover,
.prc-find-orders-table .prc-order-row:focus {
    background: #eef6fb;
}

.prc-order-summary-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px 24px;
    margin: 16px 0;
}

.prc-find-overlay {
    position: absolute;
    inset: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.72);
    backdrop-filter: blur(1px);
}

.prc-find-overlay[hidden] {
    display: none;
}

.prc-find-orders.prc-is-busy {
    pointer-events: none;
}

.prc-find-overlay-card {
    position: sticky;
    top: 35vh;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 22px;
    background: #fff;
    border: 1px solid #d9e3ea;
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    color: #0b4f75;
    font-weight: 600;
}

.prc-find-orders .prc-orders-table-wrapper {
    overflow-x: auto;
}

.prc-find-table-toolbar {
    display: flex;
    justify-content: flex-end;
    margin: 8px 0 4px;
}

.prc-find-orders .prc-export-csv {
    background: #309748;
    border-color: #309748;
    color: #fff;
}

.prc-find-orders .prc-export-csv:hover,
.prc-find-orders .prc-export-csv:focus {
    background: #218838;
    border-color: #218838;
    color: #fff;
}

.prc-find-spinner {
    width: 22px;
    height: 22px;
    border: 3px solid #d9e3ea;
    border-top-color: #007cba;
    border-radius: 50%;
    animation: prc-spin 0.8s linear infinite;
}

.prc-tracking-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.prc-tracking-link,
.prc-tracking-plain {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 600;
    line-height: 1.3;
    word-break: break-all;
}

.prc-tracking-link {
    color: #0056b3;
    background: #e3f2fd;
    border: 1px solid #bbdefb;
    text-decoration: none;
}

.prc-tracking-link:hover,
.prc-tracking-link:focus {
    background: #bbdefb;
    border-color: #90caf9;
    text-decoration: none;
    color: #003d80;
}

.prc-tracking-plain {
    color: #495057;
    background: #f1f3f5;
    border: 1px solid #dee2e6;
}

.prc-tracking-empty {
    color: #868e96;
}

.prc-document-card {
    background: #fff;
    border: 1px solid #e9ecef;
    border-radius: 6px;
    padding: 12px;
    margin-bottom: 10px;
}

.prc-document-card ul {
    margin: 8px 0 0 18px;
}

.prc-tracking-list {
    margin: 0;
    padding-left: 20px;
}

.prc-tracking-list li {
    margin-bottom: 12px;
}

.prc-back-to-results {
    margin-bottom: 12px;
}

@media (max-width: 768px) {
    .prc-mode-segments {
        width: 100%;
    }

    .prc-mode-segment {
        flex: 1 1 50%;
    }

    .prc-mode-segment span {
        width: 100%;
        text-align: center;
    }

    .prc-find-fields {
        flex-direction: column;
    }

    .prc-find-fields input[type="date"],
    .prc-find-fields input[type="text"] {
        min-width: 0;
        width: 100%;
    }

    .prc-order-summary-grid {
        grid-template-columns: 1fr;
    }
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
    .prc-orders-container {
        border: 2px solid #000;
    }
    
    .prc-orders-table th {
        background: #000;
        color: #fff;
    }
    
    .prc-orders-table tr:hover {
        background: #f0f0f0;
    }
    
    .woo-order-link {
        border: 2px solid #000;
        background: #fff;
        color: #000;
    }
}
