/* =============================================================================
   SECTION: Global Admin Shell Styling
   BEGIN
   ============================================================================= */

/* Page background */
html, body {
    background: #f4f8fc !important;
    overflow-x: hidden !important;
    max-width: 100% !important;
}

/* Hide the default Django breadcrumbs everywhere */
.breadcrumbs {
    display: none !important;
}

/* Hide the Django admin left sidebar everywhere */
#nav-sidebar,
.toggle-nav-sidebar,
#toggle-nav-sidebar {
    display: none !important;
}

/* Remove the left offset that Django adds when the sidebar is present */
.main.shifted,
.main,
#content-start,
#content,
#content-main {
    margin-left: 0 !important;
    left: 0 !important;
    max-width: 100% !important;
    min-width: 0 !important;
    overflow-x: hidden !important;
}

/* Allow main content area to use full width */
#content {
    width: 100% !important;
    max-width: 100% !important;
}

/* Prevent odd layout gaps in some admin views */
.object-tools,
.submit-row,
.module,
.inline-group,
.dashboard #content {
    margin-left: 0 !important;
}

/* Improve top header spacing slightly */
#header {
    background: linear-gradient(90deg, #0b7fe0, #1fa4ff) !important;
    color: #ffffff !important;
    box-shadow: 0 4px 14px rgba(24, 50, 74, 0.08);
}

/* Ensure header text is visible */
#header a,
#header h1,
#header h1 a,
#header .brand,
#header .user-tools,
#header .user-tools a {
    color: #ffffff !important;
}

/* Ensure default Django header navigation buttons are readable */
#header .button,
#header .button:link,
#header .button:visited,
#header input[type="submit"],
#header input[type="button"],
#header .user-tools a.button,
#header .user-tools .button,
#header .nav-global a,
#header .nav-global .button {
    color: #ffffff !important;
    border-color: rgba(255, 255, 255, 0.45) !important;
}

/* =============================================================================
   SECTION: AceFlyte Global Top Navigation
   BEGIN
   ============================================================================= */

.aceflyte-global-nav {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 18px;
    margin: 12px 12px 0 12px;
    border-radius: 16px;
    border: 1px solid #cfe0f2;
    background: linear-gradient(
        180deg,
        rgba(77, 184, 255, 0.12) 0%,
        #ffffff 38%,
        #f7fbff 100%
    );
    box-shadow: 0 10px 24px rgba(24, 50, 74, 0.08);
    position: relative;
    overflow: hidden;
    max-width: 100% !important;
    min-width: 0 !important;
}

.aceflyte-global-nav::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    height: 4px;
    width: 100%;
    background: linear-gradient(90deg, #4db8ff, #7bd3ff);
}

.aceflyte-global-nav-btn {
    position: relative;
    overflow: hidden;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 225px;
    max-width: 225px !important;
    flex: 0 0 225px;
    min-height: 38px;
    padding: 0 10px;
    border-radius: 12px;
    border: 1px solid #b8d4ee !important;
    background: linear-gradient(
        180deg,
        rgba(255, 255, 255, 0.92) 0%,
        #eef5fc 100%
    ) !important;
    color: #18324a !important;
    -webkit-text-fill-color: #18324a !important;
    text-decoration: none !important;
    font-weight: 600;
    font-size: 0.92rem !important;
    line-height: 1.2;
    opacity: 1 !important;
    visibility: visible !important;
    text-shadow: none !important;
    transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

#header .aceflyte-global-nav .aceflyte-global-nav-btn,
#header .aceflyte-global-nav .aceflyte-global-nav-btn:link,
#header .aceflyte-global-nav .aceflyte-global-nav-btn:visited,
#header .aceflyte-global-nav .aceflyte-global-nav-btn:hover,
#header .aceflyte-global-nav .aceflyte-global-nav-btn:active,
#header .aceflyte-global-nav .aceflyte-global-nav-btn:focus {
    color: #18324a !important;
    -webkit-text-fill-color: #18324a !important;
    text-decoration: none !important;
    opacity: 1 !important;
    visibility: visible !important;
    text-shadow: none !important;
    font-size: 0.92rem !important;
}

