/* =====================================================
   Jazzmin Admin - Related Object Popup Modal Fixes
   Selectors sourced from jazzmin/static/jazzmin/js/related-modal.js
   ====================================================*/

/* The Bootstrap modal that wraps the iframe */
div[class*="related-modal-"] .modal-dialog {
    max-width: 860px !important;
    width: 90vw !important;
    margin: 1.75rem auto !important;
}

div[class*="related-modal-"] .modal-content {
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.25);
}

div[class*="related-modal-"] .modal-header {
    padding: 0.75rem 1.25rem;
    background: var(--bg-sidebar);
    color: #fff;
}

div[class*="related-modal-"] .modal-header .btn-close {
    filter: invert(1);
}

/* The modal body must be tall enough to actually show the form */
div[class*="related-modal-"] .modal-body {
    padding: 0 !important;
    height: 75vh !important;
    max-height: 75vh !important;
    overflow: hidden !important;
}

/* The iframe must fill the entire modal body */
#related-modal-iframe,
.related-iframe {
    width: 100% !important;
    height: 100% !important;
    min-height: 75vh !important;
    border: none !important;
    display: block !important;
}

/* =====================================================
   Select2 Premium Styling & Border Fixes
   ====================================================*/

.select2-container--default .select2-selection--single,
.select2-container--default .select2-selection--multiple,
.select2-container--admin-autocomplete .select2-selection--single,
.select2-container--admin-autocomplete .select2-selection--multiple {
    border: 1px solid var(--slate-300) !important;
    border-radius: var(--radius-sm) !important;
    height: 38px !important;
    padding: 5px 12px !important;
    background-color: #fff !important;
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out !important;
}

.select2-container--default .select2-selection--single .select2-selection__rendered,
.select2-container--admin-autocomplete .select2-selection--single .select2-selection__rendered {
    padding: 0 !important;
    line-height: 26px !important;
    color: var(--slate-900) !important;
}

.select2-container--default .select2-selection--single .select2-selection__arrow,
.select2-container--admin-autocomplete .select2-selection--single .select2-selection__arrow {
    height: 100% !important;
    top: 0 !important;
    right: 8px !important;
}

.select2-container--default.select2-container--focus .select2-selection--single,
.select2-container--default.select2-container--focus .select2-selection--multiple,
.select2-container--admin-autocomplete.select2-container--focus .select2-selection--single,
.select2-container--admin-autocomplete.select2-container--focus .select2-selection--multiple {
    border-color: var(--primary) !important;
    outline: 0 !important;
    box-shadow: var(--focus-ring) !important;
}

.select2-container--admin-autocomplete .select2-selection__placeholder {
    color: var(--slate-500) !important;
}
/* List filters: each dropdown has a label naming the field it filters. */
#changelist-search {
    align-items: flex-end !important;
}
#changelist-search .jz-filter {
    display: flex;
    flex-direction: column;
    margin-bottom: 0;
}
#changelist-search .jz-filter-label {
    margin: 0 0 2px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: var(--slate-500);
    white-space: nowrap;
}
#changelist-search .jz-filter .select2-container {
    min-width: 160px;
}

/* =====================================================
   School Portal theme for the admin.
   Colours and fonts come from css/theme.css (shared with the front office);
   css/theme-bootstrap.css maps them onto Bootstrap. This file styles what is
   particular to the admin: sidebar, top bar, cards, lists and dropdowns.
   ====================================================*/

/* Sidebar: the same slate panel and indigo selection as the front office */
.app-sidebar {
    background: var(--bg-sidebar) !important;
    --bs-body-color: var(--text-sidebar);
    --bs-emphasis-color: #fff;
}
.app-sidebar .sidebar-brand {
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.app-sidebar .brand-link,
.app-sidebar .brand-text {
    color: #fff !important;
    font-weight: 600 !important;
}
.app-sidebar .user-panel,
.app-sidebar .user-panel .info a {
    color: var(--text-sidebar) !important;
}
.app-sidebar .sidebar-menu .nav-link {
    color: var(--text-sidebar);
    border-radius: var(--radius-sm);
}
.app-sidebar .sidebar-menu .nav-link:hover,
.app-sidebar .sidebar-menu .nav-link:focus-visible {
    background: var(--bg-sidebar-hover);
    color: #fff;
}
.app-sidebar .sidebar-menu .nav-link.active,
.app-sidebar .sidebar-menu .menu-open > .nav-link.active {
    background: var(--primary) !important;
    color: #fff !important;
    box-shadow: none !important;
}
.app-sidebar .sidebar-menu .menu-open > .nav-link:not(.active) {
    background: rgba(255, 255, 255, 0.06);
    color: #fff;
}
.app-sidebar .nav-header {
    color: var(--text-sidebar-label) !important;
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

/* Top bar */
.app-header {
    background: #fff !important;
    border-bottom: 1px solid var(--slate-200) !important;
    box-shadow: var(--shadow);
}
.app-header .nav-link {
    color: var(--slate-600);
}
.app-header .nav-link:hover {
    color: var(--slate-900);
}
.app-header .form-control-navbar {
    background: var(--slate-50);
    border-color: var(--slate-200);
}

/* Cards */
.card {
    --bs-card-border-color: var(--slate-200);
    --bs-card-border-radius: var(--radius);
    --bs-card-inner-border-radius: calc(var(--radius) - 1px);
    --bs-card-cap-bg: #fff;
    box-shadow: var(--shadow);
}
.card-primary.card-outline {
    border-top-color: var(--primary) !important;
}

/* Lists: quiet uppercase column headings and a light row hover, as in the front office */
.table {
    --bs-table-border-color: var(--slate-100);
    --bs-table-hover-bg: rgba(79, 70, 229, 0.03);
    --bs-table-striped-bg: var(--slate-50);
}
#result_list thead th {
    background: var(--slate-50);
    color: var(--slate-500);
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    border-bottom: 1px solid var(--slate-200);
}
#result_list thead th a {
    color: inherit;
}
#result_list tbody tr.selected,
#result_list tbody tr.selected td {
    background: var(--primary-light);
}

