/* Modals, query results, backup tables */

.modal-body table {
    table-layout: fixed;
    width: 100%;
}

.modal-body table td {
    word-wrap: break-word;
    overflow-wrap: break-word;
    word-break: break-word;
}

.modal-body pre {
    word-wrap: break-word;
    overflow-wrap: break-word;
    white-space: pre-wrap;
    word-break: break-word;
    max-width: 100%;
}

.query-result-table {
    width: 100% !important;
    table-layout: auto !important;
}

.query-result-table th {
    white-space: nowrap;
    min-width: 100px;
    background-color: #212529 !important;
    color: #fff !important;
    font-weight: 600;
    padding: 0.5rem 0.75rem !important;
    border: 1px solid #495057 !important;
}

.query-result-table td {
    padding: 0.5rem 0.75rem !important;
    border: 1px solid #dee2e6 !important;
    vertical-align: top;
    word-wrap: break-word;
    overflow-wrap: break-word;
    max-width: 300px;
}

.query-result-table thead th {
    position: sticky;
    top: 0;
    z-index: 10;
}

.query-result-table tbody tr:hover {
    background-color: #f8f9fa !important;
}

#queryResultsModal .modal-dialog {
    margin: 2.5vh auto;
}

#queryResultsModal .modal-content {
    max-height: 95vh;
}

#queryResultsModal .table-responsive {
    max-height: calc(95vh - 120px);
    overflow-x: auto;
    overflow-y: auto;
}

@media (max-width: 991.98px) {
    #queryResultsModal .modal-dialog {
        margin: 0;
        max-width: 100vw;
        height: 100vh;
    }

    #queryResultsModal .modal-content {
        max-height: 100vh;
        border-radius: 0;
    }

    #queryResultsModal .table-responsive {
        max-height: calc(100vh - 120px);
    }
}

.backup-table-wrapper {
    display: block;
    width: 100%;
    min-width: 0;
    max-width: 100%;
    overflow-x: auto;
    overflow-y: visible;
    -webkit-overflow-scrolling: touch;
    border-radius: var(--radius-lg, 8px);
    border: 1px solid var(--border-color, #e8ecf1);
}

.backup-history-modal .modal-body {
    min-width: 0;
    overflow: hidden;
    max-height: 70vh;
    display: flex;
    flex-direction: column;
}

.backup-history-modal .backup-table-wrapper {
    overflow-x: auto;
    overflow-y: auto;
    max-height: min(60vh, 480px);
    -webkit-overflow-scrolling: touch;
}

.backup-history-modal .backup-history-table thead th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: var(--bg-tertiary, #f0f4f8);
    box-shadow: 0 1px 0 var(--border-color, #e8ecf1);
}

.modal-body:has(.backup-table-wrapper) {
    min-width: 0;
    overflow-x: hidden;
}

.backup-jobs-table {
    table-layout: fixed;
    width: 1208px;
    min-width: 1208px;
}

.backup-jobs-table .col-name { width: 120px; min-width: 120px; }
.backup-jobs-table .col-desc { width: 180px; min-width: 180px; }
.backup-jobs-table .col-conn { width: 140px; min-width: 140px; }
.backup-jobs-table .col-type { width: 118px; min-width: 118px; }
.backup-jobs-table .col-path { width: 200px; min-width: 200px; }
.backup-jobs-table .col-status { width: 105px; min-width: 105px; }
.backup-jobs-table .col-date { width: 125px; min-width: 125px; }
.backup-jobs-table .col-actions { width: 220px; min-width: 220px; max-width: 220px; white-space: nowrap; }

.backup-jobs-table thead th {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    padding-right: 0.5rem;
}

.backup-jobs-table thead th .oi { margin-right: 0.25rem; flex-shrink: 0; }

.backup-jobs-table th.col-actions,
.backup-jobs-table td.col-actions { overflow: visible; white-space: nowrap; }

.backup-jobs-table td { overflow: hidden; text-overflow: ellipsis; }

.backup-history-table {
    table-layout: fixed;
    width: 980px;
    min-width: 980px;
}

.backup-history-table .col-file { width: 180px; min-width: 180px; }
.backup-history-table .col-type { width: 80px; min-width: 80px; }
.backup-history-table .col-size { width: 90px; min-width: 90px; }
.backup-history-table .col-status { width: 140px; min-width: 140px; }
.backup-history-table .col-start { width: 130px; min-width: 130px; }
.backup-history-table .col-end { width: 130px; min-width: 130px; }
.backup-history-table .col-duration { width: 85px; min-width: 85px; }
.backup-history-table .col-verified { width: 95px; min-width: 95px; }
.backup-history-table .col-actions { width: 90px; min-width: 90px; white-space: nowrap; }

.backup-history-table td { overflow: hidden; text-overflow: ellipsis; }

.backup-history-table td.col-status {
    max-width: 140px;
    white-space: nowrap;
}

.backup-history-table td.col-status .backup-history-error {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
    display: block;
}

.backup-history-table td.col-actions { overflow: visible; white-space: nowrap; }

/* Theme tối: bảng kết quả truy vấn (đồng bộ teal #2eb398 với .etl-table) */
html:not([data-theme="light"]) .query-result-table th {
    background-color: #2eb398 !important;
    color: #fff !important;
    border-color: #2eb398 !important;
}

html:not([data-theme="light"]) .query-result-table td {
    border-color: #2eb398 !important;
    color: rgba(248, 250, 252, 0.94) !important;
    background-color: rgba(2, 6, 23, 0.25) !important;
}

html:not([data-theme="light"]) .query-result-table tbody tr:hover {
    background-color: rgba(46, 179, 152, 0.1) !important;
}

html:not([data-theme="light"]) .query-result-table tbody tr:hover td {
    color: rgba(248, 250, 252, 0.98) !important;
}

html:not([data-theme="light"]) .backup-history-modal .backup-history-table thead th {
    background: #2eb398 !important;
    background-image: none !important;
    box-shadow: none;
    color: #fff !important;
    border-bottom: 2px solid #2eb398 !important;
}

html:not([data-theme="light"]) .backup-table-wrapper {
    border-color: #2eb398;
}

html:not([data-theme="light"]) .backup-history-modal .backup-history-table tbody td {
    border-bottom-color: #2eb398 !important;
}
