/**
 * Search and Messaging Styles
 * Styles for product search, filtering, and messaging functionality
 */

/* ==========================================================================
   Search Form Styles
   ========================================================================== */

.rm-search-form {
    background: #fff;
    border: 1px solid #e1e5e9;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 30px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.rm-search-container {
    width: 100%;
}

.rm-search-row {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    align-items: end;
}

.rm-search-field {
    flex: 1;
    min-width: 200px;
}

.rm-search-field label {
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
    color: #333;
    font-size: 14px;
}

.rm-search-field input,
.rm-search-field select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    transition: border-color 0.3s ease;
}

.rm-search-field input:focus,
.rm-search-field select:focus {
    outline: none;
    border-color: #007cba;
    box-shadow: 0 0 0 2px rgba(0, 124, 186, 0.1);
}

.rm-search-keyword {
    flex: 2;
    min-width: 250px;
}

.rm-search-submit {
    flex: 0 0 auto;
}

.rm-search-submit .rm-btn {
    padding: 10px 20px;
    white-space: nowrap;
}

.rm-price-range {
    display: flex;
    align-items: center;
    gap: 10px;
}

.rm-price-range input {
    flex: 1;
    margin: 0;
}

.rm-price-separator {
    color: #666;
    font-weight: 500;
}

/* Advanced Filters */
.rm-advanced-filters {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid #e1e5e9;
}

.rm-filter-row {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
}

.rm-filter-field {
    flex: 1;
    min-width: 200px;
}

.rm-filter-toggle {
    margin-top: 15px;
    display: flex;
    gap: 10px;
    justify-content: center;
}

/* Layout Variations */
.rm-layout-horizontal .rm-search-row {
    flex-direction: row;
}

.rm-layout-vertical .rm-search-row {
    flex-direction: column;
}

.rm-layout-vertical .rm-search-field {
    width: 100%;
}

/* ==========================================================================
   Product Search Results
   ========================================================================== */

.rm-product-search {
    margin-bottom: 30px;
}

.rm-search-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding: 15px 0;
    border-bottom: 1px solid #e1e5e9;
}

.rm-search-results-info {
    color: #666;
    font-size: 14px;
}

.rm-results-count {
    font-weight: 600;
    color: #333;
}

.rm-search-controls {
    display: flex;
    align-items: center;
    gap: 15px;
}

.rm-layout-toggle {
    display: flex;
    border: 1px solid #ddd;
    border-radius: 4px;
    overflow: hidden;
}

.rm-layout-btn {
    background: #fff;
    border: none;
    padding: 8px 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    border-right: 1px solid #ddd;
}

.rm-layout-btn:last-child {
    border-right: none;
}

.rm-layout-btn:hover {
    background: #f5f5f5;
}

.rm-layout-btn.active {
    background: #007cba;
    color: #fff;
}

.rm-layout-btn .dashicons {
    font-size: 16px;
    width: 16px;
    height: 16px;
}

/* Loading State */
.rm-search-loading {
    text-align: center;
    padding: 40px 20px;
    color: #666;
}

.rm-loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #007cba;
    border-radius: 50%;
    animation: rm-spin 1s linear infinite;
    margin: 0 auto 15px;
}

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

/* No Results */
.rm-no-results {
    text-align: center;
    padding: 60px 20px;
    color: #666;
}

.rm-no-results p {
    font-size: 16px;
    margin: 0;
}

/* ==========================================================================
   Product Cards
   ========================================================================== */

.rm-products-grid {
    display: grid;
    gap: 20px;
}

.rm-layout-grid {
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}

.rm-layout-list {
    grid-template-columns: 1fr;
}

.rm-product-card {
    background: #fff;
    border: 1px solid #e1e5e9;
    border-radius: 8px;
    overflow: hidden;
    transition: all 0.3s ease;
    position: relative;
}

.rm-product-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
}

.rm-product-card.rm-featured {
    border-color: #ffc107;
    box-shadow: 0 2px 8px rgba(255, 193, 7, 0.2);
}