/* Select2 dropdowns: highlighted and chosen options in indigo */
.select2-container--default .select2-results__option--highlighted[aria-selected],
.select2-container--default .select2-results__option--highlighted.select2-results__option--selectable,
.select2-container--admin-autocomplete .select2-results__option--highlighted[aria-selected] {
    background-color: var(--primary) !important;
    color: #fff !important;
}
.select2-container--default .select2-selection--multiple .select2-selection__choice {
    background: var(--primary-light) !important;
    border-color: var(--primary-200) !important;
    color: var(--primary-darker) !important;
}

/* Layout shared with the front office: the same header height, sidebar widths
   and logo tile (sizes in css/theme.css), so moving between the admin and the
   site does not make anything jump. */
:root {
    --lte-sidebar-width: var(--sidebar-width);
}
.sidebar-mini.sidebar-collapse .app-sidebar {
    min-width: var(--sidebar-collapsed-width);
    max-width: var(--sidebar-collapsed-width);
}
.sidebar-mini.sidebar-collapse .sidebar-menu .nav-link {
    width: calc(var(--sidebar-collapsed-width) - 1rem);
}
.app-sidebar .sidebar-brand {
    height: var(--header-height);
    padding: 0 1rem;
    justify-content: flex-start;
}
.app-sidebar .brand-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 0;
    padding: 0;
    text-decoration: none;
}
.portal-logo {
    width: 36px;
    height: 36px;
    flex: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    background: var(--primary);
    color: #fff;
    font-size: 1rem;
    overflow: hidden;
}
.portal-logo img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}
.app-sidebar .brand-text {
    margin: 0 !important;
    font-size: 1.05rem;
    line-height: 1.2;
    overflow: hidden;
    text-overflow: ellipsis;
}
.app-header {
    height: var(--header-height);
    padding-top: 0 !important;
    padding-bottom: 0 !important;
}
.app-header .container-fluid {
    height: 100%;
    padding-left: 1.5rem;  /* menu button at the same spot as the front office's */
    padding-right: 1.5rem;
}
.app-header .navbar-nav .nav-link {
    white-space: nowrap;
}

/* Scrollbars: shared with the front office, see css/theme.css */

/* Page title and content spacing */
.app-content-header {
    padding-top: 1.25rem;
    padding-bottom: 0.75rem;
}
.app-content-header h3 {
    font-size: 1.5rem;
}
.app-content-header .breadcrumb {
    font-size: 0.8125rem;
    margin: 0;
}

/* Header search boxes: the site's look (pale field, rounded) */
.app-header .form-control-navbar {
    height: 36px;
    border-radius: var(--radius-sm) 0 0 var(--radius-sm);
    font-size: 0.8125rem;
}
.app-header .form-control-navbar:focus {
    background: #fff;
    border-color: var(--primary);
    box-shadow: var(--focus-ring);
}
.app-header .btn-navbar {
    height: 36px;
    border: 1px solid var(--slate-200);
    border-left: 0;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    background: var(--slate-50);
    color: var(--slate-500);
}
.app-header .navbar-nav .nav-link.active {
    color: var(--primary-dark);
    font-weight: 600;
}

/* Footer: quiet, one line */
.portal-footer {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.75rem 1.5rem;
    background: transparent;
    border-top: 1px solid var(--slate-200);
    color: var(--slate-500);
    font-size: 0.8125rem;
}

