/* css/orders.css - Complete Orders Module Styles */
.orders-container {
    max-width: 100%;
    overflow-x: auto;
}

.table-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem;
    border-bottom: 1px solid var(--border);
    background: var(--card-bg);
}

.table-header h4 {
    margin-bottom: 10px;
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text);
}

.table-actions {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.search-box {
    position: relative;
    min-width: 250px;
}

.search-box i {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 0.875rem;
}

.search-input {
    width: 100%;
    padding: 0.625rem 1rem 0.625rem 2.5rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.875rem;
    background: var(--card-bg);
    color: var(--text);
    transition: all 0.2s ease;
}

.search-input:focus {
    outline: none;
    border-color: var(--primary-500);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.search-input::placeholder {
    color: var(--text-muted);
}

.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.data-table {
    width: 100%;
    min-width: 800px;
    border-collapse: collapse;
    background: var(--card-bg);
}

.data-table th {
    padding: 1rem 1.5rem;
    text-align: left;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.data-table td {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border-light);
    font-size: 0.875rem;
    color: var(--text);
    vertical-align: middle;
}

.data-table tr:last-child td {
    border-bottom: none;
}

.data-table tr:hover {
    background: var(--border-light);
}

.data-table tr:hover td {
    background: var(--border-light);
}

/* Order Status Badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.75rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1;
    white-space: nowrap;
}

.badge-primary {
    background: var(--primary-100);
    color: var(--primary-700);
}

.badge-success {
    background: #d1fae5;
    color: #065f46;
}

.badge-warning {
    background: #fef3c7;
    color: #92400e;
}

.badge-error {
    background: #fee2e2;
    color: #991b1b;
}

.badge-info {
    background: #dbeafe;
    color: #1e40af;
}

/* Order Actions */
.table-actions-inline {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.row-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
}

.row-actions .btn span {
    font-weight: 600;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border-radius: var(--radius);
    border: 1px solid transparent;
    font-size: 0.875rem;
    font-weight: 500;
    line-height: 1.5;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    white-space: nowrap;
}

.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.75rem;
    min-height: 2rem;
}

.btn-primary {
    background: var(--primary-600);
    color: white;
    border-color: var(--primary-600);
}

.btn-primary:hover {
    background: var(--primary-700);
    border-color: var(--primary-700);
}

.btn-secondary {
    background: var(--secondary-500);
    color: white;
    border-color: var(--secondary-500);
}

.btn-secondary:hover {
    background: var(--secondary-600);
    border-color: var(--secondary-600);
}

.btn-success {
    background: var(--success);
    color: white;
    border-color: var(--success);
}

.btn-success:hover {
    background: #0da76e;
    border-color: #0da76e;
}

.btn-error {
    background: var(--error);
    color: white;
    border-color: var(--error);
}

.btn-error:hover {
    background: #dc2626;
    border-color: #dc2626;
}

.btn-outline {
    background: transparent;
    color: var(--text);
    border-color: var(--border);
}

.btn-outline:hover {
    background: var(--border-light);
    border-color: var(--text-muted);
}

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

.btn i {
    font-size: 0.875em;
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    border-top: 1px solid var(--border);
    background: var(--card-bg);
}

.pagination-info {
    font-size: 0.875rem;
    color: var(--text-muted);
}

.pagination-controls {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.pagination-controls .btn {
    min-width: 2.5rem;
    height: 2.5rem;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* Order Details Modal */
.order-details-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
    margin-bottom: 2rem;
}

.detail-section {
    background: var(--bg);
    padding: 1.5rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.detail-section h4 {
    margin: 0 0 1rem 0;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text);
}

.detail-item {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.75rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border-light);
}

.detail-item:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.detail-label {
    font-weight: 500;
    color: var(--text-muted);
    font-size: 0.875rem;
}

.detail-value {
    text-align: right;
    color: var(--text);
    font-size: 0.875rem;
    max-width: 200px;
    word-break: break-word;
}

/* Order Items */
.order-items-section {
    margin-top: 2rem;
}

.order-items-section h4 {
    margin: 0 0 1rem 0;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text);
}

.order-items-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.order-item-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 1rem;
    background: var(--bg);
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.item-info {
    flex: 1;
}

.item-name {
    font-weight: 500;
    color: var(--text);
    margin-bottom: 0.25rem;
    display: block;
}