.rm-featured-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    background: #ffc107;
    color: #333;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    z-index: 2;
}

.rm-product-image {
    position: relative;
    overflow: hidden;
}

.rm-layout-grid .rm-product-image {
    height: 200px;
}

.rm-layout-list .rm-product-image {
    width: 200px;
    height: 150px;
    flex-shrink: 0;
}

.rm-product-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.rm-product-card:hover .rm-product-image img {
    transform: scale(1.05);
}

.rm-product-content {
    padding: 15px;
}

.rm-layout-list .rm-product-card {
    display: flex;
    align-items: stretch;
}

.rm-layout-list .rm-product-content {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.rm-product-title {
    margin: 0 0 10px;
    font-size: 16px;
    line-height: 1.4;
}

.rm-product-title a {
    color: #333;
    text-decoration: none;
    transition: color 0.3s ease;
}

.rm-product-title a:hover {
    color: #007cba;
}

.rm-product-excerpt {
    color: #666;
    font-size: 14px;
    line-height: 1.5;
    margin-bottom: 15px;
}

.rm-product-meta {
    margin-bottom: 15px;
}

.rm-product-price {
    margin-bottom: 8px;
}

.rm-price {
    font-size: 18px;
    font-weight: 700;
    color: #007cba;
}

.rm-price-type {
    font-size: 14px;
    color: #666;
    margin-left: 2px;
}

.rm-product-condition {
    margin-bottom: 8px;
}

.rm-condition {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
    text-transform: uppercase;
}

.rm-condition-new {
    background: #d4edda;
    color: #155724;
}

.rm-condition-like-new {
    background: #d1ecf1;
    color: #0c5460;
}

.rm-condition-good {
    background: #fff3cd;
    color: #856404;
}

.rm-condition-fair {
    background: #f8d7da;
    color: #721c24;
}

.rm-condition-poor {
    background: #f5c6cb;
    color: #721c24;
}

.rm-product-location {
    display: flex;
    align-items: center;
    color: #666;
    font-size: 14px;
    margin-bottom: 8px;
}

.rm-product-location .dashicons {
    margin-right: 4px;
    font-size: 14px;
    width: 14px;
    height: 14px;
}

.rm-product-actions {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
}

.rm-layout-list .rm-product-actions {
    margin-top: auto;
}

.rm-product-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    color: #999;
    border-top: 1px solid #f0f0f0;
    padding-top: 10px;
}

/* ==========================================================================
   Pagination
   ========================================================================== */

.rm-pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 5px;
    margin-top: 30px;
    padding: 20px 0;
}

.rm-page-btn {
    background: #fff;
    border: 1px solid #ddd;
    color: #333;
    padding: 8px 12px;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.3s ease;
    font-size: 14px;
}

.rm-page-btn:hover {
    background: #f5f5f5;
    border-color: #007cba;
}

.rm-page-btn.active {
    background: #007cba;
    color: #fff;
    border-color: #007cba;
}

.rm-page-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.rm-pagination-dots {
    padding: 8px 4px;
    color: #999;
}

/* ==========================================================================
   Messages
   ========================================================================== */

.rm-messages-container {
    background: #fff;
    border: 1px solid #e1e5e9;
    border-radius: 8px;
    overflow: hidden;
}

.rm-messages-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    background: #f8f9fa;
    border-bottom: 1px solid #e1e5e9;
}

.rm-messages-header h3 {
    margin: 0;
    color: #333;
}

.rm-messages-filters {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background: #fff;
    border-bottom: 1px solid #e1e5e9;
}

.rm-message-tabs {
    display: flex;
    gap: 5px;
}

.rm-tab-btn {
    background: transparent;
    border: 1px solid #ddd;
    color: #666;
    padding: 8px 16px;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.3s ease;
    position: relative;
}

.rm-tab-btn:hover {
    background: #f5f5f5;
}

.rm-tab-btn.active {
    background: #007cba;
    color: #fff;
    border-color: #007cba;
}

