/**
 * A-MIS tables — polished list / DataTables / profile tables
 */

:root {
    --amis-table-text: #1e293b;
    --amis-table-muted: #64748b;
    --amis-table-border: #e2e8f0;
    --amis-table-surface: #f8fafc;
    --amis-table-header: #0f2744;
    --amis-table-accent: #c9a227;
    --amis-table-accent-soft: rgba(201, 162, 39, 0.14);
    --amis-table-row-hover: #f1f5f9;
    --amis-table-stripe: #fafbfc;
    --amis-table-primary: #1e3a5f;
    --amis-table-link: #1d4ed8;
}

.main-content .table,
.main-content table.dataTable,
.modal .table,
.modal table.dataTable {
    color: var(--amis-table-text);
    margin-bottom: 0;
    border-collapse: collapse;
    border-spacing: 0;
    width: 100%;
}

/* Override Stisla fixed 60px row height */
.main-content .table:not(.table-sm):not(.table-md) td,
.main-content .table:not(.table-sm):not(.table-md) th,
.main-content table.dataTable tbody td,
.main-content table.dataTable tbody th,
.main-content table.dataTable thead td,
.main-content table.dataTable thead th,
.modal .table:not(.table-sm):not(.table-md) td,
.modal .table:not(.table-sm):not(.table-md) th,
.modal table.dataTable tbody td,
.modal table.dataTable tbody th,
.modal table.dataTable thead td,
.modal table.dataTable thead th {
    height: auto !important;
}

/* Headers — light, readable, gold accent underline */
.main-content .table > thead > tr > th,
.main-content .table > thead > tr > td,
.main-content table.dataTable > thead > tr > th,
.main-content table.dataTable > thead > tr > td,
.modal .table > thead > tr > th,
.modal .table > thead > tr > td,
.modal table.dataTable > thead > tr > th,
.modal table.dataTable > thead > tr > td {
    background: #f8fafc !important;
    color: #475569 !important;
    font-size: 0.72rem !important;
    font-weight: 700 !important;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-top: none !important;
    border-left: none !important;
    border-right: none !important;
    border-bottom: 2px solid var(--amis-table-accent) !important;
    padding: 0.85rem 1rem !important;
    vertical-align: middle !important;
    white-space: nowrap;
    box-shadow: none !important;
}

.main-content .table thead.table-light th,
.main-content .table thead.table-light td,
.main-content .table.table-bordered thead th,
.main-content table.dataTable.table-bordered thead th {
    background: #f8fafc !important;
    color: #475569 !important;
    border-bottom: 2px solid var(--amis-table-accent) !important;
}

.main-content .table thead th a,
.main-content table.dataTable thead th a {
    color: #334155 !important;
}

.main-content .table thead th a:hover,
.main-content table.dataTable thead th a:hover {
    color: #0f172a !important;
}

/* Body cells */
.main-content .table tbody td,
.main-content .table tbody th,
.main-content table.dataTable tbody td,
.main-content table.dataTable tbody th {
    padding: 0.8rem 1rem !important;
    vertical-align: middle;
    font-size: 0.875rem;
    color: var(--amis-table-text);
    border-color: var(--amis-table-border) !important;
    background-clip: padding-box;
}

.main-content .table:not(.table-bordered) td,
.main-content .table:not(.table-bordered) th {
    border-top: none;
    border-bottom: 1px solid var(--amis-table-border);
}

.main-content .table.table-bordered,
.main-content .table.table-bordered td,
.main-content .table.table-bordered th,
.main-content table.dataTable.table-bordered,
.main-content table.dataTable.table-bordered td,
.main-content table.dataTable.table-bordered th {
    border-color: var(--amis-table-border) !important;
}

.main-content .table.table-bordered {
    border: 1px solid var(--amis-table-border) !important;
}

.main-content .table.table-bordered thead th,
.main-content table.dataTable.table-bordered thead th {
    border-bottom-width: 2px !important;
    border-bottom-color: var(--amis-table-accent) !important;
}