.aceflyte-global-nav-btn::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    height: 3px;
    width: 100%;
    background: linear-gradient(90deg, #4db8ff, #7bd3ff);
}

.aceflyte-global-nav-btn:hover {
    transform: translateY(-1px);
    border-color: #4db8ff !important;
    box-shadow: 0 8px 18px rgba(77, 184, 255, 0.14);
}

/* =============================================================================
   SECTION: Admin Form / Module Box Standardization
   BEGIN
   ============================================================================= */

/* Make normal Django admin content boxes align better with the AceFlyte style */
.module,
.inline-group,
.submit-row,
fieldset.module,
.results,
#changelist-form .results,
.change-form .module {
    border-radius: 16px !important;
    border: 1px solid #d8e6f5 !important;
    background: linear-gradient(
        180deg,
        rgba(77, 184, 255, 0.12) 0%,
        #ffffff 38%,
        #f7fbff 100%
    ) !important;
    box-shadow: 0 10px 24px rgba(24, 50, 74, 0.08) !important;
    overflow: visible !important;
    position: relative !important;
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
}

/* Add the same top accent bar to normal admin modules */
.module::before,
.inline-group::before,
.submit-row::before,
fieldset.module::before,
.results::before,
#changelist-form .results::before,
.change-form .module::before {
    content: "" !important;
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    height: 4px !important;
    width: 100% !important;
    background: linear-gradient(90deg, #4db8ff, #7bd3ff) !important;
    z-index: 1 !important;
}

/* Give module headings a neater look */
.module h2,
.module caption,
.inline-group h2 {
    background: transparent !important;
    color: #18324a !important;
    font-weight: 700 !important;
    padding-top: 14px !important;
}

/* =============================================================================
   SECTION: AceJet Admin DAL / Select2 Layout Fix
   BEGIN
   ============================================================================= */

/* Make related widget wrapper behave nicely */
.related-widget-wrapper {
    display: flex !important;
    align-items: center !important;
    width: 100% !important;
    gap: 6px !important;
    min-width: 0 !important;
    max-width: 100% !important;
}

/* Make the main field area fill the row */
.related-widget-wrapper > .select2-container,
.related-widget-wrapper > select,
.related-widget-wrapper > .django-select2,
.select2-container {
    width: 100% !important;
    flex: 1 1 auto !important;
    min-width: 0 !important;
    max-width: 100% !important;
}

/* Force visible Select2 box */
.select2-container .select2-selection--single,
.select2-container .select2-selection--multiple {
    width: 100% !important;
    min-height: 38px !important;
    border: 1px solid #cfe0f2 !important;
    border-radius: 6px !important;
    background-color: #ffffff !important;
    color: #18324a !important;
    box-sizing: border-box !important;
    max-width: 100% !important;
}

/* Single select text */
.select2-container .select2-selection--single .select2-selection__rendered {
    color: #18324a !important;
    line-height: 36px !important;
    padding-left: 12px !important;
    padding-right: 30px !important;
}

/* Placeholder text */
.select2-container .select2-selection--single .select2-selection__placeholder,
.select2-container .select2-selection--multiple .select2-selection__placeholder {
    color: #5f7388 !important;
}

/* Dropdown arrow */
.select2-container .select2-selection--single .select2-selection__arrow {
    height: 36px !important;
    right: 8px !important;
}

/* Multi select */
.select2-container .select2-selection--multiple {
    color: #18324a !important;
    padding: 4px 8px !important;
}

/* Multi select selected tags */
.select2-container .select2-selection--multiple .select2-selection__choice {
    background: #eef5fc !important;
    border: 1px solid #cfe0f2 !important;
    color: #18324a !important;
    border-radius: 4px !important;
}

/* Search text inside multi select */
.select2-container .select2-search--inline .select2-search__field {
    color: #18324a !important;
    background: transparent !important;
}

/* Focus/open state */
.select2-container--focus .select2-selection--single,
.select2-container--focus .select2-selection--multiple,
.select2-container--open .select2-selection--single,
.select2-container--open .select2-selection--multiple {
    background-color: #ffffff !important;
    border-color: #4db8ff !important;
    box-shadow: 0 0 0 0.12rem rgba(77, 184, 255, 0.20) !important;
}

/* Dropdown panel */
.select2-dropdown {
    border: 1px solid #cfe0f2 !important;
    background-color: #ffffff !important;
    color: #18324a !important;
}

/* Dropdown result rows */
.select2-results__option {
    background: #ffffff !important;
    color: #18324a !important;
}

/* Highlighted result row */
.select2-results__option--highlighted[aria-selected] {
    background: #eef5fc !important;
    color: #18324a !important;
}

/* Selected result row */
.select2-results__option[aria-selected="true"] {
    background: #f7fbff !important;
    color: #18324a !important;
}

/* Search box inside dropdown */
.select2-search__field {
    border: 1px solid #cfe0f2 !important;
    background-color: #ffffff !important;
    color: #18324a !important;
    border-radius: 6px !important;
}

/* Hide Django related-object icons beside searchable fields */
.related-widget-wrapper-link {
    display: none !important;
}

/* Hide the tiny dropdown marker if it is still showing separately */
.related-widget-wrapper > a,
.related-widget-wrapper .select2 + a {
    display: none !important;
}

/* =============================================================================
   SECTION: Mobile Form Overflow Fix
   BEGIN
   ============================================================================= */

*,
*::before,
*::after {
    box-sizing: border-box !important;
}

form,
.change-form,
.change-form #content-main,
.change-form form,
.change-form .module,
.change-form fieldset,
.change-form .form-row,
.change-form .fieldBox,
.change-form .aligned .form-row,
.change-form .aligned label,
.change-form .aligned div,
.change-form .help,
.change-form .readonly,
.change-form .vTextField,
.change-form .vLargeTextField,
.change-form input[type="text"],
.change-form input[type="email"],
.change-form input[type="number"],
.change-form input[type="url"],
.change-form input[type="tel"],
.change-form input[type="password"],
.change-form input[type="date"],
.change-form input[type="datetime-local"],
.change-form input[type="time"],
.change-form select,
.change-form textarea,
.change-form .submit-row,
.change-form .inline-related,
.change-form .tabular,
.change-form .tabular table,
.change-form .tabular tbody,
.change-form .tabular tr,
.change-form .tabular td,
.change-form .tabular th {
    max-width: 100% !important;
    min-width: 0 !important;
}

.change-form .aligned .form-row,
.change-form .form-row,
.change-form .fieldBox {
    overflow: visible !important;
}

.change-form .aligned label,
.change-form .readonly,
.change-form .help,
.change-form .fieldBox p,
.change-form .form-row p,
.change-form .form-row div,
.change-form .form-row span {
    overflow-wrap: anywhere !important;
    word-break: break-word !important;
}

.change-form input[type="text"],
.change-form input[type="email"],
.change-form input[type="number"],
.change-form input[type="url"],
.change-form input[type="tel"],
.change-form input[type="password"],
.change-form input[type="date"],
.change-form input[type="datetime-local"],
.change-form input[type="time"],
.change-form select,
.change-form textarea {
    width: 100% !important;
    box-sizing: border-box !important;
}

.change-form .selector,
.change-form .selector-available,
.change-form .selector-chosen {
    max-width: 100% !important;
    min-width: 0 !important;
}

.change-form .tabular {
    overflow-x: auto !important;
}

.change-form .tabular table {
    table-layout: fixed !important;
    width: 100% !important;
}

.change-form .tabular td,
.change-form .tabular th {
    overflow-wrap: anywhere !important;
    word-break: break-word !important;
}

/* =============================================================================
   SECTION: Admin Form Inputs - Light Theme Fix
   BEGIN
   ============================================================================= */

.change-form input[type="text"],
.change-form input[type="email"],
.change-form input[type="number"],
.change-form input[type="url"],
.change-form input[type="tel"],
.change-form input[type="password"],
.change-form input[type="date"],
.change-form input[type="datetime-local"],
.change-form input[type="time"],
.change-form input[type="search"],
.change-form input[type="file"],
.change-form textarea,
.change-form select,
.change-form .vTextField,
.change-form .vLargeTextField,
.change-form .vURLField,
.change-form .vIntegerField,
.change-form .vDateField,
.change-form .vTimeField,
.change-form .vForeignKeyRawIdAdminField {
    background: #ffffff !important;
    color: #18324a !important;
    border: 1px solid #cfe0f2 !important;
    border-radius: 6px !important;
}

.change-form input[type="text"]:focus,
.change-form input[type="email"]:focus,
.change-form input[type="number"]:focus,
.change-form input[type="url"]:focus,
.change-form input[type="tel"]:focus,
.change-form input[type="password"]:focus,
.change-form input[type="date"]:focus,
.change-form input[type="datetime-local"]:focus,
.change-form input[type="time"]:focus,
.change-form input[type="search"]:focus,
.change-form input[type="file"]:focus,
.change-form textarea:focus,
.change-form select:focus,
.change-form .vTextField:focus,
.change-form .vLargeTextField:focus,
.change-form .vURLField:focus,
.change-form .vIntegerField:focus,
.change-form .vDateField:focus,
.change-form .vTimeField:focus,
.change-form .vForeignKeyRawIdAdminField:focus {
    background: #ffffff !important;
    color: #18324a !important;
    border-color: #4db8ff !important;
    box-shadow: 0 0 0 0.12rem rgba(77, 184, 255, 0.20) !important;
    outline: none !important;
}

.change-form select option {
    background: #ffffff !important;
    color: #18324a !important;
}

.change-form .aligned label,
.change-form .form-row label,
.change-form .form-row label.required {
    color: #18324a !important;
}

.change-form .help,
.change-form .helptext,
.change-form .form-row .help,
.change-form .form-row .helptext {
    color: #5f7388 !important;
}


/* =============================================================================
   SECTION: Admin Delete Button Vertical Clip Fix
   BEGIN
   ============================================================================= */

.change-form .submit-row a.deletelink,
.change-form .submit-row a.deletelink:link,
.change-form .submit-row a.deletelink:visited {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    min-height: 35px !important;
    line-height: 1.2 !important;
    padding-top: 0 !important;
    padding-bottom: 0 !important;
    box-sizing: border-box !important;
    overflow: visible !important;
}

/* =============================================================================
   SECTION: Admin Delete Button Vertical Clip Fix
   END
   ============================================================================= */

/* =============================================================================
   SECTION: Responsive Tweaks
   BEGIN
   ============================================================================= */

@media (max-width: 760px) {
    .aceflyte-global-nav {
        flex-wrap: wrap;
        gap: 8px;
        padding: 10px 12px;
        margin: 10px 10px 0 10px;
        border-radius: 14px;
    }

    .aceflyte-global-nav-btn {
        width: 100%;
    }

    .change-form .aligned label {
        float: none !important;
        display: block !important;
        width: 100% !important;
        padding-right: 0 !important;
    }

    .change-form .aligned .form-row > div,
    .change-form .aligned .form-row .readonly,
    .change-form .aligned .form-row p,
    .change-form .aligned .form-row .related-widget-wrapper {
        margin-left: 0 !important;
        width: 100% !important;
    }

    .change-form .submit-row input,
    .change-form .submit-row a,
    .change-form .submit-row .button,
    .change-form .submit-row button {
        width: 100% !important;
        margin: 0 0 8px 0 !important;
        box-sizing: border-box !important;
    }
}



/* =============================================================================
   SECTION: Mobile Search Box Fix (SAFE)
   BEGIN
   ============================================================================= */

@media (max-width: 760px) {

    /* Target Django admin search box ONLY */
    #changelist-search input[type="text"],
    #toolbar form input[type="text"],
    input[name="q"] {
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
        box-sizing: border-box !important;
    }

    /* Prevent container overflow */
    #changelist-search,
    #toolbar form {
        width: 100% !important;
        max-width: 100% !important;
        overflow-x: hidden !important;
        box-sizing: border-box !important;
    }
}

/* =============================================================================
   SECTION: Mobile Search Box Fix (SAFE)
   END
   ============================================================================= */
/* =============================================================================
   SECTION: END
   ============================================================================= */