.rm-unread-count {
    background: #dc3545;
    color: #fff;
    border-radius: 10px;
    padding: 2px 6px;
    font-size: 11px;
    margin-left: 5px;
    display: none;
}

.rm-message-actions {
    display: flex;
    gap: 10px;
}

.rm-messages-list-container {
    max-height: 600px;
    overflow-y: auto;
}

.rm-message-item {
    padding: 15px 20px;
    border-bottom: 1px solid #f0f0f0;
    transition: background-color 0.3s ease;
    cursor: pointer;
}

.rm-message-item:hover {
    background: #f8f9fa;
}

.rm-message-item.rm-unread {
    background: #fff3cd;
    border-left: 4px solid #ffc107;
}

.rm-message-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.rm-message-user {
    font-weight: 600;
    color: #333;
}

.rm-message-product {
    font-weight: normal;
    color: #666;
    font-size: 14px;
    margin-left: 10px;
}

.rm-message-date {
    font-size: 12px;
    color: #999;
}

.rm-message-subject {
    font-weight: 500;
    color: #333;
    margin-bottom: 5px;
}

.rm-message-preview {
    color: #666;
    font-size: 14px;
    line-height: 1.4;
    margin-bottom: 10px;
}

.rm-message-item .rm-message-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

.rm-no-messages {
    text-align: center;
    padding: 60px 20px;
    color: #666;
}

/* ==========================================================================
   Message Modal
   ========================================================================== */

.rm-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.rm-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 9999;
}

.rm-modal-content {
    background: #fff;
    border-radius: 8px;
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    z-index: 10001;
}

.rm-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid #e1e5e9;
}

.rm-modal-header h3 {
    margin: 0;
    color: #333;
}

.rm-modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #999;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.rm-modal-close:hover {
    color: #333;
}

#rm-message-form {
    padding: 20px;
}

.rm-form-group {
    margin-bottom: 20px;
}

.rm-form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
    color: #333;
}

.rm-form-group input,
.rm-form-group textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    transition: border-color 0.3s ease;
    box-sizing: border-box;
}

.rm-form-group input:focus,
.rm-form-group textarea:focus {
    outline: none;
    border-color: #007cba;
    box-shadow: 0 0 0 2px rgba(0, 124, 186, 0.1);
}

.rm-form-group textarea {
    resize: vertical;
    min-height: 100px;
}

.rm-form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 20px;
}

/* ==========================================================================
   Buttons
   ========================================================================== */

.rm-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 16px;
    border: 1px solid transparent;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.3s ease;
    gap: 5px;
}

.rm-btn:focus {
    outline: none;
    box-shadow: 0 0 0 2px rgba(0, 124, 186, 0.2);
}

.rm-btn-primary {
    background: #007cba;
    color: #fff;
    border-color: #007cba;
}

.rm-btn-primary:hover {
    background: #005a87;
    border-color: #005a87;
    color: #fff;
}

.rm-btn-secondary {
    background: #6c757d;
    color: #fff;
    border-color: #6c757d;
}

.rm-btn-secondary:hover {
    background: #545b62;
    border-color: #545b62;
    color: #fff;
}

.rm-btn-danger {
    background: #dc3545;
    color: #fff;
    border-color: #dc3545;
}

.rm-btn-danger:hover {
    background: #c82333;
    border-color: #c82333;
    color: #fff;
}

.rm-btn-sm {
    padding: 6px 12px;
    font-size: 12px;
}

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

.rm-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid transparent;
    border-top: 2px solid currentColor;
    border-radius: 50%;
    animation: rm-spin 1s linear infinite;
}

/* ==========================================================================
   Alerts
   ========================================================================== */

.rm-message-alert {
    padding: 12px 16px;
    border-radius: 4px;
    margin-bottom: 20px;
    cursor: pointer;
    transition: opacity 0.3s ease;
}

.rm-alert-success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.rm-alert-error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.rm-alert-info {
    background: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
}

