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

Custom style overrides

We've tried to minimize custom CSS and use Django/unfold python features
whenever possible. When not possible, we've tried to document the CSS
overrides in this file.
============================================================================== */


/* ============================================================================
   CSS Variables
   ============================================================================ */

/* Light mode (default) */
:root {
    --border-color: #e5e7eb;
    --header-bg: #f9fafb;
    --text-primary: #374151;
    --text-secondary: #6b7280;
    --row-bg: #ffffff;
    --row-bg-alt: #f9fafb;
    --row-bg-hover: #f3f4f6;
    --old-value-color: #dc2626;
    --old-value-bg: #fef2f2;
    --new-value-color: #16a34a;
    --new-value-bg: #f0fdf4;
    --badge-created-bg: #dbeafe;
    --badge-created-color: #1d4ed8;
    /* Subtler input shadows (default is #0000000d = 5% black) */
    --tw-shadow-color: #00000005;
}

/* Dark mode - unfold uses .dark class on html element */
.dark {
    --border-color: #374151;
    --header-bg: #1f2937;
    --text-primary: #f3f4f6;
    --text-secondary: #9ca3af;
    --row-bg: #111827;
    --row-bg-alt: #1f2937;
    --row-bg-hover: #374151;
    --old-value-color: #fecaca;
    --old-value-bg: #7f1d1d;
    --new-value-color: #bbf7d0;
    --new-value-bg: #166534;
    --badge-created-bg: #1e3a5f;
    --badge-created-color: #93c5fd;
    /* Subtler input shadows for dark mode */
    --tw-shadow-color: #00000008;
}

/* ============================================================================
   History Table Layout
   ============================================================================ */

/* Spacing above table */
#content-main .module {
    margin-top: 1.5rem;
}

#change-history {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    border-radius: 0.5rem;
    overflow: hidden;
    border: 1px solid var(--border-color);
}

#change-history th,
#change-history td {
    padding: 0.75rem 1rem !important;
    text-align: left;
    vertical-align: top;
}

#change-history thead th {
    background-color: var(--header-bg);
    border-bottom: 2px solid var(--border-color);
    font-weight: 600;
    color: var(--text-primary);
}

#change-history tbody tr {
    border-bottom: 1px solid var(--border-color);
    background-color: var(--row-bg);
    transition: background-color 0.15s ease;
}

/* Zebra stripes */
#change-history tbody tr:nth-child(even) {
    background-color: var(--row-bg-alt);
}

#change-history tbody tr:hover {
    background-color: var(--row-bg-hover);
}

/* ============================================================================
   Change Details Styling
   ============================================================================ */

.changes-cell {
    min-width: 300px;
}

.change-item {
    margin-bottom: 0.25rem;
    font-size: 0.875rem;
    line-height: 1.4;
}

.change-item:last-child {
    margin-bottom: 0;
}

.field-name {
    font-weight: 600;
    color: var(--text-primary);
    margin-right: 0.25rem;
}

.old-value {
    color: var(--old-value-color);
    text-decoration: line-through;
    background-color: var(--old-value-bg);
    padding: 0.125rem 0.25rem;
    border-radius: 0.25rem;
}

.arrow {
    color: var(--text-secondary);
    margin: 0 0.25rem;
}

.new-value {
    color: var(--new-value-color);
    background-color: var(--new-value-bg);
    padding: 0.125rem 0.25rem;
    border-radius: 0.25rem;
}

.change-badge {
    display: inline-block;
    padding: 0.125rem 0.5rem;
    border-radius: 0.25rem;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.change-badge.created {
    background-color: var(--badge-created-bg);
    color: var(--badge-created-color);
}

.no-changes {
    color: var(--text-secondary);
    font-style: italic;
}

/* ============================================================================
   Compact Changelist Rows
   ============================================================================ */

/* Reduce vertical padding on changelist table cells for a more compact view */
.change-list table#result_list tbody td,
.change-list table#result_list tbody th {
    padding-top: 0.375rem;
    padding-bottom: 0.375rem;
}

/* Reduce vertical padding on tabular inline rows in changeform view */
.inline-group table tbody td,
.inline-group table tbody th {
    padding-top: 0.375rem;
    padding-bottom: 0.375rem;
}

