/* Custom Admin Styles for Rydes */

/* Global fix for horizontal scrolling on all list pages */
body.change-list #changelist-form {
    overflow-x: hidden !important;
}

body.change-list .results {
    overflow-x: hidden !important;
    width: 100% !important;
}

body.change-list #result_list {
    width: 100% !important;
    table-layout: auto !important;
}

/* Hide Save button on list pages when there are no editable fields */
body.change-list .paginator + p.submit-row {
    display: none !important;
}

/* Convert dropdown CTAs to simple buttons */
.submit-row .deletelink-box {
    display: none !important;
}

.submit-row {
    padding: 15px 0 !important;
    border: none !important;
    background: transparent !important;
}

.submit-row input[type="submit"] {
    margin-right: 10px !important;
    background-color: #3B71A1 !important;  /* Rydes cobalt blue */
    border: none !important;
    padding: 10px 20px !important;
    font-size: 14px !important;
    border-radius: 5px !important;
    cursor: pointer !important;
    transition: all 0.2s ease !important;
}

.submit-row input[type="submit"]:hover {
    background-color: #2A5378 !important;
    transform: translateY(-1px) !important;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2) !important;
}

.submit-row .default {
    background-color: #43A047 !important;  /* Success green */
}

.submit-row .default:hover {
    background-color: #388E3C !important;
}

/* Hide action text and go button globally */
.actions > label:first-child,
.actions > button[type="submit"]:not(.delete-selected-button):not(.add-user-button) {
    display: none !important;
}

/* Remove dropdown styling */
select.admin-action-select,
.actions select {
    display: none !important;
}

.actions button,
.actions .button {
    display: inline-block !important;
    margin-right: 10px !important;
    background-color: #3B71A1 !important;
    color: white !important;
    border: none !important;
    padding: 8px 16px !important;
    border-radius: 4px !important;
    cursor: pointer !important;
    text-decoration: none !important;
}

.actions button:hover,
.actions .button:hover {
    background-color: #2A5378 !important;
}

/* Password field with visibility toggle */
.password-input-wrapper {
    position: relative;
    display: inline-block;
    width: 100%;
}

.password-with-toggle {
    padding-right: 40px !important;
}

.password-toggle-btn {
    position: absolute;
    right: 5px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    padding: 5px;
    color: #666;
    font-size: 16px;
}

.password-toggle-btn:hover {
    color: #3B71A1;
}

/* Hide Django's default password toggle in UserProfile admin */
.field-password .toggle-password-visibility,
.field-password button[type="button"]:not(#toggle-password) {
    display: none !important;
}

/* Role checkboxes styling */
.form-row.field-is_enthusiast,
.form-row.field-is_site_admin {
    background-color: #f5f7f9;
    padding: 10px !important;
    margin: 5px 0 !important;
    border-radius: 5px;
    border-left: 4px solid #3B71A1;
}

.form-row.field-is_enthusiast label,
.form-row.field-is_site_admin label {
    font-weight: bold !important;
    color: #2C3035;
}

/* Modal styling improvements */
.modal-content {
    border-radius: 10px !important;
}

.modal-header {
    background-color: #3B71A1 !important;
    color: white !important;
    border-radius: 10px 10px 0 0 !important;
}

.modal-header h2 {
    color: white !important;
}

/* Navigation sidebar styling - force yellow group titles */
#nav-sidebar a.section {
    color: #ffc !important;
    font-weight: bold !important;
    text-transform: uppercase !important;
    font-size: 12px !important;
}

/* Remove spacing between navigation groups */
#nav-sidebar > *,
#nav-sidebar .module,
#nav-sidebar div[class*="app-"],
#nav-sidebar table {
    margin: 0 !important;
    margin-bottom: 0 !important;
    margin-top: 0 !important;
    padding-bottom: 0 !important;
}

/* Hover state for navigation titles */
#nav-sidebar a.section:hover {
    color: #fff !important;
    text-decoration: none !important;
}

/* Fix toolbar button layout to prevent overlapping */
.changelist-form-container .actions {
    display: flex !important;
    flex-wrap: nowrap !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    white-space: nowrap !important;
    max-width: 100% !important;
    padding: 10px 0 !important;
    gap: 10px !important;
}

