/* components.css - tables, pagination, badges, modals, cookie-alert, buttons and component-specific styling */

/* Admin Table & related components */

.admin-table-wrapper table,
.admin-table-wrapper tbody,
.admin-table-wrapper td,
.admin-table-wrapper tfoot,
.admin-table-wrapper th,
.admin-table-wrapper thead,
.admin-table-wrapper tr {
    border-color: inherit;
    border-style: solid;
    border-width: 1px !important;
}

.admin-table-wrapper {
    overflow: hidden;
    background: white;
}

.admin-table-wrapper.admin-table-scroll {
    overflow: auto;
}

.admin-table {
    border: none;
    margin-bottom: 0;
}

.admin-table th,
.admin-table td {
    border-left: 1px solid var(--bs-border-color, #dee2e6);
    border-right: 1px solid var(--bs-border-color, #dee2e6);
}

.admin-table thead th {
    border-bottom: 2px solid #dee2e6;
    background-color: #f8f9fa;
    font-weight: 600;
}

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

/* Pagination Controls Styling */
.pagination-wrapper {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    gap: 1rem;
    flex-wrap: wrap;
}

.pagination-wrapper.top {
    border-bottom: none;
    border-top-left-radius: 0.375rem;
    border-top-right-radius: 0.375rem;
}

.pagination-wrapper.bottom {
    border-top: none;
    border-bottom-left-radius: 0.375rem;
    border-bottom-right-radius: 0.375rem;
}

.items-per-page-control {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    font-weight: 500;
}

.items-per-page-control label {
    margin: 0;
    color: #495057;
}

.items-per-page {
    padding: 0.375rem 0.75rem;
    border: 1px solid #ced4da;
    border-radius: 0.25rem;
    font-size: 0.875rem;
    background-color: white;
    color: #495057;
    min-width: 80px;
}

.items-per-page:focus {
    border-color: #86b7fe;
    outline: 0;
    box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
}

.table-info {
    font-size: 0.875rem;
    color: #6c757d;
    margin: 0;
    white-space: nowrap;
    font-weight: 500;
}

/* Modal roles: 3-column responsive grid */
#modal-roles-list {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.25rem 0.5rem;
    align-items: start;
}

/* Ensure the modal roles container matches JS expectations (padding/min-height moved from inline styles) */
#modal-roles-list {
    min-height: auto;
    padding: .5rem;
}

#modal-roles-list .form-check {
    display: flex !important;
    align-items: center;
    margin: 0 !important;
    padding: 0.15rem 0;
}

#modal-roles-list .form-check-input.modal-role-check {
    width: 1rem;
    height: 1rem;
    margin: 0 0.5rem 0 0;
}

#modal-roles-list .form-check-label {
    margin: 0;
    line-height: 1;
    font-size: 0.9rem;
}

#modal-roles-list.is-invalid {
    border: 1px solid var(--bs-danger);
    border-radius: 0.25rem;
    padding: 0.4rem;
    box-shadow: 0 0 0 0.2rem rgba(220, 53, 69, 0.12);
}

#modal-roles-list.is-valid {
    border: 1px solid var(--bs-success);
    border-radius: 0.25rem;
    padding: 0.4rem;
    box-shadow: 0 0 0 0.2rem rgba(25, 135, 84, 0.12);
}

.table-search-input {
    width: 180px;
}

