/* Fixed admin table column widths + ellipsis (admin-panel-local).
   Widths come from CSS variables (content reference strings), locked via <colgroup> in JS. */

:root {
    --panel-col-vpn-login: 20ch;
    --panel-col-vpn-groups: 19ch;
    --panel-col-vpn-method: 10ch;
    --panel-col-vpn-configured: 19ch;
    --panel-col-vpn-datetime: 16ch;
    --panel-col-bool-icon: 3.25rem;

    --panel-col-login-attempt-reason: 27ch;
    --panel-col-resource-name: 12ch;
    --panel-col-ip: 20ch;
    --panel-col-license-status: 11ch;
    --panel-col-license-count: 8ch;
    --panel-col-date: 12ch;
    --panel-col-error-source: 18ch;
    --panel-col-connector-type: 10ch;
    --panel-col-sync-status: 10ch;
    --panel-col-email: 28ch;
    --panel-col-person-name: 16ch;
    --panel-col-username: 20ch;
    --panel-col-overage-days: 6ch;
}

/* Override Django changelist.css `#changelist table { width: 100% }`. */
#changelist table#result_list,
.export-preview-changelist table#result_list,
.license-overage-changelist table#result_list {
    table-layout: fixed !important;
    max-width: none !important;
}

#changelist .results,
.export-preview-changelist .results,
.license-overage-changelist .results {
    overflow-x: auto;
}

#changelist #result_list th,
#changelist #result_list td,
.export-preview-changelist #result_list th,
.export-preview-changelist #result_list td,
.license-overage-changelist #result_list th,
.license-overage-changelist #result_list td {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    vertical-align: middle;
    box-sizing: border-box;
}

#changelist #result_list tbody td,
.export-preview-changelist #result_list tbody td,
.license-overage-changelist #result_list tbody td {
    max-width: 0;
}

#changelist #result_list thead th {
    max-width: none;
    overflow: visible;
    text-overflow: clip;
}

#changelist #result_list thead th .text,
#changelist #result_list thead th .text a {
    overflow: visible;
    text-overflow: clip;
}

#changelist #result_list td > a,
.export-preview-changelist #result_list td > a,
.license-overage-changelist #result_list td > a {
    display: block;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#changelist #result_list .action-checkbox-column,
#changelist #result_list .action-checkbox,
#changelist #result_list col.panel-col-checkbox {
    width: 2.75rem !important;
    max-width: 2.75rem !important;
    min-width: 2.75rem !important;
}

#changelist #result_list .action-checkbox-column,
#changelist #result_list .action-checkbox {
    overflow: visible;
    text-overflow: clip;
    white-space: normal;
}

/* VPN users */
body.model-vpnuser #result_list :is(th.column-login, td.field-login) { width: var(--panel-col-vpn-login); }
body.model-vpnuser #result_list :is(th.column-groups_display, td.field-groups_display) { width: var(--panel-col-vpn-groups); }
body.model-vpnuser #result_list :is(th.column-otp_provider_display, td.field-otp_provider_display) { width: var(--panel-col-vpn-method); }
body.model-vpnuser #result_list :is(th.column-configured_methods_display, td.field-configured_methods_display) { width: var(--panel-col-vpn-configured); }
body.model-vpnuser #result_list :is(th.column-created_at_display, td.field-created_at_display),
body.model-vpnuser #result_list :is(th.column-last_login_display, td.field-last_login_display) { width: var(--panel-col-vpn-datetime); }
body.model-vpnuser #result_list :is(th.column-is_active, td.field-is_active) { width: var(--panel-col-bool-icon); text-align: center; }

/* Login attempts */
body.model-loginattempt #result_list :is(th.column-vpn_user, td.field-vpn_user) { width: var(--panel-col-vpn-login); }
body.model-loginattempt #result_list :is(th.column-date_time, td.field-date_time) { width: var(--panel-col-vpn-datetime); }
body.model-loginattempt #result_list :is(th.column-resource_name, td.field-resource_name) { width: var(--panel-col-resource-name); }
body.model-loginattempt #result_list :is(th.column-auth_method, td.field-auth_method) { width: var(--panel-col-vpn-method); }
body.model-loginattempt #result_list :is(th.column-client_ip, td.field-client_ip) { width: var(--panel-col-ip); }
body.model-loginattempt #result_list :is(th.column-attempt_reason, td.field-attempt_reason) { width: var(--panel-col-login-attempt-reason); }
body.model-loginattempt #result_list :is(th.column-auth_result, td.field-auth_result) { width: var(--panel-col-bool-icon); text-align: center; }

