/* Orders Page Styles - v20251222a */

/* Page Layout */
.orders-page {
    padding: 24px 32px;
    max-width: 1400px;
}

/* Page Header */
.orders-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 24px;
}

.orders-header-left {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.orders-title {
    font-size: 24px;
    font-weight: 600;
    color: var(--ai-text-dark);
    margin: 0;
    letter-spacing: -0.02em;
}

.orders-subtitle {
    font-size: 14px;
    color: var(--ai-text-muted);
    margin: 0;
}

.orders-header-right {
    display: flex;
    gap: 12px;
}

/* Buttons (reuse from products if loaded together, otherwise define here) */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    font-size: 14px;
    font-weight: 500;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.15s ease;
    border: none;
    font-family: var(--ai-font);
}

.btn-primary {
    background: var(--ai-primary);
    color: #fff;
}

.btn-primary:hover {
    background: #6b00b3;
}

.btn-secondary {
    background: var(--ai-bg-white);
    color: var(--ai-text-medium);
    border: 1px solid var(--ai-border);
}

.btn-secondary:hover {
    background: var(--ai-bg-main);
}

.btn-danger {
    background: #DC2626;
    color: #fff;
}

.btn-danger:hover {
    background: #B91C1C;
}

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

/* Stats Cards */
.orders-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.orders-stat-card {
    background: var(--ai-bg-white);
    border: 1px solid var(--ai-border);
    border-radius: 12px;
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
}

.orders-stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.orders-stat-icon--blue {
    background: var(--ai-blue-light);
    color: var(--ai-blue);
}

.orders-stat-icon--green {
    background: var(--ai-green-light);
    color: var(--ai-green);
}

.orders-stat-icon--orange {
    background: var(--ai-orange-light);
    color: var(--ai-orange);
}

.orders-stat-icon--purple {
    background: var(--ai-purple-light);
    color: var(--ai-purple);
}

.orders-stat-content {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.orders-stat-value {
    font-size: 28px;
    font-weight: 600;
    color: var(--ai-text-dark);
    line-height: 1.2;
}

.orders-stat-label {
    font-size: 14px;
    color: var(--ai-text-muted);
}

/* Toolbar */
.orders-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    gap: 16px;
}

.orders-filters {
    display: flex;
    gap: 12px;
}

.orders-filter-select {
    padding: 8px 32px 8px 12px;
    font-size: 14px;
    border: 1px solid var(--ai-border);
    border-radius: 8px;
    background: var(--ai-bg-white);
    color: var(--ai-text-medium);
    cursor: pointer;
    font-family: var(--ai-font);
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236A7282' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
}

.orders-filter-select:focus {
    outline: none;
    border-color: var(--ai-primary);
}

.orders-search {
    position: relative;
    flex: 1;
    max-width: 320px;
}

.orders-search-input {
    width: 100%;
    padding: 8px 12px 8px 36px;
    font-size: 14px;
    border: 1px solid var(--ai-border);
    border-radius: 8px;
    background: var(--ai-bg-white);
    font-family: var(--ai-font);
}

.orders-search-input:focus {
    outline: none;
    border-color: var(--ai-primary);
}

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

.orders-search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--ai-text-muted);
    pointer-events: none;
}

/* Table Container */
.orders-table-container {
    background: var(--ai-bg-white);
    border: 1px solid var(--ai-border);
    border-radius: 12px;
    overflow: hidden;
}

/* Table */
.orders-table {
    width: 100%;
    border-collapse: collapse;
}

.orders-table thead {
    background: var(--ai-bg-main);
    border-bottom: 1px solid var(--ai-border);
}