/* Admin home: a card per app, flowing in columns across the page */
.portal-app-grid {
    columns: 3 300px;
    column-gap: 1rem;
}
.portal-app-card {
    break-inside: avoid;
    display: inline-block;   /* keeps a card whole inside its column */
    width: 100%;
    margin-bottom: 1rem;
}
.portal-app-head {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--slate-200);
}
.portal-app-icon {
    width: 32px;
    height: 32px;
    flex: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    background: var(--primary-light);
    color: var(--primary);
    font-size: 0.9rem;
}
.portal-app-title {
    margin: 0;
    font-family: var(--font-heading);
    font-size: 1rem;
    font-weight: 600;
    color: var(--slate-900);
}
.portal-app-count {
    margin-left: auto;
    min-width: 24px;
    padding: 0 7px;
    border-radius: 999px;
    background: var(--slate-100);
    color: var(--slate-500);
    font-size: 0.75rem;
    font-weight: 600;
    text-align: center;
}
.portal-model-list {
    list-style: none;
    margin: 0;
    padding: 0.25rem 0;
}
.portal-model-list li {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0 0.5rem 0 0.25rem;
}
.portal-model-list li + li {
    border-top: 1px solid var(--slate-100);
}
.portal-model-link {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-sm);
    color: var(--slate-900);
    font-size: 0.875rem;
    text-decoration: none;
}
.portal-model-link i {
    width: 16px;
    flex: none;
    text-align: center;
    color: var(--slate-400);
}
a.portal-model-link:hover,
a.portal-model-link:focus-visible {
    background: var(--slate-50);
    color: var(--primary-dark);
}
a.portal-model-link:hover i {
    color: var(--primary);
}
.portal-model-tag {
    font-size: 0.6875rem;
    font-weight: 600;
    padding: 1px 7px;
    border-radius: 999px;
    background: var(--slate-100);
    color: var(--slate-500);
    white-space: nowrap;
}
.portal-model-add {
    flex: none;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.2rem 0.6rem;
    border: 1px solid var(--primary-200);
    border-radius: 999px;
    color: var(--primary-dark);
    font-size: 0.75rem;
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
}
.portal-model-add:hover,
.portal-model-add:focus-visible {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}
.portal-model-add i {
    font-size: 0.65rem;
}
/* Collapsed rail: only icons, like the front office (the name shows again on hover) */
.sidebar-mini.sidebar-collapse .app-sidebar:not(:hover) .user-panel .info,
.sidebar-mini.sidebar-collapse .app-sidebar:not(:hover) .brand-text {
    display: none;
}

/* Related panel on edit forms: lists of records linked to this one */
.portal-related {
    margin-top: 1rem;
    padding: 0.75rem;
    background: #fff;
    border: 1px solid var(--slate-200);
    border-radius: var(--radius);
}
.portal-related-title {
    margin: 0 0 0.5rem;
    font-family: var(--font-heading);
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--slate-900);
}
.portal-related-list {
    list-style: none;
    margin: 0;
    padding: 0;
}
.portal-related-list li {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}
.portal-related-link {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.5rem;
    border-radius: var(--radius-sm);
    color: var(--slate-900);
    font-size: 0.8125rem;
    text-decoration: none;
}
.portal-related-link i {
    width: 16px;
    text-align: center;
    color: var(--slate-400);
}
.portal-related-link span:first-of-type {
    flex: 1;
    min-width: 0;
    overflow-wrap: anywhere;
}
.portal-related-link:hover,
.portal-related-link:focus-visible {
    background: var(--slate-50);
    color: var(--primary-dark);
}
.portal-related-count {
    min-width: 22px;
    padding: 0 6px;
    border-radius: 999px;
    background: var(--slate-100);
    color: var(--slate-500);
    font-size: 0.75rem;
    font-weight: 600;
    text-align: center;
}
.portal-related-add {
    flex: none;
    width: 28px;
    height: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--primary-200);
    border-radius: 999px;
    color: var(--primary-dark);
    font-size: 0.7rem;
}
.portal-related-add:hover,
.portal-related-add:focus-visible {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

/* "Where am I" bar on a list narrowed to one record's children */
.portal-where {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.25rem 0.5rem;
    margin-top: 0.75rem;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--primary-200);
    border-radius: var(--radius-sm);
    background: var(--primary-light);
    color: var(--slate-600);
    font-size: 0.8125rem;
    clear: both;
}
.portal-where > i {
    color: var(--primary);
}
.portal-where-parent {
    font-weight: 600;
    color: var(--primary-darker);
}
.portal-where-actions {
    margin-left: auto;
    display: inline-flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem;
}

/* Linked record names in list columns */
#result_list .portal-fk-link {
    color: var(--primary-dark);
}

/* Add/edit forms opened in a pop-up over the page: plain white */
body.popup {
    background: #fff !important;
}

/* Compact lists and forms, so long lists stay easy to scan */
#result_list th,
#result_list td {
    padding: 0.45rem 0.65rem;
    vertical-align: middle;
    font-size: 0.8125rem;
}
#result_list td .form-check-input,
#result_list th .form-check-input {
    margin-top: 0;
}
.app-content .card-body {
    padding: 0.875rem 1rem;
}
.change-form .form-group,
.change-form .form-row {
    margin-bottom: 0.6rem;
}
.change-form .form-group label,
.change-form .col-form-label {
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--slate-600);
}
.inline-group .tabular td,
.inline-group .tabular th {
    padding: 0.35rem 0.5rem;
    vertical-align: middle;
}
.paginator,
.app-content .pagination {
    font-size: 0.8125rem;
}
