/**
 * Pancake-Style Global CSS
 * ========================
 * Extracted from don-hang.html for ERP-wide styling
 */

/* ==============================================
   CSS Variables - Pancake Theme Colors
   ============================================== */
:root {
    --pancake-primary: #1a56db;
    --pancake-dark: #1e2837;
    --pancake-header: #1e3a5f;
    --pancake-border: #e5e7eb;
    --pancake-hover: #f9fafb;
    --pancake-success: #22c55e;
    --pancake-warning: #f59e0b;
    --pancake-danger: #ef4444;
    --pancake-info: #3b82f6;
}

* {
    box-sizing: border-box;
}

/* ==============================================
   Page Layouts
   ============================================== */
.orders-page {
    background: #f3f4f6;
    min-height: 100vh;
}

.orders-page .page-content {
    padding: 0 !important;
}

/* ==============================================
   Top Action Bar
   ============================================== */
.top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    background: white;
    border-bottom: 1px solid var(--pancake-border);
}

.tab-group {
    display: flex;
    gap: 4px;
}

.tab-btn {
    padding: 6px 14px;
    border: 1px solid var(--pancake-border);
    border-radius: 6px;
    background: white;
    font-size: 13px;
    font-weight: 500;
    color: #374151;
    cursor: pointer;
    transition: all 0.15s;
}

.tab-btn:hover {
    background: #f9fafb;
}

.tab-btn.active {
    background: var(--pancake-primary);
    color: white;
    border-color: var(--pancake-primary);
}

.action-btns-top {
    display: flex;
    gap: 8px;
}

.btn-action {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    border: 1px solid var(--pancake-border);
    border-radius: 6px;
    background: white;
    font-size: 12px;
    font-weight: 500;
    color: #374151;
    cursor: pointer;
    transition: all 0.15s;
}

.btn-action:hover {
    background: #f9fafb;
}

.btn-action.primary {
    background: var(--pancake-primary);
    color: white;
    border-color: var(--pancake-primary);
}

.btn-action.primary:hover {
    background: #1e40af;
}

/* ==============================================
   Filter Row
   ============================================== */
.filter-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: white;
    border-bottom: 1px solid var(--pancake-border);
    flex-wrap: wrap;
}

.filter-tabs {
    display: flex;
    gap: 4px;
}

.filter-tab {
    padding: 5px 12px;
    font-size: 12px;
    color: #6b7280;
    background: transparent;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.15s;
}

.filter-tab:hover {
    background: #f3f4f6;
}

.filter-tab.active {
    background: #e0e7ff;
    color: var(--pancake-primary);
    font-weight: 500;
}

/* ==============================================
   Status Pills Row
   ============================================== */
.status-row {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    background: white;
    border-bottom: 1px solid var(--pancake-border);
    overflow-x: auto;
}

.status-pill {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 10px;
    border-radius: 16px;
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.15s;
}

.status-pill:hover {
    opacity: 0.85;
    transform: translateY(-1px);
}

.status-pill.active {
    box-shadow: 0 0 0 2px var(--pancake-primary), 0 2px 8px rgba(26, 86, 219, 0.2);
    transform: translateY(-1px);
}

.status-pill.all {
    background: #e5e7eb;
    color: #374151;
}

.status-pill.new {
    background: #dbeafe;
    color: #1d4ed8;
}

.status-pill.waiting {
    background: #fef3c7;
    color: #b45309;
}

.status-pill.confirmed {
    background: #dcfce7;
    color: #15803d;
}

.status-pill.packing {
    background: #e0e7ff;
    color: #4338ca;
}

.status-pill.shipping {
    background: #fce7f3;
    color: #be185d;
}

.status-pill.delivered {
    background: #d1fae5;
    color: #047857;
}

.status-pill.sent {
    background: #ccfbf1;
    color: #0d9488;
}

.status-pill.paid {
    background: #c7d2fe;
    color: #4338ca;
}

.status-pill.returning {
    background: #fef08a;
    color: #a16207;
}

.status-pill.exchanging {
    background: #fbcfe8;
    color: #be185d;
}

.status-pill.partial-return {
    background: #fed7aa;
    color: #c2410c;
}

.status-pill.returned {
    background: #fecaca;
    color: #dc2626;
}

.status-pill.cancelled {
    background: #e5e7eb;
    color: #6b7280;
}

.status-pill .count {
    background: rgba(0, 0, 0, 0.1);
    padding: 1px 6px;
    border-radius: 10px;
    font-size: 11px;
}