/* Ensure buttons don't shrink or wrap */
.changelist-form-container .actions button,
.changelist-form-container .actions .button,
.changelist-form-container .actions a.button {
    flex-shrink: 0 !important;
    white-space: nowrap !important;
    min-width: fit-content !important;
}

/* Add scrollbar styling for better visibility */
.changelist-form-container .actions::-webkit-scrollbar {
    height: 8px !important;
}

.changelist-form-container .actions::-webkit-scrollbar-track {
    background: #f1f1f1 !important;
    border-radius: 4px !important;
}

.changelist-form-container .actions::-webkit-scrollbar-thumb {
    background: #888 !important;
    border-radius: 4px !important;
}

.changelist-form-container .actions::-webkit-scrollbar-thumb:hover {
    background: #555 !important;
}

/* Ensure the toolbar container doesn't overflow */
.results {
    overflow-x: hidden !important;
}

/* Fix for object-tools (top right buttons) */
.object-tools {
    display: flex !important;
    flex-wrap: nowrap !important;
    gap: 10px !important;
    float: none !important;
    margin: 0 !important;
    padding: 0 !important;
    position: relative !important;
    z-index: 1 !important;
}

.object-tools li {
    flex-shrink: 0 !important;
    margin-left: 0 !important;
    list-style: none !important;
}

.object-tools a {
    white-space: nowrap !important;
    display: inline-block !important;
}

/* Ensure proper layout for the entire changelist header */
#changelist #toolbar {
    display: flex !important;
    justify-content: space-between !important;
    align-items: flex-start !important;
    flex-wrap: nowrap !important;
    gap: 20px !important;
    overflow-x: auto !important;
    padding: 10px 0 !important;
}

#changelist .actions {
    flex: 0 0 auto !important;
    min-width: 0 !important;
}

/* Fix search bar to not overlap with buttons */
#toolbar form#changelist-search {
    flex: 0 0 auto !important;
    min-width: 200px !important;
    margin-right: 20px !important;
}

/* Prevent object-tools from floating and overlapping */
#changelist .object-tools {
    float: none !important;
    position: static !important;
    margin: 0 !important;
    flex: 0 0 auto !important;
    order: 3 !important; /* Place after search */
}

/* Ensure search form doesn't shrink too much */
#changelist-search {
    display: flex !important;
    align-items: center !important;
    gap: 10px !important;
}

#changelist-search input[type="text"] {
    min-width: 150px !important;
    flex: 1 1 auto !important;
}

/* Container for the entire toolbar to enable scrolling */
#changelist {
    overflow-x: auto !important;
}

/* Style the scrollbar for the changelist */
#changelist::-webkit-scrollbar {
    height: 8px !important;
}

#changelist::-webkit-scrollbar-track {
    background: #f1f1f1 !important;
    border-radius: 4px !important;
}

#changelist::-webkit-scrollbar-thumb {
    background: #888 !important;
    border-radius: 4px !important;
}

#changelist::-webkit-scrollbar-thumb:hover {
    background: #555 !important;
}

/* Additional fix for toolbar elements positioning */
#content-main #changelist #toolbar {
    position: relative !important;
    min-height: 50px !important;
}

/* Ensure the right-side buttons don't overlap search */
#changelist #toolbar .object-tools {
    position: absolute !important;
    right: 0 !important;
    top: 0 !important;
    float: none !important;
    z-index: 10 !important;
}

/* Add padding to toolbar to accommodate absolute positioned elements */
#changelist #toolbar form {
    padding-right: 150px !important; /* Space for Add button */
}

/* Media query for small screens */
@media (max-width: 767px) {
    #changelist #toolbar {
        flex-direction: column !important;
        align-items: stretch !important;
    }
    
    #changelist #toolbar .object-tools {
        position: static !important;
        margin-top: 10px !important;
        order: 2 !important;
    }
    
    #changelist #toolbar form {
        padding-right: 0 !important;
        order: 1 !important;
        width: 100% !important;
    }
    
    #changelist .actions {
        order: 3 !important;
        margin-top: 10px !important;
        width: 100% !important;
    }
}

/* Prevent any absolute positioning conflicts */
#changelist-form .results {
    clear: both !important;
    margin-top: 10px !important;
}

