/* =========================================================
   AluminiumGlass
   assets/css/tables.css
   Production Data Tables
   ========================================================= */

/* ---------------------------------------------------------
   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(--surface-color, #ffffff);
}

.table-wrapper::-webkit-scrollbar {
    height: 8px;
}

.table-wrapper::-webkit-scrollbar-track {
    background: var(--background-color, #f5f7fa);
}

.table-wrapper::-webkit-scrollbar-thumb {
    background: var(--border-color, #d1d5db);
    border-radius: 10px;
}


/* ---------------------------------------------------------
   2. BASE TABLE
   --------------------------------------------------------- */

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

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

.table th {
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    color: var(--muted-text-color, #6b7280);
    background: var(--table-header-bg, #f8fafc);
    white-space: nowrap;
}

.table td {
    background: var(--surface-color, #ffffff);
}


/* ---------------------------------------------------------
   3. TABLE HEADER
   --------------------------------------------------------- */

.table thead th:first-child {
    border-top-left-radius: 12px;
}

.table thead th:last-child {
    border-top-right-radius: 12px;
}

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


/* ---------------------------------------------------------
   4. TABLE BODY
   --------------------------------------------------------- */

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

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

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


/* ---------------------------------------------------------
   5. STRIPED TABLE
   --------------------------------------------------------- */

.table-striped tbody tr:nth-child(even) td {
    background: var(--table-stripe-bg, #fafafa);
}

.table-striped tbody tr:nth-child(even):hover td {
    background: var(--table-hover-bg, #f3f4f6);
}


/* ---------------------------------------------------------
   6. BORDERED TABLE
   --------------------------------------------------------- */

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

.table-bordered th:last-child,
.table-bordered td:last-child {
    border-right: 0;
}


/* ---------------------------------------------------------
   7. COMPACT TABLE
   --------------------------------------------------------- */

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


/* ---------------------------------------------------------
   8. LARGE TABLE
   --------------------------------------------------------- */

.table-lg th,
.table-lg td {
    padding: 17px 20px;
}


/* ---------------------------------------------------------
   9. ALIGNMENT
   --------------------------------------------------------- */

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

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

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

.table .align-top {
    vertical-align: top;
}

.table .align-middle {
    vertical-align: middle;
}

.table .align-bottom {
    vertical-align: bottom;
}


/* ---------------------------------------------------------
   10. SORTABLE COLUMNS
   --------------------------------------------------------- */

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

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

.table th.sortable .sort-icon {
    display: inline-flex;
    margin-left: 5px;
    opacity: 0.5;
    transition: transform 0.2s ease, opacity 0.2s ease;
}

.table th.sortable:hover .sort-icon {
    opacity: 1;
}

.table th.sortable.is-asc .sort-icon {
    transform: rotate(180deg);
}

.table th.sortable.is-desc .sort-icon {
    transform: rotate(0deg);
}


/* ---------------------------------------------------------
   11. CHECKBOX COLUMN
   --------------------------------------------------------- */

.table .checkbox-column {
    width: 48px;
    min-width: 48px;
    text-align: center;
}

.table .checkbox-column input[type="checkbox"] {
    width: 16px;
    height: 16px;
    margin: 0;
    cursor: pointer;
    accent-color: var(--primary-color, #2563eb);
}


/* ---------------------------------------------------------
   12. ACTION COLUMN
   --------------------------------------------------------- */

.table .actions-column {
    width: 1%;
    min-width: 120px;
    white-space: nowrap;
    text-align: right;
}

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


/* ---------------------------------------------------------
   13. TABLE ACTION BUTTONS
   --------------------------------------------------------- */

.table-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    padding: 0;
    border: 1px solid transparent;
    border-radius: 8px;
    background: transparent;
    color: var(--muted-text-color, #6b7280);
    cursor: pointer;
    transition:
        background-color 0.15s ease,
        color 0.15s ease,
        border-color 0.15s ease;
}

.table-action:hover {
    background: var(--hover-color, #f3f4f6);
    color: var(--text-color, #111827);
}

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

.table-action.edit:hover {
    color: var(--warning-color, #d97706);
}

.table-action.delete:hover {
    color: var(--danger-color, #dc2626);
}


/* ---------------------------------------------------------
   14. STATUS BADGES
   --------------------------------------------------------- */

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

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


/* Active */

.table-status.active,
.table-status.approved,
.table-status.published,
.table-status.success {
    color: #15803d;
    background: #dcfce7;
}


/* Pending */

.table-status.pending,
.table-status.processing,
.table-status.review {
    color: #a16207;
    background: #fef9c3;
}


/* Inactive */

.table-status.inactive,
.table-status.disabled,
.table-status.draft {
    color: #6b7280;
    background: #f3f4f6;
}


/* Rejected */

.table-status.rejected,
.table-status.failed,
.table-status.cancelled {
    color: #b91c1c;
    background: #fee2e2;
}


/* ---------------------------------------------------------
   15. TABLE AVATAR / USER CELL
   --------------------------------------------------------- */

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

.table-user-avatar {
    flex: 0 0 auto;
    width: 38px;
    height: 38px;
    overflow: hidden;
    border-radius: 50%;
    background: var(--avatar-bg, #e5e7eb);
}

.table-user-avatar img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

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

.table-user-name {
    margin: 0;
    font-weight: 700;
    color: var(--text-color, #111827);
}

.table-user-meta {
    margin-top: 2px;
    font-size: 12px;
    color: var(--muted-text-color, #6b7280);
}


/* ---------------------------------------------------------
   16. BUSINESS CELL
   --------------------------------------------------------- */

.table-business {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 220px;
}

.table-business-logo {
    flex: 0 0 auto;
    width: 44px;
    height: 44px;
    overflow: hidden;
    border: 1px solid var(--border-color, #e5e7eb);
    border-radius: 8px;
    background: #f8fafc;
}

.table-business-logo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

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

.table-business-name {
    display: block;
    overflow: hidden;
    max-width: 280px;
    font-weight: 700;
    color: var(--text-color, #111827);
    text-overflow: ellipsis;
    white-space: nowrap;
}

.table-business-location {
    display: block;
    margin-top: 3px;
    overflow: hidden;
    max-width: 280px;
    font-size: 12px;
    color: var(--muted-text-color, #6b7280);
    text-overflow: ellipsis;
    white-space: nowrap;
}


/* ---------------------------------------------------------
   17. LINKS
   --------------------------------------------------------- */

.table a {
    color: var(--primary-color, #2563eb);
    text-decoration: none;
}

.table a:hover {
    text-decoration: underline;
}


/* ---------------------------------------------------------
   18. NUMERIC / MONEY
   --------------------------------------------------------- */

.table .number,
.table .amount {
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.table .amount {
    font-weight: 700;
}


/* ---------------------------------------------------------
   19. EMPTY STATE
   --------------------------------------------------------- */

.table-empty {
    padding: 50px 24px;
    text-align: center;
    color: var(--muted-text-color, #6b7280);
}

.table-empty-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 54px;
    height: 54px;
    margin: 0 auto 14px;
    border-radius: 50%;
    background: #f3f4f6;
    font-size: 22px;
}

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

.table-empty-text {
    max-width: 420px;
    margin: 0 auto;
    font-size: 13px;
}


/* ---------------------------------------------------------
   20. LOADING STATE
   --------------------------------------------------------- */

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

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

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

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


/* ---------------------------------------------------------
   21. SKELETON LOADING
   --------------------------------------------------------- */

.table-skeleton {
    height: 14px;
    overflow: hidden;
    border-radius: 5px;
    background: #e5e7eb;
    animation: table-skeleton-pulse 1.5s ease-in-out infinite;
}

.table-skeleton.short {
    width: 70px;
}

.table-skeleton.medium {
    width: 140px;
}

.table-skeleton.long {
    width: 220px;
}

@keyframes table-skeleton-pulse {
    0%,
    100% {
        opacity: 0.55;
    }

    50% {
        opacity: 1;
    }
}


/* ---------------------------------------------------------
   22. TABLE TOOLBAR
   --------------------------------------------------------- */

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

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


/* ---------------------------------------------------------
   23. TABLE SEARCH
   --------------------------------------------------------- */

.table-search {
    position: relative;
    min-width: 220px;
}

.table-search input {
    width: 100%;
    height: 40px;
    padding: 0 12px 0 38px;
    border: 1px solid var(--border-color, #d1d5db);
    border-radius: 8px;
    outline: none;
    background: #ffffff;
    color: var(--text-color, #111827);
    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.12);
}

.table-search-icon {
    position: absolute;
    top: 50%;
    left: 12px;
    transform: translateY(-50%);
    color: var(--muted-text-color, #6b7280);
    pointer-events: none;
}


/* ---------------------------------------------------------
   24. TABLE FILTER
   --------------------------------------------------------- */

.table-filter {
    height: 40px;
    min-width: 150px;
    padding: 0 34px 0 12px;
    border: 1px solid var(--border-color, #d1d5db);
    border-radius: 8px;
    outline: none;
    background-color: #ffffff;
    color: var(--text-color, #111827);
    cursor: pointer;
}

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


/* ---------------------------------------------------------
   25. PAGINATION
   --------------------------------------------------------- */

.table-pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    padding: 14px 0 0;
}

.table-pagination-info {
    font-size: 13px;
    color: var(--muted-text-color, #6b7280);
}

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

.table-page-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 0 10px;
    border: 1px solid var(--border-color, #d1d5db);
    border-radius: 8px;
    background: #ffffff;
    color: var(--text-color, #374151);
    cursor: pointer;
    transition:
        background-color 0.15s ease,
        border-color 0.15s ease,
        color 0.15s ease;
}

.table-page-btn:hover:not(:disabled) {
    border-color: var(--primary-color, #2563eb);
    color: var(--primary-color, #2563eb);
}

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

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


/* ---------------------------------------------------------
   26. SELECTED ROW
   --------------------------------------------------------- */

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

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


/* ---------------------------------------------------------
   27. PRIORITY ROW
   --------------------------------------------------------- */

.table tbody tr.priority-high td:first-child {
    border-left: 3px solid #dc2626;
}

.table tbody tr.priority-medium td:first-child {
    border-left: 3px solid #f59e0b;
}

.table tbody tr.priority-low td:first-child {
    border-left: 3px solid #22c55e;
}


/* ---------------------------------------------------------
   28. RESPONSIVE
   --------------------------------------------------------- */

@media (max-width: 768px) {

    .table-toolbar {
        align-items: stretch;
    }

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

    .table-search {
        flex: 1;
        min-width: 180px;
    }

    .table-filter {
        flex: 1;
        min-width: 140px;
    }

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

    .table-pagination-controls {
        width: 100%;
        overflow-x: auto;
        padding-bottom: 3px;
    }

    .table-page-btn {
        flex: 0 0 auto;
    }
}


/* ---------------------------------------------------------
   29. PRINT
   --------------------------------------------------------- */

@media print {

    .table-wrapper {
        overflow: visible;
        border: 0;
    }

    .table {
        min-width: 0;
        font-size: 10pt;
    }

    .table th,
    .table td {
        padding: 7px 8px;
    }

    .table-toolbar,
    .table-pagination,
    .table-actions,
    .table-action,
    .checkbox-column {
        display: none !important;
    }

    .table tbody tr:hover td {
        background: transparent;
    }
}