.rm-alert-warning {
    background: #fff3cd;
    color: #856404;
    border: 1px solid #ffeaa7;
}

/* ==========================================================================
   Responsive Design
   ========================================================================== */

@media (max-width: 768px) {
    .rm-search-row {
        flex-direction: column;
    }
    
    .rm-search-field {
        min-width: auto;
        width: 100%;
    }
    
    .rm-price-range {
        flex-direction: column;
        gap: 5px;
    }
    
    .rm-search-header {
        flex-direction: column;
        gap: 15px;
        align-items: stretch;
    }
    
    .rm-search-controls {
        justify-content: center;
    }
    
    .rm-layout-grid {
        grid-template-columns: 1fr;
    }
    
    .rm-layout-list .rm-product-card {
        flex-direction: column;
    }
    
    .rm-layout-list .rm-product-image {
        width: 100%;
        height: 200px;
    }
    
    .rm-messages-filters {
        flex-direction: column;
        gap: 15px;
        align-items: stretch;
    }
    
    .rm-message-tabs {
        justify-content: center;
    }
    
    .rm-message-actions {
        justify-content: center;
    }
    
    .rm-message-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 5px;
    }
    
    .rm-product-actions {
        flex-direction: column;
    }
    
    .rm-product-footer {
        flex-direction: column;
        gap: 5px;
        align-items: flex-start;
    }
    
    .rm-pagination {
        flex-wrap: wrap;
    }
    
    .rm-modal-content {
        width: 95%;
        margin: 20px;
    }
}

@media (max-width: 480px) {
    .rm-search-form {
        padding: 15px;
    }
    
    .rm-product-card {
        margin-bottom: 15px;
    }
    
    .rm-messages-container {
        border-radius: 0;
        border-left: none;
        border-right: none;
    }
    
    .rm-message-item {
        padding: 12px 15px;
    }
    
    .rm-modal-content {
        width: 100%;
        height: 100%;
        border-radius: 0;
        margin: 0;
    }
}

/* ==========================================================================
   Print Styles
   ========================================================================== */

@media print {
    .rm-search-form,
    .rm-search-controls,
    .rm-pagination,
    .rm-message-actions,
    .rm-btn {
        display: none !important;
    }
    
    .rm-product-card {
        break-inside: avoid;
        box-shadow: none;
        border: 1px solid #ccc;
    }
    
    .rm-message-item {
        break-inside: avoid;
    }
}

/* ==========================================================================
   High Contrast Mode
   ========================================================================== */

@media (prefers-contrast: high) {
    .rm-product-card {
        border-width: 2px;
    }
    
    .rm-btn {
        border-width: 2px;
    }
    
    .rm-message-item.rm-unread {
        border-left-width: 6px;
    }
}

/* ==========================================================================
   Reduced Motion
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
    .rm-product-card,
    .rm-btn,
    .rm-search-field input,
    .rm-search-field select,
    .rm-message-item {
        transition: none;
    }
    
    .rm-loading-spinner {
        animation: none;
        border: 4px solid #007cba;
    }
    
    .rm-spinner {
        animation: none;
        border: 2px solid currentColor;
    }
}

/* ==========================================================================
   Dark Mode Support
   ========================================================================== */

@media (prefers-color-scheme: dark) {
    .rm-search-form,
    .rm-product-card,
    .rm-messages-container,
    .rm-modal-content {
        background: #2c3e50;
        border-color: #34495e;
        color: #ecf0f1;
    }
    
    .rm-search-field input,
    .rm-search-field select,
    .rm-form-group input,
    .rm-form-group textarea {
        background: #34495e;
        border-color: #4a5f7a;
        color: #ecf0f1;
    }
    
    .rm-product-title a {
        color: #ecf0f1;
    }
    
    .rm-product-title a:hover {
        color: #3498db;
    }
    
    .rm-message-item:hover {
        background: #34495e;
    }
    
    .rm-messages-header {
        background: #34495e;
    }
}