/* Hide the "original" summary row that shows above each inline object */
.inline-group table tbody tr:has(td.original) {
    display: none !important;
}

/* Fallback for browsers that don't support :has() */
.inline-group table tbody td.original {
    display: none !important;
}

/* ============================================================================
   Dashboard Card Hover Effect
   ============================================================================ */

.dashboard-card-link {
    display: block;
    border-radius: 0.5rem;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.dashboard-card-link:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.dark .dashboard-card-link:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

/* ============================================================================
   Sidebar & Header Hover Effects
   ============================================================================ */

/* Sidebar navigation links */
aside nav a {
    transition: color 0.15s ease;
}

aside nav a:hover {
    color: var(--color-primary-600) !important;
}

.dark aside nav a:hover {
    color: var(--color-primary-400) !important;
}

/* Header area links (back button, breadcrumb links) */
#header-inner a {
    transition: color 0.15s ease;
}

#header-inner a:hover {
    color: var(--color-primary-600) !important;
}

.dark #header-inner a:hover {
    color: var(--color-primary-400) !important;
}

/* ============================================================================
   Fieldset Spacing
   ============================================================================ */

fieldset {
    margin-top: 0 !important;
}

/* ============================================================================
   Narrower Sidebar
   ============================================================================ */

/* Reduce sidebar width from default 288px to 240px */
#nav-sidebar {
    width: 240px !important;
}

/* Also adjust the wrapper div that has the same width */
.w-\[288px\] {
    width: 240px !important;
}

/* ============================================================================
   Grid Spacer Field
   ============================================================================ */

/* Hide the spacer field content but preserve its grid column space.
   Target field-line elements that have an empty label (spacer fields). */
.field-line:has(label:empty) {
    visibility: hidden !important;
}

/* ============================================================================
   Subtler Form Labels
   ============================================================================ */

/* Use subtle gray color for form field labels instead of bold/important */
.field-line label {
    color: var(--color-font-subtle-light) !important;
    font-weight: 500 !important;
}

.dark .field-line label {
    color: var(--color-font-subtle-dark) !important;
}

/* ============================================================================
   Readonly Field Styling
   ============================================================================ */

/* Remove box styling from readonly fields - show as plain text */
.readonly {
    background: none !important;
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
}

/* ============================================================================
   Select2 Autocomplete Shadow
   ============================================================================ */

/* Match Select2 shadow to native input shadow and remove extra border */
.select2-container--admin-autocomplete .select2-selection--single,
.select2-container--admin-autocomplete .select2-selection--multiple {
    box-shadow: 0 1px 2px 0 #00000005 !important;
    border: none !important;
}

/* ============================================================================
   Full-Width Fields
   ============================================================================ */

/* Allow rundir input to expand to full container width */
.field-rundir .max-w-2xl {
    max-width: none;
}

/* ============================================================================
   Hide Number Input Spinners
   ============================================================================ */

/* Chrome, Safari, Edge */
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* Firefox */
input[type="number"] {
    -moz-appearance: textfield;
}

/* ============================================================================
   Checkbox Field Alignment
   ============================================================================ */

/* Vertically center checkbox fields in form grid rows */
.field-line:has(input[type="checkbox"]) {
    align-self: center;
}

/* ============================================================================
   Import/Export Validation Errors
   ============================================================================ */

/* Add space below the table so error popups on the last rows aren't clipped */
.import-preview {
    margin-bottom: 8rem;
}

/* ============================================================================
   Changelist Column Separators
   ============================================================================ */

/* Add vertical separators between columns in changelist table.
   Only on desktop (lg:) since mobile uses a card-style layout.
   Note: The first data column (link column) uses <th> in tbody, not <td>. */
@media (min-width: 1024px) {
    .change-list table#result_list thead th:not(:last-child),
    .change-list table#result_list tbody th:not(:last-child),
    .change-list table#result_list tbody td:not(:last-child) {
        border-right: 1px solid var(--border-color) !important;
    }
}

/* ============================================================================
   Import/Export Preview Diff Colors
   ============================================================================ */

