/* ===========================================
   ADMIN CUSTOM CSS
   Custom styling for Django admin interface
   =========================================== */

/* Prevent layout shift when scrollbar appears/disappears on main content */
body {
  scrollbar-gutter: stable;
  --header-bg: var(--client-primary-color) !important;
  /* For elements on primary color backgrounds (inline headers, nav sections, breadcrumbs) */
  --header-link-color: var(--client-primary-text-color) !important;
  /* Default font for all admin elements that don't have explicit font styling */
  font-family: 'DM Sans', sans-serif !important;
}

/* Header link color for page header only */
#header {
  --header-link-color: var(--client-header-text-color) !important;
}

/* But keep theme toggle using header background */
.theme-toggle {
  --header-bg: var(--client-header-bg-color) !important;
}

/* Site branding styling */
#site-branding {
  padding: 8px 0;
}

#header
{
  padding: 10px 35px !important;
}

/* Force EB Garamond for admin header/site name (non-login pages only) */
body:not(.login) #header #site-name,
body:not(.login) #header #site-name a,
body:not(.login) #site-name,
body:not(.login) #site-name a,
body:not(.login) #site-name a:link,
body:not(.login) #site-name a:visited {
  font-family: 'EB Garamond', serif !important;
  font-weight: 600;
  font-size: 3.2rem !important;
  letter-spacing: -1px;
}

/* Module captions and app module styling */
.module caption,
.app-module .model {
  background: var(--client-primary-color) !important;
  color: var(--client-primary-text-color) !important;
 
}

/* Breadcrumb navigation strip */
.breadcrumbs {
  background: var(--client-primary-color) !important;
}

/* Breadcrumb text color - use auto-detected primary text color */
.breadcrumbs,
.breadcrumbs a,
.breadcrumbs a:link,
.breadcrumbs a:visited {
  color: var(--client-primary-text-color) !important;
}

.breadcrumbs a,
.breadcrumbs a:link,
.breadcrumbs a:visited,
.breadcrumbs a:hover,
.breadcrumbs a:focus,
.breadcrumbs a:active {
  text-decoration: none !important;
}

/* Header background and text colors */
#header {
  background: var(--client-header-bg-color) !important;
}

.object-tools a.addlink {
  background: var(--client-primary-color) url("/static/admin/img/tooltag-add.e59d620a9742.svg") no-repeat right 7px center !important;
  color: var(--client-primary-text-color) !important;
  padding-right: 26px;
}

#site-name a,
#site-name a:link,
#site-name a:visited {
  color: var(--client-header-text-color) !important;
}

/* Success/info messages - make background semi-transparent */
.messagelist .success {
  background-color: rgba(173, 233, 187, 0.2) !important;
}


/* Widen sidebar to accommodate bold active links */
#nav-sidebar {
  flex: 0 0 265px !important;
}

#nav-sidebar a,
#nav-sidebar a:link,
#nav-sidebar a:visited,
#nav-sidebar a:hover,
#nav-sidebar a:focus,
#nav-sidebar a:active {
  text-decoration: none !important;
}

/* Override active sidebar section header text color */
#nav-sidebar .current-app .section:link,
#nav-sidebar .current-app .section:visited {
  color: var(--client-primary-text-color) !important;
}

/* Override selected sidebar item styling */
#nav-sidebar .current-model {
  background: #18334934 !important;
}

html[data-theme="dark"] #nav-sidebar .current-model {
  background: #a7c1dd6c !important;
}

/* Make selected items in multi-select lists read clearly as selected in light mode. */
html[data-theme="dark"] select[multiple] option:checked,
html[data-theme="dark"] select[size]:not([size="1"]) option:checked {
  background: #99c8ff !important;
  color: #121212 !important;
}

html[data-theme="light"] select[multiple] option:checked,
html[data-theme="light"] select[size]:not([size="1"]) option:checked {
  background: #99c8ff !important;
  color: #121212 !important;
}

@media (prefers-color-scheme: light) {
  html[data-theme="auto"] select[multiple] option:checked,
  html[data-theme="auto"] select[size]:not([size="1"]) option:checked {
    background: #99c8ff !important;
    color: #121212 !important;
  }
}

/* Admin dashboard and page headings */
body.dashboard #content h1 {
  font-family: 'EB Garamond', serif !important;
  font-size: 1.8rem !important;
  font-weight: 500 !important;
}