/* ==============================================
   Table Styles
   ============================================== */
.table-wrapper {
    background: white;
    overflow: hidden;
}

.table-scroll {
    overflow-x: auto;
    max-height: calc(100vh - 280px);
}

.orders-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
    min-width: 1200px;
}

.orders-table thead {
    background: linear-gradient(180deg, #1e3a5f 0%, #152a45 100%);
    color: white;
    position: sticky;
    top: 0;
    z-index: 10;
}

.orders-table th {
    padding: 10px 8px;
    text-align: left;
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    white-space: nowrap;
    border-right: 1px solid rgba(255, 255, 255, 0.1);
}

.orders-table th:last-child {
    border-right: none;
}

.orders-table tbody tr {
    border-bottom: 1px solid #f3f4f6;
    transition: background 0.1s;
}

.orders-table tbody tr:hover {
    background: #f9fafb;
}

.orders-table tbody tr:nth-child(even) {
    background: #fafbfc;
}

.orders-table tbody tr:nth-child(even):hover {
    background: #f3f4f6;
}

.orders-table td {
    padding: 8px;
    vertical-align: middle;
    border-right: 1px solid #f3f4f6;
}

.orders-table td:last-child {
    border-right: none;
}

/* ==============================================
   Checkbox Cell
   ============================================== */
.checkbox-cell {
    width: 32px;
    text-align: center;
}

.checkbox-cell input {
    width: 16px;
    height: 16px;
    cursor: pointer;
}

/* ==============================================
   Order ID Cell
   ============================================== */
.order-id-cell {
    min-width: 140px;
}

.order-id {
    color: var(--pancake-primary);
    font-weight: 600;
    cursor: pointer;
    font-size: 12px;
}

.order-id:hover {
    text-decoration: underline;
}

/* ==============================================
   VC Badge (Carrier/Source)
   ============================================== */
.vc-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 600;
}

.vc-badge.pancake {
    background: #fef3c7;
    color: #92400e;
}

.vc-badge.woo {
    background: #dbeafe;
    color: #1e40af;
}

.vc-badge.manual {
    background: #e5e7eb;
    color: #374151;
}

.vc-badge.viettel {
    background: #fee2e2;
    color: #991b1b;
}

.vc-badge.ghn {
    background: #fef3c7;
    color: #92400e;
}

.vc-badge.ghtk {
    background: #dcfce7;
    color: #166534;
}

.vc-badge.jt {
    background: #dbeafe;
    color: #1e40af;
}

.vc-badge.best {
    background: #f3e8ff;
    color: #7c3aed;
}

.vc-badge.default {
    background: #f3f4f6;
    color: #374151;
}

.vc-badge.vnpost {
    background: #fef3c7;
    color: #b45309;
}

.vc-badge.ninja {
    background: #fee2e2;
    color: #dc2626;
}

.vc-badge.snappy {
    background: #e0f2fe;
    color: #0369a1;
}

.vc-badge.ahamove {
    background: #fce7f3;
    color: #be185d;
}

.vc-badge.grab {
    background: #dcfce7;
    color: #15803d;
}

/* ==============================================
   Source Badge (Order Source)
   ============================================== */
.source-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
}

.source-badge.shopee {
    background: #fff7ed;
    color: #ea580c;
}

.source-badge.facebook {
    background: #dbeafe;
    color: #1d4ed8;
}

.source-badge.lazada {
    background: #ede9fe;
    color: #7c3aed;
}

.source-badge.tiktok {
    background: #f3f4f6;
    color: #374151;
}

.source-badge.tiki {
    background: #e0f2fe;
    color: #0369a1;
}

.source-badge.sendo {
    background: #fee2e2;
    color: #dc2626;
}

.source-badge.shopify {
    background: #dcfce7;
    color: #16a34a;
}

.source-badge.woo {
    background: #f3e8ff;
    color: #9333ea;
}

.source-badge.default {
    background: #f3f4f6;
    color: #4b5563;
}

/* ==============================================
   Tag Badge
   ============================================== */
.tag-badge {
    display: inline-flex;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 500;
    background: #fee2e2;
    color: #dc2626;
}

/* ==============================================
   Customer Cell
   ============================================== */
.customer-cell {
    max-width: 120px;
}

.customer-name {
    font-weight: 500;
    color: #1f2937;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.customer-phone {
    font-size: 11px;
    color: #6b7280;
}

/* ==============================================
   Carrier Badge
   ============================================== */
