/**
 * Frontend Admin Styles
 * 
 * @package FrontendAdmin
 */

/* Search Container */
.frontend-admin-search-container {
    margin: 20px 0;
}

.search-form {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

/* Keep search input and primary search button on the first row */
#frontend-admin-search {
    order: 1;
}

#frontend-admin-search-btn {
    order: 2;
}

/* Move filters to the next row and span full width */
.search-form .filters {
    order: 3;
    flex: 0 0 100%;
}

/* Optional: place clear button after filters */
#frontend-admin-clear-btn {
    order: 4;
}

#frontend-admin-search {
    flex: 1;
    min-width: 300px;
    padding: 12px 15px;
    border: 2px solid #ddd;
    border-radius: 4px;
    font-size: 16px;
    transition: border-color 0.3s ease;
}

#frontend-admin-search:focus {
    outline: none;
    border-color: #0073aa;
}

.search-form .button {
    padding: 12px 20px;
    font-size: 16px;
    cursor: pointer;
    border: none;
    border-radius: 4px;
    transition: background-color 0.3s ease;
}

.search-form .button:hover {
    opacity: 0.9;
}

/* Loading Spinner */
.loading-spinner {
    text-align: center;
    padding: 20px;
    font-style: italic;
    color: #666;
}

.loading-spinner:before {
    content: '';
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #0073aa;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-right: 10px;
}

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

/* Filters row: place date-from, date-to, and status on the same line */
.frontend-admin-search-container .filters {
    display: flex;
    gap: 10px;
    align-items: flex-end; /* align inputs/selects along bottom for clean row */
    flex-wrap: wrap; /* allow wrap on small screens */
    width: 100%;
}

.frontend-admin-search-container .filters .filter-group {
    flex: 0 1 auto; /* size to intrinsic width of inner control */
    min-width: 0;
}

.frontend-admin-search-container .filters .filter-group label {
    display: block;
    font-size: 12px;
    color: #666;
    margin-bottom: 4px;
}

/* Make date fields compact */
.frontend-admin-search-container .filters .filter-group input[type="date"] {
    box-sizing: border-box;
    width: 126px;
    max-width: 126px;
    font-size: 12px;
    padding: 4px 6px;
}

/* Constrain status select width so it doesn't force wrapping */
.frontend-admin-search-container .filters .filter-group select#frontend-admin-status {
    width: 170px;
    max-width: 170px;
    font-size: 13px;
    padding: 6px 8px;
}

@media (max-width: 768px) {
    .frontend-admin-search-container .filters .filter-group {
        flex: 1 1 100%; /* stack on small screens */
    }
}

/* Results */
.search-results {
    margin-top: 20px;
}

.orders-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.order-item {
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 20px;
    background: #fff;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    transition: box-shadow 0.3s ease;
}

.order-item:hover {
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

.order-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    flex-wrap: wrap;
    gap: 10px;
}

.order-id {
    flex: 1;
    min-width: 200px;
}

.order-id strong {
    font-size: 18px;
    color: #0073aa;
}

.order-date {
    display: block;
    font-size: 14px;
    color: #666;
    margin-top: 2px;
}

.order-status {
    flex-shrink: 0;
}

.order-total {
    flex-shrink: 0;
    font-size: 18px;
    color: #2c3e50;
}

.order-details {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    flex-wrap: wrap;
    gap: 15px;
}

.customer-info {
    flex: 1;
    min-width: 200px;
}

.customer-info small {
    color: #666;
}

.item-count {
    color: #666;
    font-style: italic;
}

.order-actions {
    flex-shrink: 0;
}

/* Order Items Summary */
.order-items-summary {
    flex: 1 1 100%;
    margin-top: 15px;
    padding: 12px;
    background: #f8f9fa;
    border-radius: 6px;
    border: 1px solid #e9ecef;
}

.order-items-summary strong {
    color: #495057;
    margin-bottom: 8px;
    display: block;
}

.items-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.item-summary {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 0;
    border-bottom: 1px solid #e9ecef;
}

.item-summary:last-child {
    border-bottom: none;
}

.item-name {
    flex: 1;
    font-weight: 500;
    color: #212529;
}

.item-sku {
    font-size: 12px;
    color: #6c757d;
    font-style: italic;
}

.item-quantity {
    font-weight: 500;
    color: #495057;
    min-width: 40px;
    text-align: center;
}

.item-total {
    font-weight: 600;
    color: #28a745;
    min-width: 80px;
    text-align: right;
}