.admin-table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.roles-badges .badge {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Default badge background / color for role badges to ensure contrast on light/dark themes */
.roles-badges .badge {
    background-color: #e9ecef;
    color: #212529;
    border: 1px solid rgba(0,0,0,0.04);
}

/* Role-based badge coloring — use normalized role classes (role-admin, role-staff, etc.) */
.badge.role-admin { background-color: #dc3545; color: #fff; }
.badge.role-staff { background-color: #0d6efd; color: #fff; }
.badge.role-faculty { background-color: #ffc107; color: #212529; }
.badge.role-student { background-color: #198754; color: #fff; }
.badge.role-ugapp, .badge.role-gsapp { background-color: #0dcaf0; color: #000; }
.badge.role-member { background-color: #6c757d; color: #fff; }
.badge.role-admin, .roles-badges .badge { padding: .35em .5em; margin-right: .25rem; display: inline-block; }

/* Slightly increase table cell padding for readability */
.admin-table-wrapper table.table th,
.admin-table-wrapper table.table td {
    padding: .5rem .75rem;
    vertical-align: middle;
}

/* Keep action buttons on one line */
.admin-table-wrapper td[data-label="Actions"] > div {
    white-space: nowrap;
}
.admin-table-wrapper td[data-label="Actions"] .btn {
    display: inline-block;
}

/* Inline form helper (used for small delete forms in tables) */
.form-inline-block {
    display: inline-block;
    margin: 0;
}

/* Pre element used to display roles (moved from inline style) */
#view-roles-content {
    white-space: pre-wrap;
    word-break: break-word;
    margin: 0;
}

/* Code block and contrast */
.code-block {
    background: var(--bs-light-bg-subtle, #f8f9fa);
    color: var(--bs-emphasis-color, #000);
    padding: 10px;
    border-radius: 4px;
    word-break: break-all;
    white-space: pre-wrap;
}

[data-bs-theme="dark"] .code-block {
    background: var(--bs-light-bg-subtle, #171a16) !important;
    color: var(--bs-emphasis-color, #fff) !important;
}

/* Utility: suppress focus ring only on mouse/pointer, not keyboard (WCAG 2.4.7) */
.no-focus-outline:focus:not(:focus-visible),
.no-focus-outline:active {
    outline: 0 !important;
    box-shadow: none !important;
    background-color: transparent !important;
}

.dropdown-toggle.no-focus-outline:focus:not(:focus-visible) {
    box-shadow: none !important;
}

/* Icon link styling and responsive variations */
.row .col.icon-link {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    text-decoration: none !important;
    transition: all 0.2s ease-in-out;
    text-align: center !important;
    box-sizing: border-box !important;
    overflow: visible !important;
}

/* Prevent Font Awesome glyph ascenders from clipping in card icon links */
.row .col.icon-link > i.fa-solid,
.row .col.icon-link > i.fa-regular,
.row .col.icon-link > i.fas,
.row .col.icon-link > i.far,
.row .col.icon-link > i.fad,
.row .col.icon-link > i.fal {
    display: inline-block;
    line-height: 1.15;
    padding-top: 0.08em;
}

/* Modal styles - minimal and theme-neutral */
.audit-modal {
    display: none;
}

.audit-modal.open {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 1100;
}

.audit-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 10005;
}

.audit-modal-content {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    background: var(--bs-body-bg, #fff);
    color: var(--bs-body-color, #000);
    border-radius: 6px;
    max-width: 900px;
    width: calc(100% - 32px);
    max-height: 80vh;
    overflow: auto;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    z-index: 10010;
}

.audit-modal-close {
    position: absolute;
    right: 8px;
    top: 6px;
    border: none;
    background: transparent;
    font-size: 1.6rem;
    line-height: 1;
    padding: .2rem .6rem;
    cursor: pointer;
    color: var(--bs-body-color, #000);
}

.audit-modal-body {
    padding: 1.25rem;
    overflow-x: auto;
    max-width: calc(100vw - 120px);
}

.audit-modal-body table {
    width: 100%;
    table-layout: fixed;
}

.audit-modal-body td,
.audit-modal-body th {
    word-break: break-word;
    overflow-wrap: anywhere;
}

.admin-table-scroll {
    overflow: auto;
    border-collapse: collapse;
    width: 100%;
}

/* Cookie alert */
.cookie-alert {
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    margin: 0 !important;
    z-index: 10000 !important;
    opacity: 0;
    visibility: hidden;
    border-radius: 0 !important;
    transition: all 250ms ease-out;
    transform: translateY(100%);
    color: #fff !important;
    background: rgba(0, 0, 0, 0.9) !important;
    border: none !important;
    text-align: center !important;
    padding: 15px !important;
}

.cookie-alert.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0%);
}

.cookie-alert span,
.cookie-alert p {
    display: inline-block;
}

.cookie-alert a,
.cookie-alert a:visited {
    color: #4CA0E0;
    text-decoration: underline
}

.cookie-alert a:focus,
.cookie-alert a:hover {
    color: #0078D4;
}

.cookie-alert .accept-cookies {
    margin-left: 10px;
    vertical-align: baseline;
}

/* Site-wide disclaimer styles */
.site-disclaimer {
    border-top: 1px solid var(--bs-border-color, #dee2e6) !important;
    background-color: transparent;
    padding-top: 0.75rem;
    padding-bottom: 0.75rem;
    color: #6c757d;
    font-size: 0.9rem;
}
.site-disclaimer p {
    margin: 0 0 0.375rem 0;
}
.site-disclaimer p:last-child {
    margin-bottom: 0;
}
@media (min-width: 768px) {
    .site-disclaimer {
        padding-left: 1.5rem;
        padding-right: 1.5rem;
    }
}

/* Ensure modals overlay the fixed header and cookie banner on small screens */
.modal-backdrop {
    z-index: 10005 !important;
}
.modal {
    z-index: 10010 !important;
}
/* Custom audit modal used in admin pages */
.audit-modal.open {
    z-index: 10010 !important;
}
.audit-modal-backdrop {
    z-index: 10005 !important;
}

.cookie-alert .accept-all.btn {
    background-color: #198754;
    border-color: #198754;
    color: #fff;
}

.cookie-alert .accept-all.btn:hover,
.cookie-alert .accept-all.btn:focus {
    background-color: #146c43;
    border-color: #146c43;
    color: #fff;
}

.cookie-alert .manage-cookies.btn {
    background-color: #0d6efd;
    border-color: #0d6efd;
    color: #fff;
}

.cookie-alert .manage-cookies.btn:hover,
.cookie-alert .manage-cookies.btn:focus {
    background-color: #0b5ed7;
    border-color: #0a58ca;
    color: #fff;
}

.cookie-alert .decline-all.btn {
    background-color: #dc3545;
    border-color: #dc3545;
    color: #fff;
}

.cookie-alert .decline-all.btn:hover,
.cookie-alert .decline-all.btn:focus {
    background-color: #c82333;
    border-color: #bd2130;
}