.carrier-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 10px;
    background: #f3f4f6;
}

.carrier-badge.viettel {
    background: #fee2e2;
    color: #991b1b;
}

.carrier-badge.ghn {
    background: #fef3c7;
    color: #92400e;
}

.carrier-badge.ghtk {
    background: #dcfce7;
    color: #166534;
}

/* ==============================================
   Shipping Cell
   ============================================== */
.shipping-cell {
    max-width: 140px;
}

.shipping-text {
    font-size: 11px;
    color: #6b7280;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
    cursor: help;
}

.shipping-text:hover {
    color: #374151;
}

/* ==============================================
   Product Cell & Tooltip
   ============================================== */
.product-cell {
    max-width: 180px;
    position: relative;
}

.product-text {
    position: relative;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 11px;
    color: #374151;
    display: block;
    max-width: 150px;
}

.product-text.multi-product {
    color: #2563eb;
    font-weight: 500;
    cursor: help;
}

.product-cell:hover .product-tooltip {
    display: block;
}

.product-tooltip {
    display: none;
    position: fixed;
    background: #1e293b;
    color: #f8fafc;
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 12px;
    line-height: 1.6;
    white-space: normal;
    max-width: 350px;
    min-width: 220px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
    z-index: 99999;
}

.product-tooltip .tooltip-item {
    padding: 5px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.15);
}

.product-tooltip .tooltip-item:last-child {
    border-bottom: none;
}

/* ==============================================
   Amount Cell
   ============================================== */
.amount-cell {
    text-align: right;
    font-weight: 600;
    color: #1f2937;
    white-space: nowrap;
}

/* ==============================================
   Date Cell
   ============================================== */
.date-cell {
    font-size: 11px;
    color: #6b7280;
    white-space: nowrap;
}

/* ==============================================
   Status Badge
   ============================================== */
.status-cell {
    min-width: 120px;
}

.status-badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
}

/* New orders - Blue */
.status-badge.new {
    background: #dbeafe;
    color: #1e40af;
}

/* Pending/Waiting - Yellow/Amber */
.status-badge.pending {
    background: #fef3c7;
    color: #b45309;
}

/* Confirmed - Light Green */
.status-badge.confirmed {
    background: #dcfce7;
    color: #15803d;
}

/* Processing/Packing - Indigo */
.status-badge.processing,
.status-badge.packing,
.status-badge.packaging {
    background: #e0e7ff;
    color: #4338ca;
}

/* Shipping - Pink */
.status-badge.shipping {
    background: #fce7f3;
    color: #be185d;
}

/* Sent - Cyan */
.status-badge.sent {
    background: #ccfbf1;
    color: #0d9488;
}

/* Delivered/Completed - Green */
.status-badge.delivered,
.status-badge.completed {
    background: #d1fae5;
    color: #047857;
}

/* Paid (Đã thu tiền) - Light Purple (same as status-pill.paid) */
.status-badge.paid {
    background: #c7d2fe;
    color: #4338ca;
}

/* Returning - Yellow */
.status-badge.returning {
    background: #fef08a;
    color: #a16207;
}

/* Exchanging - Light Pink */
.status-badge.exchanging {
    background: #fbcfe8;
    color: #be185d;
}

/* Partial Return - Orange */
.status-badge.partial_return {
    background: #fed7aa;
    color: #c2410c;
}

/* Returned/Refunded - Red */
.status-badge.returned,
.status-badge.refunded {
    background: #fecaca;
    color: #dc2626;
}

/* Cancelled - Gray */
.status-badge.cancelled {
    background: #e5e7eb;
    color: #6b7280;
}

/* ==============================================
   Table Footer
   ============================================== */
.table-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    background: #f9fafb;
    border-top: 1px solid var(--pancake-border);
    font-size: 12px;
}

.footer-stats {
    display: flex;
    gap: 20px;
}

.footer-stat {
    display: flex;
    align-items: center;
    gap: 6px;
}

.footer-stat .label {
    color: #6b7280;
}

.footer-stat .value {
    font-weight: 600;
    color: #1f2937;
}

.footer-stat .value.highlight {
    color: var(--pancake-primary);
}

/* ==============================================
   Pagination
   ============================================== */
.pagination {
    display: flex;
    align-items: center;
    gap: 8px;
}

.page-btn {
    min-width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--pancake-border);
    border-radius: 4px;
    background: white;
    font-size: 12px;
    color: #374151;
    cursor: pointer;
    transition: all 0.15s;
}