@media (max-width: 768px) {
    .item-summary {
        flex-wrap: wrap;
        gap: 6px;
    }
    
    .item-name {
        flex: 1 1 100%;
    }
    
    .item-sku,
    .item-quantity,
    .item-total {
        flex: 0 1 auto;
    }
}

/* Status Styles */
.status {
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: bold;
    text-transform: uppercase;
}

.status-pending {
    background: #f39c12;
    color: white;
}

.status-processing {
    background: #3498db;
    color: white;
}

.status-on-hold {
    background: #95a5a6;
    color: white;
}

.status-completed {
    background: #27ae60;
    color: white;
}

.status-cancelled {
    background: #e74c3c;
    color: white;
}

.status-refunded {
    background: #9b59b6;
    color: white;
}

.status-failed {
    background: #c0392b;
    color: white;
}

/* No Results */
.no-results {
    text-align: center;
    padding: 40px 20px;
    color: #666;
    font-style: italic;
    background: #f8f8f8;
    border-radius: 8px;
}

.error-message {
    background: #f8d7da;
    color: #721c24;
    padding: 15px;
    border-radius: 4px;
    border: 1px solid #f5c6cb;
}

/* Pagination */
.pagination-container {
    margin-top: 30px;
    text-align: center;
}

.pagination {
    display: inline-flex;
    gap: 5px;
    margin-bottom: 10px;
    flex-wrap: wrap;
    justify-content: center;
}

.frontend-admin-page-btn {
    padding: 8px 12px;
    border: 1px solid #ddd;
    background: #fff;
    color: #0073aa;
    text-decoration: none;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.frontend-admin-page-btn:hover {
    background: #0073aa;
    color: #fff;
    border-color: #0073aa;
}

.frontend-admin-page-btn.active {
    background: #0073aa;
    color: #fff;
    border-color: #0073aa;
}

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

.pagination-info {
    color: #666;
    font-size: 14px;
}

/* Modal */
.frontend-admin-modal {
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: none; /* hidden by default; toggled via .is-open */
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.frontend-admin-modal.is-open {
    display: flex;
}

.modal-content {
    background-color: #fff;
    padding: 0;
    border-radius: 8px;
    width: 90%;
    max-width: 800px;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.modal-close {
    position: absolute;
    top: 15px;
    right: 20px;
    font-size: 28px;
    font-weight: bold;
    color: #aaa;
    cursor: pointer;
    z-index: 1001;
}

.modal-close:hover {
    color: #000;
}

.modal-content h3 {
    margin: 0;
    padding: 20px 20px 15px 20px;
    border-bottom: 1px solid #eee;
    background: #f8f9fa;
    border-radius: 8px 8px 0 0;
}

#frontend-admin-modal-content {
    padding: 20px;
}

/* Order Details */
.order-details-content {
    display: flex;
    flex-direction: column;
    gap: 25px;
}

.order-summary-table,
.order-items-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
}

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

.order-summary-table td:first-child {
    background: #f8f9fa;
    width: 30%;
}

.order-items-table th {
    background: #f8f9fa;
    font-weight: bold;
}

/* Refund columns are hidden by default until refund mode is toggled */
.order-items-table .refund-col {
    display: none;
}

.order-items-table.show-refund-cols .refund-col {
    display: table-cell;
}

.customer-info-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-top: 15px;
}

.billing-info,
.shipping-info {
    padding: 15px;
    background: #f8f9fa;
    border-radius: 4px;
}

.billing-info h5,
.shipping-info h5 {
    margin-top: 0;
    margin-bottom: 10px;
    color: #0073aa;
}

/* Responsive Design */
@media (max-width: 768px) {
    .search-form {
        flex-direction: column;
    }
    
    #frontend-admin-search {
        min-width: auto;
    }
    
    .order-header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .order-details {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .customer-info-grid {
        grid-template-columns: 1fr;
    }
    
    .modal-content {
        width: 95%;
        margin: 10px;
    }
    
    .pagination {
        justify-content: center;
    }
    
    .order-items-table {
        font-size: 14px;
    }
    
    .order-items-table th,
    .order-items-table td {
        padding: 6px 8px;
    }
}

@media (max-width: 480px) {
    .order-item {
        padding: 15px;
    }
    
    .order-id strong {
        font-size: 16px;
    }
    
    .order-total {
        font-size: 16px;
    }
    
    .modal-content {
        max-height: 95vh;
    }
    
    .order-items-table {
        font-size: 12px;
    }
    
    .customer-info-grid {
        gap: 15px;
    }
    
    .billing-info,
    .shipping-info {
        padding: 12px;
    }
}