a.item-name {
    color: var(--primary, #4f46e5);
    text-decoration: none;
    cursor: pointer;
}

a.item-name:hover {
    text-decoration: underline;
}

.item-sku {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.item-details {
    text-align: right;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.item-quantity, .item-price {
    font-size: 0.875rem;
    color: var(--text-muted);
}

.item-total {
    font-weight: 600;
    color: var(--text);
    font-size: 0.875rem;
}

/* Order Summary */
.order-summary {
    margin-top: 2rem;
    padding: 1.5rem;
    background: var(--bg);
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.summary-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border-light);
}

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

.summary-row.total {
    padding-top: 1rem;
    margin-top: 0.5rem;
    border-top: 2px solid var(--border);
    font-weight: 600;
    font-size: 1.125rem;
}

.total-amount {
    color: var(--primary-600);
    font-weight: 700;
}

/* Filter Dropdowns */
.filter-group {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.filter-select {
    padding: 0.625rem 2.5rem 0.625rem 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.875rem;
    background: var(--card-bg);
    color: var(--text);
    cursor: pointer;
    min-width: 150px;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2364748b'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 1rem;
}

.filter-select:focus {
    outline: none;
    border-color: var(--primary-500);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.date-filter {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.date-input {
    padding: 0.625rem 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.875rem;
    background: var(--card-bg);
    color: var(--text);
    min-width: 120px;
}

.date-input:focus {
    outline: none;
    border-color: var(--primary-500);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

/* Export Button */
.export-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 1rem;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.export-btn:hover {
    background: var(--border-light);
    border-color: var(--text-muted);
}

/* Empty State */
.orders-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4rem 2rem;
    text-align: center;
    background: var(--card-bg);
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.orders-empty-state i {
    font-size: 3rem;
    color: var(--text-muted);
    margin-bottom: 1.5rem;
}

.orders-empty-state h4 {
    margin: 0 0 0.5rem 0;
    color: var(--text);
    font-size: 1.25rem;
}

.orders-empty-state p {
    margin: 0 0 1.5rem 0;
    color: var(--text-muted);
    max-width: 400px;
}

/* Loading State */
.orders-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4rem 2rem;
    text-align: center;
}

.orders-loading .spinner {
    margin-bottom: 1rem;
}

.orders-loading p {
    color: var(--text-muted);
    margin: 0;
}

/* Responsive Design */
@media (max-width: 1024px) {
    .table-header {
        flex-direction: column;
        gap: 1rem;
        align-items: stretch;
    }
    
    .table-actions {
        flex-wrap: wrap;
    }
    
    .search-box {
        min-width: 100%;
    }
    
    .filter-group {
        flex-wrap: wrap;
    }
    
    .filter-select, .date-input {
        min-width: calc(50% - 0.5rem);
    }
}

@media (max-width: 768px) {
    .data-table {
        min-width: 600px;
    }
    
    .pagination {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }
    
    .pagination-controls {
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .order-details-grid {
        grid-template-columns: 1fr;
    }
    
    .detail-item {
        flex-direction: column;
        gap: 0.25rem;
    }
    
    .detail-value {
        text-align: left;
        max-width: 100%;
    }
    
    .order-item-row {
        flex-direction: column;
        gap: 0.75rem;
    }
    
    .item-details {
        text-align: left;
        width: 100%;
    }
}

@media (max-width: 640px) {
    .data-table th,
    .data-table td {
        padding: 0.75rem 1rem;
    }
    
    .table-actions-inline {
        flex-direction: column;
        gap: 0.5rem;
        align-items: flex-start;
    }
    
    .btn-sm {
        width: 100%;
        justify-content: center;
    }
}

/* ===== MOBILE/TABLET RESPONSIVE OVERHAUL ===== */
@media (max-width: 1024px) {
    .orders-container {
        padding: 0;
    }
    
    .table-header {
        flex-direction: column;
        gap: 0.75rem;
        align-items: stretch;
        padding: 1rem;
    }
    
    .table-actions {
        flex-wrap: wrap;
        gap: 0.5rem;
    }
    
    .search-box {
        min-width: 100%;
        order: -1;
    }
    
    .filter-group {
        width: 100%;
        flex-wrap: wrap;
    }
    
    .filter-select,
    .date-input {
        flex: 1;
        min-width: calc(50% - 0.5rem);
    }
    
    .table-responsive {
        margin: 0 -0.5rem;
        padding: 0 0.5rem;
    }
}

@media (max-width: 768px) {
    .table-header {
        padding: 0.75rem;
    }
    
    .table-header h4 {
        font-size: 1.1rem;
    }
    
    .data-table {
        min-width: 550px;
    }
    
    .data-table th,
    .data-table td {
        padding: 0.75rem 0.5rem;
        font-size: 0.8125rem;
    }
    
    /* Hide less important columns on mobile */
    .data-table th:nth-child(5),
    .data-table td:nth-child(5) {
        display: none;
    }
    
    .pagination {
        flex-direction: column;
        gap: 0.75rem;
        padding: 1rem;
        text-align: center;
    }
    
    .pagination-controls {
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .order-details-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .detail-section {
        padding: 1rem;
    }
    
    .detail-item {
        flex-direction: column;
        gap: 0.25rem;
    }
    
    .detail-label {
        font-size: 0.75rem;
    }
    
    .detail-value {
        text-align: left;
        max-width: 100%;
        font-size: 0.875rem;
    }
    
    /* Modal adjustments */
    .modal-content {
        margin: 0.5rem;
        max-height: calc(100vh - 1rem);
        width: calc(100% - 1rem);
    }
    
    .modal-header {
        padding: 1rem;
    }
    
    .modal-body {
        padding: 1rem;
    }
    
    .modal-footer {
        padding: 1rem;
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .modal-footer .btn {
        width: 100%;
    }
    
    .order-item-row {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .item-details {
        text-align: left;
        width: 100%;
    }
}

@media (max-width: 480px) {
    .filter-select,
    .date-input {
        min-width: 100%;
    }
    
    .data-table th:nth-child(3),
    .data-table td:nth-child(3),
    .data-table th:nth-child(4),
    .data-table td:nth-child(4) {
        display: none;
    }
    
    .badge {
        padding: 0.2rem 0.5rem;
        font-size: 0.7rem;
    }
    
    .btn {
        padding: 0.5rem 0.75rem;
        font-size: 0.8125rem;
    }
}