/* Export preview */
.export-preview-changelist #result_list :is(th.column-user, td.field-user) { width: var(--panel-col-vpn-login); }
.export-preview-changelist #result_list :is(th.column-date_time, td.field-date_time) { width: var(--panel-col-vpn-datetime); }
.export-preview-changelist #result_list :is(th.column-resource_name, td.field-resource_name) { width: var(--panel-col-resource-name); }
.export-preview-changelist #result_list :is(th.column-auth_method, td.field-auth_method) { width: var(--panel-col-vpn-method); }
.export-preview-changelist #result_list :is(th.column-client_ip, td.field-client_ip) { width: var(--panel-col-ip); }
.export-preview-changelist #result_list :is(th.column-auth_result, td.field-auth_result) { width: var(--panel-col-bool-icon); text-align: center; }

/* Licenses */
body.model-license #result_list :is(th.column-paid_licenses_display, td.field-paid_licenses_display),
body.model-license #result_list :is(th.column-additional_licenses_count, td.field-additional_licenses_count) { width: var(--panel-col-license-count); }
body.model-license #result_list :is(th.column-license_status_display, td.field-license_status_display) { width: var(--panel-col-license-status); }
body.model-license #result_list :is(th.column-date_from, td.field-date_from),
body.model-license #result_list :is(th.column-date_to, td.field-date_to) { width: var(--panel-col-date); }

/* License overage */
.license-overage-changelist #result_list :is(th.column-login, td.field-login) { width: var(--panel-col-vpn-login); }
.license-overage-changelist #result_list :is(th.column-created_at, td.field-created_at),
.license-overage-changelist #result_list :is(th.column-user_deleted_at, td.field-user_deleted_at) { width: var(--panel-col-vpn-datetime); }
.license-overage-changelist #result_list :is(th.column-overage_days, td.field-overage_days) { width: var(--panel-col-overage-days); }

/* Error log */
body.model-errorlogday #result_list :is(th.column-log_date, td.field-log_date) { width: var(--panel-col-date); }
body.model-errorlogday #result_list :is(th.column-source, td.field-source) { width: var(--panel-col-error-source); }
body.model-errorlogday #result_list :is(th.column-line_count, td.field-line_count) { width: var(--panel-col-license-count); }
body.model-errorlogday #result_list :is(th.column-updated_at, td.field-updated_at),
body.model-errorlogday #result_list :is(th.column-sent_to_cloud_at, td.field-sent_to_cloud_at) { width: var(--panel-col-vpn-datetime); }

/* Connectors */
body.model-connector #result_list :is(th.column-name, td.field-name) { width: var(--panel-col-resource-name); }
body.model-connector #result_list :is(th.column-provider_type, td.field-provider_type) { width: var(--panel-col-connector-type); }
body.model-connector #result_list :is(th.column-is_active, td.field-is_active) { width: var(--panel-col-bool-icon); text-align: center; }

/* Directory sync */
body.model-directorysync #result_list :is(th.column-connector_display, td.field-connector_display) {
    width: calc(var(--panel-col-resource-name) + var(--panel-col-connector-type));
}
body.model-directorysync #result_list :is(th.column-status_display, td.field-status_display) { width: var(--panel-col-sync-status); }

/* Resource / group / user lists */
body.model-resource #result_list :is(th.column-__str__, td.field-__str__),
body.model-usergroup #result_list :is(th.column-__str__, td.field-__str__),
body.model-user #result_list :is(th.column-__str__, td.field-__str__) { width: var(--panel-col-resource-name); }

body.model-user #result_list :is(th.column-username, td.field-username) { width: var(--panel-col-username); }
body.model-user #result_list :is(th.column-first_name, td.field-first_name),
body.model-user #result_list :is(th.column-last_name, td.field-last_name) { width: var(--panel-col-person-name); }
body.model-user #result_list :is(th.column-email, td.field-email) { width: var(--panel-col-email); }
body.model-user #result_list :is(th.column-is_active, td.field-is_active),
body.model-user #result_list :is(th.column-is_staff, td.field-is_staff),
body.model-user #result_list :is(th.column-is_superuser, td.field-is_superuser),
body.model-user #result_list :is(th.column-last_login, td.field-last_login) { width: var(--panel-col-bool-icon); text-align: center; }
body.model-user #result_list :is(th.column-date_joined, td.field-date_joined) { width: var(--panel-col-vpn-datetime); }
