/* Custom styles for Murphy Materials Manager Admin */
/* Width adjustments only - NO theme/color changes */

/* ============================================================================ */
/* DJANGO DEBUG TOOLBAR - Force to Front (Development Only) */
/* ============================================================================ */
/* Fix z-index conflicts with AdminLTE/Jazzmin theme */
#djDebug {
    z-index: 999999 !important;
}

#djDebug[aria-hidden="false"] {
    display: block !important;
}

/* Ensure toolbar is visible on right side */
#djDebug.djdt-hidden {
    right: 0 !important;
}

#djDebug:not(.djdt-hidden) {
    right: 0 !important;
}

/* Keep content wrapper at normal width - no page-level horizontal scroll */
.content-wrapper {
    max-width: 100% !important;
    width: 100% !important;
    overflow-x: hidden !important; /* Prevent page-level horizontal scroll */
}

/* Make only the table area scrollable horizontally */
#changelist .results {
    overflow-x: auto !important;
    width: 100% !important;
}

/* Ensure changelist container doesn't cause page scroll */
#changelist {
    overflow-x: hidden !important;
}

/* Reduce font sizes by approximately two sizes (similar to dashboard) */
.content-wrapper {
    font-size: 0.85rem !important;
}

.content-wrapper .content {
    font-size: 0.85rem !important;
}

/* Reduce table font sizes */
#changelist table,
#changelist th,
#changelist td,
.results table,
.results th,
.results td {
    font-size: 0.85rem !important;
}

/* Reduce form font sizes */
.form-row,
.form-horizontal,
.field-box {
    font-size: 0.85rem !important;
}

/* Ensure tables and content expand to use the extra width */
.content-wrapper .content {
    max-width: 100%;
}

/* Make admin change list tables use full width */
#changelist {
    max-width: 100%;
}

#changelist .results {
    width: 100%;
}

/* Ensure form content uses available width */
.form-horizontal {
    max-width: 100%;
}

/* ============================================================================
   COLUMN WIDTH ADJUSTMENTS - Equipment Admin Pages
   ============================================================================

   HOW TO ADJUST COLUMN WIDTHS:

   1. Find the column you want to adjust in the sections below
   2. Change both 'min-width' and 'width' values (keep them the same)
   3. Units are in 'em' (1em ≈ width of one character at current font size)
   4. After editing, run: python manage.py collectstatic --noinput
   5. Refresh your browser to see changes

   TIPS:
   - Increase value to make column wider (e.g., 22em → 30em)
   - Decrease value to make column narrower (e.g., 22em → 18em)
   - Current font size is 0.85rem (set in lines 22-40 below)
   - Wider columns reduce text wrapping but require more horizontal scrolling
   - The horizontal scroll bar is confined to the table area only

   CURRENT WIDTHS (as of 2025-11-14):
   - Small columns (6-15em): Qty, Size, Op MTBF, Phase, Age, Dispensation, Status
   - Medium columns (18-24em): Item Number, Well, Rework, Created At, Serial, Type
   - Large columns (27-30em): Part Number, Material, Connections, Vendor, Location
   - Extra Large (40em): Description (for long text fields)

   ============================================================================ */

/* EQUIPMENT TABLE COLUMNS - Position-based selectors */
/* Using :nth-child() because Jazzmin doesn't output column-specific classes */
/* Optimized to eliminate horizontal scrolling and minimize empty-column widths */

/* Column 1: Checkbox - Selection (no width needed) */

/* Column 2: Item Number - Equipment identifier (CURRENT: 12em) */
#result_list th:nth-child(2),
#result_list td:nth-child(2) {
    min-width: 12em !important;
    width: 12em !important;
}

/* Column 3: Action Icon - Delete/edit (CURRENT: 3em) */
#result_list th:nth-child(3),
#result_list td:nth-child(3) {
    min-width: 3em !important;
    width: 3em !important;
}

/* Column 4: Part Number - Manufacturer SKU (CURRENT: 5em) */
#result_list th:nth-child(4),
#result_list td:nth-child(4) {
    min-width: 5em !important;
    width: 5em !important;
}

/* Column 5: Size - Equipment dimensions (CURRENT: 5em) */
#result_list th:nth-child(5),
#result_list td:nth-child(5) {
    min-width: 5em !important;
    width: 5em !important;
}

/* Column 6: Material - Material grade (CURRENT: 5em) */
#result_list th:nth-child(6),
#result_list td:nth-child(6) {
    min-width: 5em !important;
    width: 5em !important;
}