/* Striped & hover */
.main-content .table-striped tbody tr:nth-of-type(odd),
.main-content table.dataTable.table-striped tbody tr:nth-of-type(odd),
.main-content table.dataTable.stripe tbody tr.odd,
.main-content table.dataTable.display tbody tr.odd {
    background-color: var(--amis-table-stripe);
}

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

.main-content .table-hover tbody tr:hover,
.main-content .table tbody tr:hover,
.main-content table.dataTable.hover tbody tr:hover,
.main-content table.dataTable.display tbody tr:hover,
.main-content table.dataTable tbody tr:hover {
    background-color: var(--amis-table-row-hover) !important;
    box-shadow: inset 3px 0 0 var(--amis-table-accent);
}

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

/* Compact variant */
.main-content .table.table-sm thead th,
.main-content .table.table-sm tbody td,
.main-content .table.table-sm tbody th {
    padding: 0.5rem 0.75rem !important;
    font-size: 0.8125rem;
}

.main-content .table.table-sm thead th {
    font-size: 0.65rem;
    padding: 0.65rem 0.75rem !important;
}

/* Borderless detail tables */
.main-content .table.table-borderless tbody td,
.main-content .table.table-borderless tbody th {
    padding: 0.35rem 0 !important;
    border: none !important;
}

.main-content .table.table-borderless tbody tr:hover {
    background: transparent !important;
    box-shadow: none !important;
}

/* Links & actions */
.main-content .table a:not(.btn) {
    color: var(--amis-table-primary);
    font-weight: 600;
    text-decoration: none;
}

.main-content .table a:not(.btn):hover {
    color: var(--amis-table-link);
    text-decoration: underline;
}

.main-content .table .btn {
    font-size: 0.78rem;
    font-weight: 600;
    border-radius: 0;
    padding: 0.35rem 0.65rem;
    box-shadow: none;
}

.main-content .table .btn-icon,
.main-content .table .btn-icon-split {
    margin-right: 0.15rem;
}

.main-content .table .btn-group-vertical .btn {
    text-align: left;
}

.main-content .table .badge {
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    white-space: nowrap;
    border-radius: 0;
    padding: 0.35em 0.65em;
    border: 1px solid transparent;
}

.main-content .table .badge-primary {
    background: rgba(30, 58, 95, 0.12);
    color: #1e3a5f;
    border-color: rgba(30, 58, 95, 0.2);
}

.main-content .table .badge-secondary {
    background: #f1f5f9;
    color: #475569;
    border-color: #e2e8f0;
}

.main-content .table .badge-info {
    background: rgba(14, 165, 233, 0.12);
    color: #0369a1;
    border-color: rgba(14, 165, 233, 0.25);
}

.main-content .table .badge-warning {
    background: var(--amis-table-accent-soft);
    color: #92400e;
    border-color: rgba(201, 162, 39, 0.35);
}

.main-content .table .badge-success {
    background: rgba(22, 163, 74, 0.12);
    color: #166534;
    border-color: rgba(22, 163, 74, 0.28);
}

.main-content .table .badge-danger {
    background: rgba(220, 38, 38, 0.1);
    color: #b91c1c;
    border-color: rgba(220, 38, 38, 0.25);
}

/* Card-wrapped tables */
.main-content .card .card-body > .table-responsive,
.main-content .card .card-body > .dataTables_wrapper,
.main-content .profile-section-body > .table-responsive {
    margin: 0;
}

.main-content .card .card-body > .table-responsive:not(:first-child),
.main-content .card .card-body > .dataTables_wrapper:not(:first-child) {
    margin-top: 0.5rem;
}

.main-content .card .card-body > .table-responsive,
.main-content .profile-section-body > .table-responsive,
.main-content .amis-table-shell {
    border: 1px solid var(--amis-table-border);
    background: #fff;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.05);
    overflow-x: auto !important;
    overflow-y: visible;
    -webkit-overflow-scrolling: touch;
}

/* Custom Visible Scrollbar styling so users easily notice horizontal scroll */
.table-responsive::-webkit-scrollbar,
.dataTables_scrollBody::-webkit-scrollbar {
    height: 8px;
}

