* {
  box-sizing: border-box;
  font-family: Arial, Helvetica, sans-serif;
}

body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  background-color: #f8f9fa;
  color: #343a40;
}

/* --- Top Navigation Bar --- */
.topnav {
  overflow: hidden;
  background-color: #343a40;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  margin-bottom: 20px;
}

.topnav a {
  float: left;
  display: block;
  color: #f2f2f2;
  text-align: center;
  padding: 14px 16px;
  text-decoration: none;
  font-size: 17px;
  transition: background-color 0.3s, color 0.3s;
}

.topnav a:hover {
  background-color: #555;
  color: white;
}

/* --- Header / Listic Form Bar (#listic_form) --- */
.header {
    padding: 20px 0;
    margin: 0 20px;
}

/* Flex container for the header form fields */
#listic_form form {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 10px;
    background-color: #e9ecef;
    border-radius: 5px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    flex-wrap: wrap;
}

#listic_form select {
    height: calc(1.5em + .75rem + 2px);
    padding: .375rem .75rem;
    font-size: 1rem;
    line-height: 1.5;
    color: #495057;
    background-color: #fff;
    border: 1px solid #ced4da;
    border-radius: .25rem;
    width: auto;
    max-width: 200px;
}

#listic_form .form-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

#listic_form label {
    margin-bottom: 0;
    font-weight: normal;
}

/* --- Main Content Layout & Columns --- */
.column {
  float: left;
  width: 50%;
  padding: 10px;
  min-height: 500px;
}

.column:first-child {
    border-right: 1px solid #dee2e6;
}

/* Clear floats after the columns */
.row:after {
  content: "";
  display: table;
  clear: both;
}

.column > div:first-child {
    text-align: center;
    padding: 20px;
}

.column img {
    max-width: 100%;
    height: auto;
    border: 1px solid #dee2e6;
    border-radius: 5px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.column label {
    /* Removed redundant display: block; here as form-field-row handles it */
    margin-top: 10px;
    font-weight: bold;
    color: #6c757d;
}

/* --- Modal Styles --- */
.modal-image {
  display: none;
  position: fixed;
  z-index: 1;
  padding-top: 100px;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  overflow: auto;
  background-color: rgba(0,0,0,0.9);
}

.modal-content-image {
  margin: auto;
  display: block;
  width: 80%;
  max-width: 700px;
}

#caption {
  margin: auto;
  display: block;
  width: 80%;
  max-width: 700px;
  text-align: center;
  color: #ccc;
  padding: 10px 0;
  height: 150px;
}

.modal-content-image, #caption {
  animation-name: zoom;
  animation-duration: 0.6s;
}

@keyframes zoom {
  from {transform:scale(0)}
  to {transform:scale(1)}
}

.close {
  position: absolute;
  top: 15px;
  right: 35px;
  color: #f1f1f1;
  font-size: 40px;
  font-weight: bold;
  transition: 0.3s;
}

.close:hover,
.close:focus {
  color: #bbb;
  text-decoration: none;
  cursor: pointer;
}

/* --- Flexbox Form Field Styling (Label-on-Left) --- */

/* Wrapper for each field row */
.form-group.form-field-row {
    margin-bottom: 1rem;
}

/* Label Container (FIXES WRAPPING) */
.form-field-row .label-container {
    width: 40%;
    min-width: 220px; /* Accommodates long labels */
    text-align: right;
    padding-right: 15px;
    flex-shrink: 0;
}

/* CRITICAL FIX: Force the actual <label> inside the container to fill its space */
.form-field-row .label-container label {
    display: block !important;
    width: 100% !important;
    margin-right: 0 !important;
    margin-bottom: 0 !important;
    font-weight: 600; /* Reapply desired weight */
}

/* --- CRITICAL FIX: Reduce Label Width for Narrow Columns (col-md-4) --- */

/* This targets the label container inside a column used for narrow fields.
   The selector is now more specific and targets the column class *before* the field container. */
.col-md-4.form-group.form-field-row .label-container {
    /* Significantly reduce the width compared to the 220px default */
    width: 30% !important;
    min-width: 100px !important; /* Adjust this value (e.g., 100px, 120px) to fit your shortest label */
}
/* Specificity: 0, 4, 0 (four classes) - This guarantees it overrides the 0,2,0 generic rule. */


/* Input Container */
.form-field-row .input-container {
    flex-grow: 1;
}

/* Global Input/Select/Textarea Overrides (Fixes Django/Bootstrap conflicts) */
#edit-form input:not([type="checkbox"]),
#edit-form select,
#edit-form textarea {
    width: 100% !important; /* Overrides inline or less specific width rules */
    max-width: 100%;
    min-width: 80px; /* Ensures select fields are usable in small columns */
    margin-bottom: 0 !important; /* Removes default vertical spacing */
    /* Restore general input styling (removed from deleted #form block) */
    padding: .375rem .75rem;
    font-size: 1rem;
    line-height: 1.5;
    color: #495057;
    background-color: #fff;
    border: 1px solid #ced4da;
    border-radius: .25rem;
}

/* Cleanup for form-row inside the form */
#edit-form .form-row .form-group {
    margin-bottom: 0;
}

/* Checkbox Styling (FIXED SIZE & ALIGNMENT) */
.form-field-row .input-container input[type="checkbox"] {
    width: 1.25rem;  /* About 20px, for better visibility */
    height: 1.25rem;
    margin: 0;
    vertical-align: middle; /* Ensures vertical alignment with any text/label next to it */
}

/* Cleanup: Ensure base label styles don't conflict */
.form-field-row label {
    margin-bottom: 0;
}

/* --- Page Sizing Cleanup --- */

/* Targets the main content wrapper (assuming it's a container-fluid)
   Restores normal height flow to fix header consuming vertical space */
.container-fluid {
    height: auto !important;
    overflow-y: visible;
    padding-bottom: 2rem;
}






/* --- Responsive layout (Crucial for mobile usability) --- */
@media (max-width: 768px) {
  .column {
    width: 100%;
    border-right: none !important;
  }
  /* On small screens, force labels to stack above inputs */
  .form-field-row {
      display: block !important; /* Stack items vertically */
  }
  .form-field-row .label-container,
  .form-field-row .input-container {
      width: 100% !important; /* Label takes full width */
      min-width: 0 !important;
      text-align: left !important; /* Align label text back to the left */
      padding-right: 0 !important;
  }
  .form-field-row .label-container label {
      margin-bottom: 5px !important; /* Add space below label */
      margin-top: 10px;
  }
  /* Reset special alignment for checkboxes on mobile */
  /* This is no longer necessary with the new structure, but kept for safety */
  #form p input[type="checkbox"] {
      margin-left: 0;
  }
  /* Smaller screens media query from old code */
  @media (max-width: 600px) {
    .modal-content-image {
      width: 100%;
    }
  }
}