/* Column 7: Connections - Connection type (CURRENT: 5em) */
#result_list th:nth-child(7),
#result_list td:nth-child(7) {
    min-width: 5em !important;
    width: 5em !important;
}

/* Column 8: Storage Status - Current state (CURRENT: 10em) */
#result_list th:nth-child(8),
#result_list td:nth-child(8) {
    min-width: 10em !important;
    width: 10em !important;
}

/* Column 9: Inventory Type - Equipment category (CURRENT: 10em) */
#result_list th:nth-child(9),
#result_list td:nth-child(9) {
    min-width: 10em !important;
    width: 10em !important;
}

/* Column 10: Vendor Facility - Storage location (CURRENT: 5em) */
#result_list th:nth-child(10),
#result_list td:nth-child(10) {
    min-width: 5em !important;
    width: 5em !important;
}

/* Column 11: Well - Well identifier (CURRENT: 5em) */
#result_list th:nth-child(11),
#result_list td:nth-child(11) {
    min-width: 5em !important;
    width: 5em !important;
}

/* Column 12: Phase - Drilling phase (CURRENT: 5em) */
#result_list th:nth-child(12),
#result_list td:nth-child(12) {
    min-width: 5em !important;
    width: 5em !important;
}

/* Column 13: Age Condition - Equipment age/condition (CURRENT: 8em) */
#result_list th:nth-child(13),
#result_list td:nth-child(13) {
    min-width: 8em !important;
    width: 8em !important;
}

/* Column 14: Dispensation - Final disposition (CURRENT: 8em) */
#result_list th:nth-child(14),
#result_list td:nth-child(14) {
    min-width: 8em !important;
    width: 8em !important;
}

/* ============================================================================ */
/* CARDINAL EQUIPMENT SPECIFIC COLUMNS */
/* ============================================================================ */

/* Qty Display - Quantity count (OPTIMIZED: 5em - fits single digit "1") */
.column-qty_display,
th.column-qty_display,
th.field-qty_display,
td.field-qty_display {
    min-width: 5em !important;
    width: 5em !important;
}

/* Status Display - Cardinal equipment status (OPTIMIZED: 11em - fits "PENDING") */
.column-status_display,
th.column-status_display,
th.field-status_display,
td.field-status_display {
    min-width: 11em !important;
    width: 11em !important;
}

/* Serial Number - Unique serial identifier (OPTIMIZED: 15em - fits "414498-01") */
.column-serial_number,
th.column-serial_number,
th.field-serial_number,
td.field-serial_number {
    min-width: 15em !important;
    width: 15em !important;
}

/* Description - Full equipment description (OPTIMIZED: 45em - wider for long text)
   NOTE: This is the widest column - often contains long tool descriptions */
.column-description,
th.column-description,
th.field-description,
td.field-description {
    min-width: 45em !important;
    width: 45em !important;
}

/* Equipment Type - Cardinal equipment category (OPTIMIZED: 12em - fits "Mis. Tools") */
.column-equipment_type,
th.column-equipment_type,
th.field-equipment_type,
td.field-equipment_type {
    min-width: 12em !important;
    width: 12em !important;
}

/* Location - Storage/deployment location (OPTIMIZED: 20em - fits "Cardinal Sh...") */
.column-location,
th.column-location,
th.field-location,
td.field-location {
    min-width: 20em !important;
    width: 20em !important;
}

/* ============================================================================ */
/* ORIGINAL DATA FILE COLUMNS - Position-based selectors */
/* ============================================================================ */
/* Using :nth-child() because Jazzmin doesn't output column-specific classes */

/* Column 1: Checkbox - Selection (no width needed) */

/* Column 2: Name - File identifier (CURRENT: 20em) */
#result_list th:nth-child(2),
#result_list td:nth-child(2) {
    min-width: 20em !important;
    width: 20em !important;
}

/* Column 3: Source Type - Data source (CURRENT: 18em) */
#result_list th:nth-child(3),
#result_list td:nth-child(3) {
    min-width: 18em !important;
    width: 18em !important;
}

/* Column 4: File Type - Excel/document type (CURRENT: 15em) */
#result_list th:nth-child(4),
#result_list td:nth-child(4) {
    min-width: 15em !important;
    width: 15em !important;
}