.table-responsive::-webkit-scrollbar-track,
.dataTables_scrollBody::-webkit-scrollbar-track {
    background: #e2e8f0;
    border-radius: 4px;
}

.table-responsive::-webkit-scrollbar-thumb,
.dataTables_scrollBody::-webkit-scrollbar-thumb {
    background: #94a3b8;
    border-radius: 4px;
}

.table-responsive::-webkit-scrollbar-thumb:hover,
.dataTables_scrollBody::-webkit-scrollbar-thumb:hover {
    background: #64748b;
}

.main-content .card .card-body > .table-responsive > .table,
.main-content .card .card-body > .table-responsive > table.dataTable,
.main-content .profile-section-body > .table-responsive > .table {
    margin-bottom: 0;
}

.main-content .card .card-body > .table:last-child,
.main-content .card .card-body > .table-responsive:last-child,
.main-content .card .card-body > .dataTables_wrapper:last-child {
    margin-bottom: 0;
}

/* Soft shadow shell for standalone tables */
.main-content .table-responsive {
    background: #fff;
}

.main-content .section-body > .row .card .table-responsive,
.main-content .card-body .table-responsive {
    border-radius: 0;
}

/* First column emphasis */
.main-content .table tbody td:first-child,
.main-content table.dataTable tbody td:first-child {
    font-weight: 600;
    color: #0f172a;
}

.main-content .table tbody td strong {
    font-weight: 700;
    color: #0f172a;
}

/* Dashboard invoice / widget tables */
.main-content .table-invoice .table thead th {
    font-size: 0.68rem;
}

.main-content .table-invoice .table tbody td {
    font-size: 0.8125rem;
}

/* DataTables wrapper */
.main-content .dataTables_wrapper {
    padding: 0 !important;
    font-size: 0.875rem !important;
}

.main-content .dataTables_wrapper .row:first-child {
    align-items: center;
    margin: 0 0 1rem;
    padding: 0.85rem 1rem;
    background: linear-gradient(135deg, rgba(201, 162, 39, 0.08), #fff 55%);
    border: 1px solid var(--amis-table-border);
    border-bottom: none;
}

.main-content .dataTables_wrapper .row:last-child {
    margin: 0;
    padding: 0.75rem 1rem;
    background: var(--amis-table-surface);
    border: 1px solid var(--amis-table-border);
    border-top: none;
}

.main-content .dataTables_wrapper > table,
.main-content .dataTables_wrapper > .row + table,
.main-content .dataTables_wrapper .dataTable {
    border-left: 1px solid var(--amis-table-border);
    border-right: 1px solid var(--amis-table-border);
}

.main-content .dataTables_wrapper .dataTables_length label,
.main-content .dataTables_wrapper .dataTables_filter label {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    margin: 0;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--amis-table-muted);
}

