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

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: #fca5a5;
    --old-value-bg: #450a0a;
    --new-value-color: #86efac;
    --new-value-bg: #052e16;
    --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;
}