/* Column 5: Is Current - Boolean checkmark (CURRENT: 8em) */
#result_list th:nth-child(5),
#result_list td:nth-child(5) {
    min-width: 8em !important;
    width: 8em !important;
}

/* Column 6: Uploaded By - User name (CURRENT: 8em) */
#result_list th:nth-child(6),
#result_list td:nth-child(6) {
    min-width: 8em !important;
    width: 8em !important;
}

/* Column 7: Uploaded At - Timestamp (CURRENT: 16em) */
#result_list th:nth-child(7),
#result_list td:nth-child(7) {
    min-width: 16em !important;
    width: 16em !important;
}

/* Column 8: File Size Display - Size in KB/MB (CURRENT: 10em) */
#result_list th:nth-child(8),
#result_list td:nth-child(8) {
    min-width: 10em !important;
    width: 10em !important;
}

/* Column 9: View Link - Action link (CURRENT: 8em) */
#result_list th:nth-child(9),
#result_list td:nth-child(9) {
    min-width: 8em !important;
    width: 8em !important;
}

/* Column 10: Download Link - Action link (CURRENT: 10em) */
#result_list th:nth-child(10),
#result_list td:nth-child(10) {
    min-width: 10em !important;
    width: 10em !important;
}

/* ============================================================================ */
/* DASHBOARD TABLE HORIZONTAL SCROLLING */
/* ============================================================================ */

/* Enable horizontal scrolling for dashboard tables (bounded to table area only) */
.dashboard-table-wrapper {
    overflow-x: auto !important;
    overflow-y: visible !important;
    width: 100% !important;
}

/* Ensure tables don't cause page-level horizontal scroll */
.dashboard-table-wrapper table {
    min-width: 100% !important;
    width: max-content !important;
}

/* ============================================================================ */
/* LOGIN PAGE CUSTOMIZATION */
/* ============================================================================ */

/* Reduce login screen logo by 1% (scale to 99% of original size) */
/* Target both the picture wrapper and the img inside */
.login-logo picture,
.login-logo img,
.login-box .login-logo picture,
.login-box .login-logo img,
body.login .login-logo picture,
body.login .login-logo img {
    max-width: 99% !important;
    max-height: 99% !important;
    width: 99% !important;
    height: auto !important;
}

/* Alternative approach using transform for better compatibility */
.login-logo picture img {
    transform: scale(0.99) !important;
    transform-origin: center !important;
}

/* Make login box narrower */
.login-box {
    width: 352px !important;  /* 320px * 1.1 = 352px */
    max-width: 352px !important;
}

/* ============================================================================ */
/* ADMIN HOME PAGE - APP MODULE ORDERING AND SIZING (INDEX PAGE ONLY) */
/* ============================================================================ */

/* Scope all rules to admin dashboard/index page only using body.dashboard */
/* This prevents affecting other admin pages like change lists */

/* Restructure the main dashboard layout - simpler approach */
body.dashboard section#content > .row {
    display: flex !important;
    flex-wrap: wrap !important;  /* Allow wrapping on smaller screens */
    gap: 1rem !important;
    align-items: flex-start !important;
}

/* Make the main content area (modules) narrower to leave room for Recent Actions */
body.dashboard section#content .col-lg-9 {
    flex: 0 0 auto !important;
    width: auto !important;
    max-width: fit-content !important;
}

/* Make the Recent Actions sidebar visible with fixed width */
body.dashboard section#content .col-lg-3 {
    flex: 0 0 300px !important;
    width: 300px !important;
    max-width: 300px !important;
}

/* Make module columns narrower and stack vertically */
body.dashboard section#content .col-lg-9 > .row > .col-md-6 {
    flex: 0 0 400px !important;
    max-width: 400px !important;
    width: 400px !important;
}

/* Ensure the module row wraps properly */
body.dashboard section#content .col-lg-9 > .row {
    display: flex !important;
    flex-wrap: wrap !important;
    justify-content: flex-start !important;
    gap: 1rem !important;
}

/* Make the module cards themselves consistent width */
body.dashboard section#content .col-lg-9 > .row > .col-md-6 > .card {
    max-width: 400px !important;
    width: 100% !important;
}

/* Optional: Order modules - Inventory first, Auth second */
body.dashboard section#content .col-lg-9 > .row > .col-md-6:has([href*="/inventory/"]) {
    order: 1 !important;
}

body.dashboard section#content .col-lg-9 > .row > .col-md-6:has([href*="/auth/"]) {
    order: 2 !important;
}