body.change-list #content h1,
body.change-form #content h1 {
  font-family: 'EB Garamond', serif !important;
  font-size: 1.6rem !important;
  font-weight: 700 !important;
}

body.change-list #content > h2,
body.change-form #content > h2 {
  font-family: 'Crimson Pro', serif !important;
  font-weight: 600 !important;
  font-size: 1.3rem;
}

#content h3,
body #content h3 {
  font-family: 'DM Sans', sans-serif !important;
}

/* Keep UTC server time without showing Django's browser/server offset note. */
.timezonewarning {
  display: none !important;
}

body.dashboard #content-related .module h2 {
  font-family: 'EB Garamond', serif !important;
  font-size: 1.5rem !important;
  font-weight: 500 !important;
}

/* Group permissions summary: use fieldset description as the heading and
   hide Django's empty readonly label cell so no orphaned colon remains. */
body.app-auth.model-group.change-form fieldset.permissions-summary-fieldset .description {
  margin-bottom: 10px;
}

body.app-auth.model-group.change-form .field-granted_permissions label,
body.app-auth.model-group.change-form .field-granted_permissions .flex-container > label {
  display: none !important;
}

body.app-auth.model-group.change-form .field-granted_permissions .readonly {
  margin-left: 0 !important;
  width: 100%;
}

body.dashboard #content-main a,
body.dashboard #content-main a:link,
body.dashboard #content-main a:visited,
body.dashboard #content-main a:hover,
body.dashboard #content-main a:focus,
body.dashboard #content-main a:active,
body.app-index #content-main a,
body.app-index #content-main a:link,
body.app-index #content-main a:visited,
body.app-index #content-main a:hover,
body.app-index #content-main a:focus,
body.app-index #content-main a:active {
  text-decoration: none !important;
}

/* User tools styling - apply auto-detected text color with dotted underline */
#user-tools,
#user-tools a,
#user-tools a:link,
#user-tools a:visited,
#user-tools form,
#user-tools button,
#user-tools input[type="submit"] {
  color: var(--client-header-text-color) !important;
}

#user-tools a,
#user-tools a:link,
#user-tools a:visited {
  border-bottom: 1px dotted var(--client-header-text-color) !important;
  text-decoration: none !important;
}

#user-tools a:hover,
#user-tools input[type="submit"]:hover {
  color: var(--client-header-text-color) !important;
  border-bottom: 1px dotted var(--client-header-text-color) !important;
}

/* Logout button styling */
#user-tools form input[type="submit"] {
  background: transparent !important;
  border: none !important;
  padding: 0 !important;
  cursor: pointer !important;
  font-size: inherit !important;
}

/* ===========================================
   Admin branding responsiveness
   =========================================== */


@media (max-width: 768px) {
  #site-branding {
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    text-align: center !important;
    gap: 0.8rem !important;
    width: 100% !important;
  }

  body:not(.login) #header #site-name,
  body:not(.login) #header #site-name a,
  body:not(.login) #header #site-name a:link,
  body:not(.login) #header #site-name a:visited,
  body:not(.login) #site-name,
  body:not(.login) #site-name a,
  body:not(.login) #site-name a:link,
  body:not(.login) #site-name a:visited {
    font-size: clamp(2.4rem, 4.5vw, 1.9rem) !important;
    text-align: center !important;
  }

  body:not(.login) #site-branding .org-logo {
    max-width: 120px !important;
    max-height: 120px !important;
    
  }
}

@media (max-width: 375px) {
  body:not(.login) #header #site-name,
  body:not(.login) #header #site-name a,
  body:not(.login) #header #site-name a:link,
  body:not(.login) #header #site-name a:visited,
  body:not(.login) #site-name,
  body:not(.login) #site-name a,
  body:not(.login) #site-name a:link,
  body:not(.login) #site-name a:visited {
    font-size: clamp(2.1rem, 6vw, 2.2rem) !important;
  }

  body:not(.login) #site-branding .org-logo {
    max-width: 100px !important;
    max-height: 100px !important;
  }
}

/* Override inline light color for current file path display */
.form-row .readonly,
.field-logo .readonly,
.form-row div[style*="color:#eee"] {
  color: #333 !important;
}