.orders-table th {
    padding: 12px 16px;
    text-align: left;
    font-size: 12px;
    font-weight: 500;
    color: var(--ai-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.orders-table tbody tr {
    border-bottom: 1px solid var(--ai-border);
    transition: background 0.15s ease;
    cursor: pointer;
}

.orders-table tbody tr:last-child {
    border-bottom: none;
}

.orders-table tbody tr:hover {
    background: var(--ai-bg-main);
}

.orders-table td {
    padding: 16px;
    font-size: 14px;
    color: var(--ai-text-medium);
    vertical-align: middle;
}

.orders-th-number {
    width: 120px;
}

.orders-th-customer {
    min-width: 180px;
}

.orders-th-items {
    width: 100px;
}

.orders-th-total {
    width: 100px;
}

.orders-th-status {
    width: 120px;
}

.orders-th-payment {
    width: 100px;
}

.orders-th-date {
    width: 140px;
}

.orders-th-actions {
    width: 80px;
    text-align: right;
}

/* Order Number */
.order-number {
    font-family: 'SF Mono', SFMono-Regular, Consolas, monospace;
    font-weight: 600;
    color: var(--ai-primary);
}

/* Customer Cell */
.customer-cell {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.customer-name {
    font-weight: 500;
    color: var(--ai-text-dark);
}

.customer-email {
    font-size: 13px;
    color: var(--ai-text-muted);
}

/* Items Count */
.items-count {
    font-weight: 500;
}

/* Order Total */
.order-total {
    font-weight: 600;
    color: var(--ai-text-dark);
}

/* Status Badge */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 500;
}

.status-badge--pending {
    background: var(--ai-orange-light);
    color: var(--ai-orange);
}

.status-badge--preparing {
    background: var(--ai-blue-light);
    color: var(--ai-blue);
}

.status-badge--ready {
    background: var(--ai-purple-light);
    color: var(--ai-purple);
}

.status-badge--shipped {
    background: #DBEAFE;
    color: #1D4ED8;
}

.status-badge--delivered {
    background: var(--ai-green-light);
    color: var(--ai-green);
}

.status-badge--cancelled {
    background: #FEE2E2;
    color: #DC2626;
}

.status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
}

/* Payment Badge */
.payment-badge {
    display: inline-flex;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
}

.payment-badge--paid {
    background: var(--ai-green-light);
    color: var(--ai-green);
}

.payment-badge--pending {
    background: var(--ai-orange-light);
    color: var(--ai-orange);
}

.payment-badge--refunded {
    background: #FEE2E2;
    color: #DC2626;
}

.payment-badge--failed {
    background: #FEE2E2;
    color: #DC2626;
}

/* Date Cell */
.order-date {
    font-size: 13px;
    color: var(--ai-text-muted);
}

.order-time {
    font-size: 12px;
    color: var(--ai-text-muted);
}

/* Actions */
.order-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

.action-btn {
    padding: 6px;
    background: transparent;
    border: 1px solid var(--ai-border);
    border-radius: 6px;
    cursor: pointer;
    color: var(--ai-text-muted);
    transition: all 0.15s ease;
}

.action-btn:hover {
    background: var(--ai-bg-main);
    color: var(--ai-text-dark);
}

/* Empty State */
.orders-empty-state {
    padding: 64px 24px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

.orders-empty-state svg {
    color: var(--ai-text-muted);
    opacity: 0.5;
}

.orders-empty-state h3 {
    font-size: 18px;
    font-weight: 600;
    color: var(--ai-text-dark);
    margin: 0;
}

.orders-empty-state p {
    font-size: 14px;
    color: var(--ai-text-muted);
    margin: 0;
}

/* Loading State */
.orders-loading {
    padding: 64px 24px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

.orders-loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--ai-border);
    border-top-color: var(--ai-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.orders-loading p {
    font-size: 14px;
    color: var(--ai-text-muted);
    margin: 0;
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: var(--ai-bg-white);
    border-radius: 16px;
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    transform: scale(0.95);
    transition: transform 0.2s ease;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
}

.modal-large {
    max-width: 700px;
}

.modal-overlay.active .modal {
    transform: scale(1);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid var(--ai-border);
}

.modal-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--ai-text-dark);
    margin: 0;
}

.modal-close {
    padding: 8px;
    background: transparent;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    color: var(--ai-text-muted);
    transition: all 0.15s ease;
}

.modal-close:hover {
    background: var(--ai-bg-main);
    color: var(--ai-text-dark);
}

.modal-body {
    padding: 24px;
    overflow-y: auto;
    flex: 1;
}

.modal-footer {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 24px;
    border-top: 1px solid var(--ai-border);
}

.modal-footer .btn-secondary {
    margin-right: auto;
}

/* Order Detail */
.order-detail {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.order-detail-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--ai-border);
}

.order-detail-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.order-detail-number {
    font-size: 20px;
    font-weight: 600;
    color: var(--ai-text-dark);
    font-family: 'SF Mono', SFMono-Regular, Consolas, monospace;
}

.order-detail-date {
    font-size: 14px;
    color: var(--ai-text-muted);
}

.order-detail-badges {
    display: flex;
    gap: 8px;
}

.order-detail-section {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.order-detail-section h4 {
    font-size: 14px;
    font-weight: 600;
    color: var(--ai-text-dark);
    margin: 0;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Customer Info */
.customer-info {
    background: var(--ai-bg-main);
    border-radius: 8px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.customer-row {
    display: flex;
    gap: 12px;
}

.customer-label {
    font-size: 14px;
    color: var(--ai-text-muted);
    min-width: 60px;
}

.customer-value {
    font-size: 14px;
    color: var(--ai-text-dark);
}

/* Order Items */
.order-items {
    background: var(--ai-bg-main);
    border-radius: 8px;
    overflow: hidden;
}

.order-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid var(--ai-border);
}

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

.order-item-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.order-item-name {
    font-size: 14px;
    font-weight: 500;
    color: var(--ai-text-dark);
}

.order-item-sku {
    font-size: 12px;
    color: var(--ai-text-muted);
    font-family: 'SF Mono', SFMono-Regular, Consolas, monospace;
}

.order-item-qty {
    font-size: 14px;
    color: var(--ai-text-muted);
}

.order-item-price {
    font-size: 14px;
    font-weight: 500;
    color: var(--ai-text-dark);
}

/* Order Totals */
.order-totals {
    background: var(--ai-bg-main);
    border-radius: 8px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.order-total-row {
    display: flex;
    justify-content: space-between;
    font-size: 14px;
    color: var(--ai-text-medium);
}

.order-total-row--grand {
    padding-top: 12px;
    margin-top: 8px;
    border-top: 1px solid var(--ai-border);
    font-size: 16px;
    font-weight: 600;
    color: var(--ai-text-dark);
}

/* Fulfillment Info */
.fulfillment-info {
    background: var(--ai-bg-main);
    border-radius: 8px;
    padding: 16px;
}

.fulfillment-type {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 500;
    color: var(--ai-text-dark);
    margin-bottom: 8px;
}

.fulfillment-address {
    font-size: 14px;
    color: var(--ai-text-medium);
    line-height: 1.5;
}

/* Status Update */
.status-update {
    display: flex;
    gap: 12px;
    align-items: center;
}

.status-update select {
    flex: 1;
}

/* Responsive */
@media (max-width: 1200px) {
    .orders-stats {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .orders-page {
        padding: 16px;
    }

    .orders-header {
        flex-direction: column;
        gap: 16px;
    }

    .orders-stats {
        grid-template-columns: 1fr;
    }

    .orders-toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .orders-filters {
        flex-wrap: wrap;
    }

    .orders-search {
        max-width: none;
    }

    .orders-table-container {
        overflow-x: auto;
    }

    .modal {
        margin: 16px;
        max-height: calc(100vh - 32px);
    }
}
