/* =========================================================
   WONDER APP - VENDOR APPLICATION
   TABLES.CSS
   Reusable tables, responsive tables, status badges,
   pagination helpers and table actions
   ========================================================= */

/* =========================================================
   1. TABLE WRAPPER
   ========================================================= */

.table-wrapper {
    width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    border: 1px solid var(--border-color, #e5e7eb);
    border-radius: 12px;
    background: var(--card-bg, #ffffff);
}

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

.table-responsive::-webkit-scrollbar,
.table-wrapper::-webkit-scrollbar {
    height: 7px;
}

.table-responsive::-webkit-scrollbar-track,
.table-wrapper::-webkit-scrollbar-track {
    background: #f3f4f6;
}

.table-responsive::-webkit-scrollbar-thumb,
.table-wrapper::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 20px;
}

.table-responsive::-webkit-scrollbar-thumb:hover,
.table-wrapper::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}


/* =========================================================
   2. BASE TABLE
   ========================================================= */

.table {
    width: 100%;
    min-width: 720px;
    border-collapse: collapse;
    border-spacing: 0;
    color: var(--text-color, #111827);
    background: var(--card-bg, #ffffff);
    font-size: 14px;
    line-height: 1.5;
}

.table th,
.table td {
    padding: 14px 16px;
    text-align: left;
    vertical-align: middle;
    border-bottom: 1px solid var(--border-color, #e5e7eb);
}

.table th {
    font-weight: 600;
    color: var(--muted-text, #475569);
    background: var(--table-header-bg, #f8fafc);
    white-space: nowrap;
}

.table td {
    color: var(--text-color, #1f2937);
}

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


/* =========================================================
   3. TABLE HOVER
   ========================================================= */

.table-hover tbody tr {
    transition:
        background-color 0.15s ease,
        box-shadow 0.15s ease;
}

.table-hover tbody tr:hover {
    background: var(--table-hover-bg, #f8fafc);
}


/* =========================================================
   4. STRIPED TABLE
   ========================================================= */

.table-striped tbody tr:nth-child(even) {
    background: #fafafa;
}

.table-striped.table-hover tbody tr:hover {
    background: #f1f5f9;
}


/* =========================================================
   5. BORDERED TABLE
   ========================================================= */

.table-bordered {
    border: 1px solid var(--border-color, #e5e7eb);
}

.table-bordered th,
.table-bordered td {
    border: 1px solid var(--border-color, #e5e7eb);
}


/* =========================================================
   6. COMPACT TABLE
   ========================================================= */

.table-compact th,
.table-compact td {
    padding: 9px 12px;
}


/* =========================================================
   7. LARGE TABLE
   ========================================================= */

.table-large th,
.table-large td {
    padding: 18px 20px;
}


/* =========================================================
   8. TABLE CARD
   ========================================================= */

.table-card {
    width: 100%;
    background: var(--card-bg, #ffffff);
    border: 1px solid var(--border-color, #e5e7eb);
    border-radius: 14px;
    overflow: hidden;
}

.table-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 18px 20px;
    border-bottom: 1px solid var(--border-color, #e5e7eb);
}

.table-card-title {
    margin: 0;
    font-size: 17px;
    font-weight: 700;
    color: var(--text-color, #111827);
}

.table-card-subtitle {
    margin: 4px 0 0;
    color: var(--muted-text, #64748b);
    font-size: 13px;
}

.table-card-body {
    width: 100%;
}

.table-card-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
    padding: 14px 20px;
    border-top: 1px solid var(--border-color, #e5e7eb);
}


/* =========================================================
   9. TABLE TOOLBAR
   ========================================================= */

.table-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 16px;
}

.table-toolbar-left,
.table-toolbar-right {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.table-toolbar-title {
    margin: 0;
    font-size: 18px;
    font-weight: 700;
}

.table-toolbar-description {
    margin: 3px 0 0;
    font-size: 13px;
    color: var(--muted-text, #64748b);
}


/* =========================================================
   10. TABLE SEARCH
   ========================================================= */

.table-search {
    position: relative;
    width: 260px;
    max-width: 100%;
}

.table-search input {
    width: 100%;
    height: 40px;
    padding: 0 13px 0 38px;
    border: 1px solid var(--border-color, #d1d5db);
    border-radius: 8px;
    background: #ffffff;
    color: #111827;
    font-size: 14px;
    outline: none;
    transition:
        border-color 0.15s ease,
        box-shadow 0.15s ease;
}

.table-search input:focus {
    border-color: var(--primary-color, #2563eb);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.10);
}

.table-search-icon {
    position: absolute;
    top: 50%;
    left: 13px;
    transform: translateY(-50%);
    color: #64748b;
    pointer-events: none;
}


/* =========================================================
   11. TABLE FILTERS
   ========================================================= */

.table-filters {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.table-filter {
    min-width: 130px;
    height: 40px;
    padding: 0 12px;
    border: 1px solid var(--border-color, #d1d5db);
    border-radius: 8px;
    background: #ffffff;
    color: #334155;
    font-size: 14px;
    outline: none;
    cursor: pointer;
}

.table-filter:focus {
    border-color: var(--primary-color, #2563eb);
}


/* =========================================================
   12. CHECKBOX / SELECT COLUMN
   ========================================================= */

.table-select {
    width: 18px;
    height: 18px;
    margin: 0;
    cursor: pointer;
    accent-color: var(--primary-color, #2563eb);
}

.table-select-cell {
    width: 45px;
    text-align: center !important;
}

.table-select-all {
    width: 18px;
    height: 18px;
    cursor: pointer;
}


/* =========================================================
   13. TABLE ID / REFERENCE
   ========================================================= */

.table-id {
    font-weight: 600;
    color: var(--primary-color, #2563eb);
    white-space: nowrap;
}

.table-reference {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco,
        Consolas, "Liberation Mono", monospace;
    font-size: 12px;
    color: #64748b;
}


/* =========================================================
   14. CUSTOMER / USER CELL
   ========================================================= */

.table-user {
    display: flex;
    align-items: center;
    gap: 11px;
    min-width: 180px;
}

.table-user-avatar {
    width: 38px;
    height: 38px;
    flex: 0 0 38px;
    border-radius: 50%;
    object-fit: cover;
    background: #e2e8f0;
}

.table-user-info {
    min-width: 0;
}

.table-user-name {
    margin: 0;
    font-weight: 600;
    color: #111827;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.table-user-meta {
    margin-top: 2px;
    color: #64748b;
    font-size: 12px;
    white-space: nowrap;
}


/* =========================================================
   15. BUSINESS CELL
   ========================================================= */

.table-business {
    display: flex;
    align-items: center;
    gap: 10px;
}

.table-business-logo {
    width: 38px;
    height: 38px;
    border-radius: 8px;
    object-fit: cover;
    background: #f1f5f9;
}

.table-business-name {
    font-weight: 600;
    color: #111827;
}


/* =========================================================
   16. DESCRIPTION CELL
   ========================================================= */

.table-description {
    max-width: 320px;
    color: #64748b;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.table-description-wrap {
    max-width: 350px;
    white-space: normal;
    word-break: break-word;
}


/* =========================================================
   17. MONEY / PRICE
   ========================================================= */

.table-amount {
    font-weight: 700;
    color: #111827;
    white-space: nowrap;
}

.table-amount-positive {
    color: #15803d;
}

.table-amount-negative {
    color: #dc2626;
}

.table-amount-muted {
    color: #64748b;
    font-weight: 500;
}


/* =========================================================
   18. STATUS BADGES
   ========================================================= */

.table-status {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 26px;
    padding: 4px 9px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    line-height: 1.2;
    white-space: nowrap;
}

.table-status::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
}


/* Success */

.table-status-success,
.table-status-active,
.table-status-completed,
.table-status-accepted,
.table-status-confirmed,
.table-status-paid {
    color: #166534;
    background: #dcfce7;
}


/* Warning */

.table-status-warning,
.table-status-pending,
.table-status-processing,
.table-status-in-progress {
    color: #92400e;
    background: #fef3c7;
}


/* Danger */

.table-status-danger,
.table-status-cancelled,
.table-status-rejected,
.table-status-failed,
.table-status-refunded {
    color: #991b1b;
    background: #fee2e2;
}


/* Info */

.table-status-info,
.table-status-new,
.table-status-assigned,
.table-status-responded,
.table-status-sent {
    color: #1e40af;
    background: #dbeafe;
}


/* Neutral */

.table-status-neutral,
.table-status-draft,
.table-status-closed,
.table-status-expired,
.table-status-inactive {
    color: #475569;
    background: #e2e8f0;
}


/* =========================================================
   19. PRIORITY
   ========================================================= */

.table-priority {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 600;
}

.table-priority-high {
    color: #dc2626;
}

.table-priority-medium {
    color: #d97706;
}

.table-priority-low {
    color: #16a34a;
}


/* =========================================================
   20. ACTIONS
   ========================================================= */

.table-actions {
    display: inline-flex;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
    white-space: nowrap;
}

.table-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    padding: 0;
    border: 1px solid transparent;
    border-radius: 7px;
    background: transparent;
    color: #64748b;
    cursor: pointer;
    text-decoration: none;
    transition:
        color 0.15s ease,
        background-color 0.15s ease,
        border-color 0.15s ease;
}

.table-action:hover {
    color: var(--primary-color, #2563eb);
    background: #eff6ff;
}

.table-action-view:hover {
    color: #2563eb;
    background: #eff6ff;
}

.table-action-edit:hover {
    color: #7c3aed;
    background: #f5f3ff;
}

.table-action-delete:hover {
    color: #dc2626;
    background: #fef2f2;
}

.table-action-success:hover {
    color: #16a34a;
    background: #f0fdf4;
}

.table-action:disabled,
.table-action.disabled {
    opacity: 0.45;
    cursor: not-allowed;
}


/* =========================================================
   21. ACTION DROPDOWN
   ========================================================= */

.table-action-menu {
    position: relative;
}

.table-action-menu-button {
    width: 34px;
    height: 34px;
    border: 1px solid var(--border-color, #e5e7eb);
    border-radius: 7px;
    background: #ffffff;
    color: #475569;
    cursor: pointer;
}

.table-action-menu-button:hover {
    background: #f8fafc;
    color: #111827;
}

.table-action-dropdown {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    z-index: 100;
    min-width: 170px;
    padding: 6px;
    border: 1px solid var(--border-color, #e5e7eb);
    border-radius: 9px;
    background: #ffffff;
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.12);
    display: none;
}

.table-action-dropdown.is-open {
    display: block;
}

.table-action-dropdown a,
.table-action-dropdown button {
    display: flex;
    align-items: center;
    width: 100%;
    gap: 9px;
    padding: 9px 10px;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: #334155;
    font-size: 13px;
    text-align: left;
    text-decoration: none;
    cursor: pointer;
}

.table-action-dropdown a:hover,
.table-action-dropdown button:hover {
    background: #f8fafc;
}

.table-action-dropdown .danger {
    color: #dc2626;
}


/* =========================================================
   22. SORTABLE COLUMNS
   ========================================================= */

.table-sortable {
    cursor: pointer;
    user-select: none;
}

.table-sortable:hover {
    color: var(--primary-color, #2563eb);
}

.table-sort {
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.table-sort-icon {
    font-size: 11px;
    color: #94a3b8;
}

.table-sortable.is-active .table-sort-icon {
    color: var(--primary-color, #2563eb);
}


/* =========================================================
   23. EMPTY STATE
   ========================================================= */

.table-empty {
    padding: 55px 20px !important;
    text-align: center !important;
    color: #64748b;
}

.table-empty-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    margin: 0 auto 12px;
    border-radius: 50%;
    background: #f1f5f9;
    color: #64748b;
    font-size: 24px;
}

.table-empty-title {
    margin: 0 0 5px;
    color: #334155;
    font-size: 15px;
    font-weight: 700;
}

.table-empty-text {
    margin: 0;
    color: #64748b;
    font-size: 13px;
}


/* =========================================================
   24. LOADING STATE
   ========================================================= */

.table-loading {
    position: relative;
    min-height: 160px;
}

.table-loading-overlay {
    position: absolute;
    inset: 0;
    z-index: 5;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.78);
}

.table-spinner {
    width: 30px;
    height: 30px;
    border: 3px solid #e2e8f0;
    border-top-color: var(--primary-color, #2563eb);
    border-radius: 50%;
    animation: table-spin 0.8s linear infinite;
}

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


/* =========================================================
   25. SKELETON ROWS
   ========================================================= */

.table-skeleton {
    position: relative;
    overflow: hidden;
    height: 14px;
    border-radius: 5px;
    background: #e2e8f0;
}

.table-skeleton::after {
    content: "";
    position: absolute;
    inset: 0;
    transform: translateX(-100%);
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.65),
        transparent
    );
    animation: table-skeleton 1.4s infinite;
}

@keyframes table-skeleton {
    100% {
        transform: translateX(100%);
    }
}


/* =========================================================
   26. TABLE PAGINATION
   ========================================================= */

.table-pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    padding: 14px 16px;
    border-top: 1px solid var(--border-color, #e5e7eb);
}

.table-pagination-info {
    color: #64748b;
    font-size: 13px;
}

.table-pagination-controls {
    display: flex;
    align-items: center;
    gap: 5px;
}

.table-page {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 34px;
    height: 34px;
    padding: 0 8px;
    border: 1px solid var(--border-color, #d1d5db);
    border-radius: 7px;
    background: #ffffff;
    color: #475569;
    font-size: 13px;
    text-decoration: none;
    cursor: pointer;
    transition: 0.15s ease;
}

.table-page:hover {
    background: #f8fafc;
    color: var(--primary-color, #2563eb);
}

.table-page.active {
    border-color: var(--primary-color, #2563eb);
    background: var(--primary-color, #2563eb);
    color: #ffffff;
}

.table-page.disabled,
.table-page:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}


/* =========================================================
   27. TABLE RESULTS COUNT
   ========================================================= */

.table-results {
    color: #64748b;
    font-size: 13px;
}

.table-results strong {
    color: #334155;
}


/* =========================================================
   28. MOBILE CARD TABLE
   ========================================================= */

.table-mobile-cards {
    display: none;
}


/* =========================================================
   29. ALIGNMENT HELPERS
   ========================================================= */

.table .text-left {
    text-align: left;
}

.table .text-center {
    text-align: center;
}

.table .text-right {
    text-align: right;
}

.table .nowrap {
    white-space: nowrap;
}


/* =========================================================
   30. COLUMN WIDTH HELPERS
   ========================================================= */

.table-col-xs {
    width: 60px;
}

.table-col-sm {
    width: 100px;
}

.table-col-md {
    width: 160px;
}

.table-col-lg {
    width: 240px;
}

.table-col-xl {
    width: 320px;
}


/* =========================================================
   31. DATE / TIME
   ========================================================= */

.table-date {
    color: #334155;
    font-size: 13px;
    white-space: nowrap;
}

.table-time {
    display: block;
    margin-top: 2px;
    color: #94a3b8;
    font-size: 12px;
}


/* =========================================================
   32. RATING
   ========================================================= */

.table-rating {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
}

.table-rating-stars {
    letter-spacing: 1px;
}

.table-rating-value {
    color: #334155;
    font-weight: 600;
    font-size: 13px;
}


/* =========================================================
   33. PROGRESS
   ========================================================= */

.table-progress {
    width: 120px;
    max-width: 100%;
}

.table-progress-track {
    width: 100%;
    height: 7px;
    overflow: hidden;
    border-radius: 999px;
    background: #e2e8f0;
}

.table-progress-bar {
    height: 100%;
    border-radius: inherit;
    background: var(--primary-color, #2563eb);
    transition: width 0.3s ease;
}

.table-progress-text {
    display: block;
    margin-top: 4px;
    color: #64748b;
    font-size: 11px;
}


/* =========================================================
   34. INVENTORY
   ========================================================= */

.table-stock {
    font-weight: 600;
    white-space: nowrap;
}

.table-stock-in {
    color: #15803d;
}

.table-stock-low {
    color: #d97706;
}

.table-stock-out {
    color: #dc2626;
}


/* =========================================================
   35. ICON CELL
   ========================================================= */

.table-icon-cell {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: #f1f5f9;
    color: #475569;
}


/* =========================================================
   36. LEAD / ENQUIRY SOURCE
   ========================================================= */

.table-source {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    color: #475569;
    font-size: 13px;
}

.table-source-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 25px;
    height: 25px;
    border-radius: 6px;
    background: #f1f5f9;
}


/* =========================================================
   37. BULK ACTION BAR
   ========================================================= */

.table-bulk-actions {
    display: none;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
    padding: 10px 14px;
    margin-bottom: 10px;
    border: 1px solid #bfdbfe;
    border-radius: 9px;
    background: #eff6ff;
}

.table-bulk-actions.is-visible {
    display: flex;
}

.table-bulk-info {
    color: #1e40af;
    font-size: 13px;
    font-weight: 600;
}

.table-bulk-buttons {
    display: flex;
    align-items: center;
    gap: 7px;
}


/* =========================================================
   38. STICKY HEADER
   ========================================================= */

.table-sticky-header thead th {
    position: sticky;
    top: 0;
    z-index: 2;
}


/* =========================================================
   39. STICKY FIRST COLUMN
   ========================================================= */

.table-sticky-first th:first-child,
.table-sticky-first td:first-child {
    position: sticky;
    left: 0;
    z-index: 1;
    background: #ffffff;
}

.table-sticky-first thead th:first-child {
    z-index: 3;
    background: #f8fafc;
}


/* =========================================================
   40. FOOTER TOTAL
   ========================================================= */

.table-total-row td {
    font-weight: 700;
    background: #f8fafc;
    border-top: 2px solid var(--border-color, #e5e7eb);
}


/* =========================================================
   41. DISABLED ROW
   ========================================================= */

.table-row-disabled {
    opacity: 0.55;
}

.table-row-disabled td {
    color: #94a3b8;
}


/* =========================================================
   42. SELECTED ROW
   ========================================================= */

.table tbody tr.is-selected {
    background: #eff6ff;
}

.table tbody tr.is-selected:hover {
    background: #dbeafe;
}


/* =========================================================
   43. ERROR ROW
   ========================================================= */

.table-row-error {
    background: #fef2f2 !important;
}

.table-row-error td {
    color: #991b1b;
}


/* =========================================================
   44. RESPONSIVE - TABLET
   ========================================================= */

@media (max-width: 992px) {

    .table-card-header {
        align-items: flex-start;
        flex-direction: column;
    }

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

    .table-toolbar-left,
    .table-toolbar-right {
        width: 100%;
    }

    .table-search {
        width: 100%;
    }

    .table-filters {
        width: 100%;
    }

    .table-filter {
        flex: 1 1 150px;
    }

    .table-pagination {
        align-items: center;
    }
}


/* =========================================================
   45. RESPONSIVE - MOBILE
   ========================================================= */

@media (max-width: 768px) {

    .table-wrapper {
        border-radius: 10px;
    }

    .table {
        min-width: 650px;
        font-size: 13px;
    }

    .table th,
    .table td {
        padding: 11px 12px;
    }

    .table-card {
        border-radius: 10px;
    }

    .table-card-header {
        padding: 14px 15px;
    }

    .table-card-footer {
        padding: 12px 15px;
    }

    .table-toolbar-left,
    .table-toolbar-right {
        gap: 7px;
    }

    .table-filters {
        display: grid;
        grid-template-columns: 1fr 1fr;
        width: 100%;
    }

    .table-filter {
        width: 100%;
        min-width: 0;
    }

    .table-pagination {
        padding: 12px;
    }

    .table-pagination-info {
        width: 100%;
        text-align: center;
    }

    .table-pagination-controls {
        width: 100%;
        justify-content: center;
    }
}


/* =========================================================
   46. RESPONSIVE - SMALL MOBILE
   ========================================================= */

@media (max-width: 480px) {

    .table {
        min-width: 600px;
    }

    .table th,
    .table td {
        padding: 9px 10px;
    }

    .table-filters {
        grid-template-columns: 1fr;
    }

    .table-card-title {
        font-size: 16px;
    }

    .table-actions {
        gap: 3px;
    }

    .table-action {
        width: 31px;
        height: 31px;
    }

    .table-user-avatar {
        width: 32px;
        height: 32px;
        flex-basis: 32px;
    }

    .table-user {
        gap: 8px;
    }
}


/* =========================================================
   47. DARK MODE SUPPORT
   ========================================================= */

@media (prefers-color-scheme: dark) {

    .dark-mode .table,
    .dark-mode .table-card,
    .dark-mode .table-wrapper {
        background: #111827;
        color: #e5e7eb;
        border-color: #374151;
    }

    .dark-mode .table th {
        background: #1f2937;
        color: #cbd5e1;
    }

    .dark-mode .table td {
        color: #e5e7eb;
        border-color: #374151;
    }

    .dark-mode .table tbody tr:hover {
        background: #1f2937;
    }

    .dark-mode .table-card-header,
    .dark-mode .table-card-footer,
    .dark-mode .table-pagination {
        border-color: #374151;
    }

    .dark-mode .table-card-title {
        color: #f8fafc;
    }

    .dark-mode .table-search input,
    .dark-mode .table-filter,
    .dark-mode .table-page {
        background: #111827;
        color: #e5e7eb;
        border-color: #374151;
    }

    .dark-mode .table-user-name,
    .dark-mode .table-business-name,
    .dark-mode .table-amount {
        color: #f8fafc;
    }

    .dark-mode .table-sticky-first th:first-child,
    .dark-mode .table-sticky-first td:first-child {
        background: #111827;
    }

    .dark-mode .table-sticky-first thead th:first-child {
        background: #1f2937;
    }
}