.page-btn:hover:not(:disabled) {
    background: #f3f4f6;
}

.page-btn.active {
    background: var(--pancake-primary);
    border-color: var(--pancake-primary);
    color: white;
}

.page-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.page-info {
    font-size: 12px;
    color: #6b7280;
}

.per-page {
    display: flex;
    align-items: center;
    gap: 6px;
}

.per-page select {
    padding: 4px 8px;
    border: 1px solid var(--pancake-border);
    border-radius: 4px;
    font-size: 12px;
}

/* ==============================================
   Loading States
   ============================================== */
.loading-row td {
    text-align: center;
    padding: 40px 20px;
    color: #6b7280;
}

.loading-spinner {
    width: 28px;
    height: 28px;
    border: 3px solid #e5e7eb;
    border-top-color: var(--pancake-primary);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    margin: 0 auto 10px;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ==============================================
   Empty/Error States
   ============================================== */
.empty-row td,
.error-row td {
    text-align: center;
    padding: 50px 20px;
    color: #9ca3af;
}

.retry-btn {
    margin-top: 12px;
    padding: 8px 20px;
    background: var(--pancake-primary);
    color: white;
    border: none;
    border-radius: 6px;
    font-weight: 500;
    cursor: pointer;
}

.retry-btn:hover {
    background: #1e40af;
}

/* ==============================================
   Actions Cell
   ============================================== */
.action-cell {
    text-align: center;
}

.action-dropdown {
    position: relative;
    display: inline-block;
}

.action-trigger {
    padding: 4px 8px;
    background: transparent;
    border: none;
    cursor: pointer;
    color: #6b7280;
    font-size: 14px;
}

.action-trigger:hover {
    color: #374151;
}

/* ==============================================
   Responsive Adjustments
   ============================================== */
@media (max-width: 1400px) {
    .orders-table {
        font-size: 11px;
    }

    .orders-table th,
    .orders-table td {
        padding: 6px;
    }
}

/* ==============================================
   Data Table Styles (For consistency with Orders Table)
   Applied to pages: nhan-su, thu-chi, dai-ly, etc.
   ============================================== */
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.data-table thead {
    background: linear-gradient(180deg, #1e3a5f 0%, #152a45 100%) !important;
    color: white !important;
    position: sticky;
    top: 0;
    z-index: 10;
}

.data-table th {
    padding: 12px 10px !important;
    text-align: left;
    font-weight: 600;
    font-size: 12px !important;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    white-space: nowrap;
    border-right: 1px solid rgba(255, 255, 255, 0.1) !important;
    background: transparent !important;
    color: white !important;
}

.data-table th:last-child {
    border-right: none !important;
}

.data-table tbody tr {
    border-bottom: 1px solid #f3f4f6;
    transition: background 0.1s;
}

.data-table tbody tr:hover {
    background: #f0f9ff;
}

.data-table tbody tr:nth-child(even) {
    background: #fafbfc;
}

.data-table tbody tr:nth-child(even):hover {
    background: #f0f9ff;
}

.data-table td {
    padding: 10px;
    vertical-align: middle;
    border-right: 1px solid #f3f4f6;
}

.data-table td:last-child {
    border-right: none;
}

/* Data Table Input Styling */
.data-table input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: var(--pancake-primary);
}

/* ==============================================
   Standard Pagination Styles
   ============================================== */
.table-footer {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    padding: 10px 12px;
    background: #f9fafb;
    border-top: 1px solid var(--pancake-border);
}

.pagination {
    display: flex;
    gap: 8px;
    align-items: center;
    justify-content: space-between;
    flex: 1;
}

.page-info {
    font-size: 12px;
    color: #6b7280;
}

.page-btn {
    width: 28px;
    height: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #e5e7eb;
    border-radius: 4px;
    background: white;
    font-size: 12px;
    color: #374151;
    cursor: pointer;
    transition: all 0.15s ease;
}

.page-btn:hover:not(:disabled):not(.active) {
    background: #f3f4f6;
    border-color: #d1d5db;
}

.page-btn.active {
    background: var(--pancake-primary);
    border-color: var(--pancake-primary);
    color: white;
}

.page-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.per-page {
    display: flex;
    align-items: center;
    gap: 4px;
}

.per-page select {
    padding: 4px 8px;
    border: 1px solid #e5e7eb;
    border-radius: 4px;
    font-size: 12px;
    background: white;
    color: #374151;
    cursor: pointer;
}

.per-page span {
    color: #6b7280;
    font-size: 12px;
}