html[data-theme="dark"] .form-row .readonly,
html[data-theme="dark"] .field-logo .readonly,
html[data-theme="dark"] .form-row div[style*="color:#eee"] {
  color: #848484 !important;
}

/* Slightly wider Status column in ArchiveItem changelist */
.app-core.model-archiveitem .column-status {
  min-width: 130px;
}

/* Slightly wider Title column in ArchiveItem changelist */ 
.app-core.model-archiveitem .column-title {
  min-width: 170px;
}

/* Give key Document Library changelist columns a bit more room */
.app-core.model-documentlibrary .column-title {
  min-width: 240px;
}

/* Hide the "Clear" checkbox on file fields — replace by uploading a new file */
.app-core.model-documentlibrary .clearable-file-input {
  display: none;
}

.app-core.model-documentlibrary .column-storage_source {
  min-width: 140px;
}

.app-core.model-documentlibrary .column-uploaded_by_display {
  min-width: 140px;
}

.app-core.model-documentlibrary .form-row.field-is_external_link {
  flex-direction: column;
}

.app-core.model-documentlibrary .form-row.field-is_external_link .checkbox-row {
  display: flex;
  align-items: center;
}

.app-core.model-documentlibrary .form-row.field-is_external_link .checkbox-row > label {
  order: -1;
  width: 160px;
  padding: 0 10px 0 0;
  margin: 0;
}

.app-core.model-documentlibrary .form-row.field-is_external_link .checkbox-row > input[type="checkbox"] {
  margin: 0;
}

.app-core.model-documentlibrary .form-row.field-is_external_link .help,
.app-core.model-documentlibrary .form-row.field-is_external_link .helptext {
  margin-left: 170px;
}

/* Keep admin changelist rows vertically aligned */
#result_list tbody th,
#result_list tbody td {
  vertical-align: middle;
}

#result_list td.action-checkbox,
#result_list th.action-checkbox {
  vertical-align: middle;
}

/* Nudge admin list checkboxes down slightly so they sit level with row text */
#result_list td.action-checkbox input[type="checkbox"],
#result_list th.action-checkbox input[type="checkbox"] {
  margin-top: 0;
  vertical-align: middle;
  position: relative;
  top: 1px;
}

/* Give the Organisation column more room on the global user changelist. */
#result_list th.column-get_client,
#result_list td.field-get_client {
  min-width: 14rem;
  width: 14rem;
}

/* Enlarge help text question mark icon only for Files inline */
.inline-group .inline-related .help-tooltip {
  width: 17px !important;
    height: 17px !important;
    margin-left: 5px;
}

.help-tooltip-wrap {
  position: relative;
  display: inline-block;
}

.help-tooltip-wrap::after {
  content: attr(data-help);
  position: absolute;
  left: 0;
  top: 100%;
  margin-top: 6px;
  padding: 6px 8px;
  background: #2b2b2b;
  color: #fff;
  border-radius: 4px;
  font-size: 0.75rem;
  line-height: 1.2;
  width: 320px;
  max-width: 360px;
  white-space: normal;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
  opacity: 0;
  transform: translateY(2px);
  transition: opacity 0.05s ease, transform 0.05s ease;
  pointer-events: none;
  z-index: 1000;
  text-transform: none;
}

.help-tooltip-wrap:hover::after,
.help-tooltip-wrap:focus::after {
  opacity: 1;
  transform: translateY(0);
}

.admin-help-note {
  display: flex;
  align-items: flex-start;
  gap: 3.5px;
  margin-top: 6px;
  color: var(--body-quiet-color);
}

.admin-help-note__icon {
  color: currentColor;
  font-size: 1.3em;
  line-height: 1;
  flex: 0 0 auto;
}

.admin-help-note__text {
  min-width: 0;
  color: currentColor;
  font-size: 0.75rem;
}

.admin-help-note--warning {
  color: #b26a00;
}

.admin-help-note--warning .admin-help-note__icon {
  color: currentColor;
}

.admin-help-note--warning .admin-help-note__text {
  color: currentColor;
}

.app-core.model-documentlibrary [data-file-upload-warning="true"] {
  margin-top: 8px;
  margin-left: 160px;
}

.pending-setup-password-field::placeholder {
  font-size: 0.88em;
  font-style: italic;
}