/* django-import-export uses <del> for removed values and <ins> for added values.
   These styles provide readable contrast in both light and dark mode using
   the same CSS variables as the history table diffs. */

table del,
.import-preview del {
    color: var(--old-value-color) !important;
    background-color: var(--old-value-bg) !important;
    text-decoration: line-through !important;
    padding: 0.125rem 0.25rem;
    border-radius: 0.25rem;
}

table ins,
.import-preview ins {
    color: var(--new-value-color) !important;
    background-color: var(--new-value-bg) !important;
    text-decoration: none !important;
    padding: 0.125rem 0.25rem;
    border-radius: 0.25rem;
}

/* ============================================================================
   DataTables Dark Mode
   ============================================================================ */

/* Base table styling */
#datatable {
    border-collapse: separate;
    border-spacing: 0;
}

#datatable thead th {
    background-color: var(--header-bg);
    color: var(--text-primary);
    font-weight: 600;
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 2px solid var(--border-color);
}

#datatable tbody tr {
    background-color: var(--row-bg);
    transition: background-color 0.15s ease;
}

#datatable tbody tr:nth-child(even) {
    background-color: var(--row-bg-alt);
}

#datatable tbody tr:hover {
    background-color: var(--row-bg-hover);
}

#datatable tbody td {
    padding: 0.5rem 1rem;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
}

/* Filter inputs in header */
#datatable thead tr.filters th {
    padding: 0.5rem;
    background-color: var(--header-bg);
}

/* Hide sorting icons on filter row (they're already in the header row) */
#datatable thead tr.filters th::before,
#datatable thead tr.filters th::after,
#datatable thead tr.filters th .dt-column-order,
#datatable thead tr.filters th span.dt-column-order {
    display: none !important;
}

/* Remove sortable styling from filter row */
#datatable thead tr.filters th {
    cursor: default !important;
    background-image: none !important;
}

#datatable thead tr.filters input {
    width: 100%;
    padding: 0.375rem 0.5rem;
    font-size: 0.875rem;
    border: 1px solid var(--border-color);
    border-radius: 0.25rem;
    background-color: var(--row-bg);
    color: var(--text-primary);
}

#datatable thead tr.filters input:focus {
    outline: none;
    border-color: var(--color-primary-500);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

#datatable thead tr.filters input::placeholder {
    color: var(--text-secondary);
}

/* DataTables wrapper elements */
.dataTables_wrapper {
    color: var(--text-primary);
}

.dataTables_info,
.dataTables_length label,
.dataTables_filter label {
    color: var(--text-secondary);
}

.dataTables_length select,
.dataTables_filter input {
    background-color: var(--row-bg);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 0.375rem 0.75rem;
    border-radius: 0.25rem;
}

/* Pagination */
.dataTables_paginate .paginate_button {
    padding: 0.375rem 0.75rem;
    margin: 0 0.125rem;
    border-radius: 0.25rem;
    border: 1px solid var(--border-color) !important;
    background: var(--row-bg) !important;
    color: var(--text-primary) !important;
}

.dataTables_paginate .paginate_button:hover {
    background: var(--row-bg-hover) !important;
    border-color: var(--border-color) !important;
}

.dataTables_paginate .paginate_button.current {
    background: var(--color-primary-600) !important;
    border-color: var(--color-primary-600) !important;
    color: white !important;
}

.dataTables_paginate .paginate_button.disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Buttons (CSV export) */
.dt-buttons .dt-button,
.dt-button-export {
    background-color: var(--row-bg);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 0.5rem 1rem;
    border-radius: 0.375rem;
    font-size: 0.875rem;
    cursor: pointer;
    transition: background-color 0.15s ease;
}

.dt-buttons .dt-button:hover,
.dt-button-export:hover {
    background-color: var(--row-bg-hover);
}

/* Scroller loading */
.dataTables_scrollBody {
    border-bottom: 1px solid var(--border-color);
}

.dts_loading {
    background-color: var(--row-bg);
    color: var(--text-secondary);
}

/* Hide default DataTables search (we use column filters) */
.dataTables_filter {
    display: none;
}

/* DataTables processing indicator */
.dataTables_processing {
    background-color: var(--row-bg);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    border-radius: 0.25rem;
    padding: 1rem;
}