.main-content .dataTables_wrapper .dataTables_filter input,
.main-content .dataTables_wrapper .dataTables_length select {
    border: 1px solid var(--amis-table-border);
    min-height: 36px;
    padding: 0.35rem 0.7rem;
    font-size: 0.875rem;
    color: var(--amis-table-text);
    background: #fff;
    margin: 0 0.35rem;
    border-radius: 0;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.main-content .dataTables_wrapper .dataTables_filter input:focus,
.main-content .dataTables_wrapper .dataTables_length select:focus {
    border-color: var(--amis-table-accent);
    outline: none;
    box-shadow: 0 0 0 3px var(--amis-table-accent-soft);
}

.main-content .dataTables_wrapper .dataTables_info {
    color: var(--amis-table-muted);
    font-size: 0.8125rem;
    padding-top: 0.35rem;
}

.main-content .dataTables_wrapper .dataTables_paginate {
    padding-top: 0.15rem;
}

.main-content .dataTables_wrapper .dataTables_paginate .paginate_button {
    border: 1px solid var(--amis-table-border) !important;
    padding: 0.4rem 0.75rem !important;
    margin-left: 0.25rem !important;
    color: #334155 !important;
    background: #fff !important;
    font-size: 0.8125rem !important;
    font-weight: 600;
    line-height: 1.4;
    border-radius: 0 !important;
}

.main-content .dataTables_wrapper .dataTables_paginate .paginate_button.current,
.main-content .dataTables_wrapper .dataTables_paginate .paginate_button.current:hover {
    background: var(--amis-table-header) !important;
    border-color: var(--amis-table-header) !important;
    color: #fff !important;
    box-shadow: inset 0 -2px 0 var(--amis-table-accent);
}

.main-content .dataTables_wrapper .dataTables_paginate .paginate_button:hover:not(.disabled):not(.current) {
    background: var(--amis-table-accent-soft) !important;
    border-color: var(--amis-table-accent) !important;
    color: #92400e !important;
}

.main-content .dataTables_wrapper .dataTables_paginate .paginate_button.disabled,
.main-content .dataTables_wrapper .dataTables_paginate .paginate_button.disabled:hover {
    opacity: 0.45;
    cursor: default;
    background: var(--amis-table-surface) !important;
    color: #94a3b8 !important;
    border-color: var(--amis-table-border) !important;
    box-shadow: none;
}

.main-content table.dataTable.no-footer {
    border-bottom: 1px solid var(--amis-table-border) !important;
}

.main-content .dataTables_wrapper .dataTables_processing {
    background: rgba(255, 255, 255, 0.95) !important;
    border: 1px solid var(--amis-table-border) !important;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.1) !important;
    color: var(--amis-table-primary) !important;
    font-weight: 600;
}

/* Sort icons — readable on light headers */
.main-content table.dataTable thead .sorting,
.main-content table.dataTable thead .sorting_asc,
.main-content table.dataTable thead .sorting_desc,
.main-content table.dataTable thead .sorting_asc_disabled,
.main-content table.dataTable thead .sorting_desc_disabled {
    background-image: none !important;
    background-color: #f8fafc !important;
    position: relative;
    padding-right: 1.45rem !important;
    cursor: pointer;
    color: #475569 !important;
}

.main-content table.dataTable thead .sorting:before,
.main-content table.dataTable thead .sorting_asc:before,
.main-content table.dataTable thead .sorting_desc:before {
    position: absolute;
    right: 0.65rem;
    top: 50%;
    transform: translateY(-50%);
    font-family: 'Font Awesome 5 Free';
    font-weight: 900;
    font-size: 0.65rem;
    color: #94a3b8;
    opacity: 1;
}

.main-content table.dataTable thead .sorting:before {
    content: '\f0dc';
}

.main-content table.dataTable thead .sorting_asc:before,
.main-content table.dataTable thead .sorting_desc:before {
    color: #a16207;
}

.main-content table.dataTable thead .sorting_asc:before {
    content: '\f0de';
}

.main-content table.dataTable thead .sorting_desc:before {
    content: '\f0dd';
}

/* Empty & loading states */
.main-content .dataTables_empty,
.main-content .table td.dataTables_empty,
.main-content .table tbody td[colspan] {
    padding: 2.25rem 1rem !important;
    text-align: center;
    color: var(--amis-table-muted);
    font-size: 0.9rem;
    font-weight: 500;
    background: linear-gradient(180deg, #fff, var(--amis-table-surface));
}

@media (max-width: 767px) {
    .main-content .dataTables_wrapper .dataTables_length,
    .main-content .dataTables_wrapper .dataTables_filter {
        text-align: left;
        margin-bottom: 0.65rem;
    }

    .main-content .dataTables_wrapper .dataTables_filter label {
        width: 100%;
    }

    .main-content .dataTables_wrapper .dataTables_filter input {
        flex: 1;
        min-width: 0;
    }

    .main-content .table-responsive {
        border: 1px solid var(--amis-table-border);
    }

    .main-content .table thead th,
    .main-content .table tbody td {
        padding-left: 0.75rem !important;
        padding-right: 0.75rem !important;
    }
}
