/* General Body Styles */
body {
  margin: 0;
  padding: 0;
  font-family: sans-serif;
  background-color: #f8f8f8;
}

/* Container & Layout */
.container {
  width: 70%;
  max-width: 1319px;
  margin: 0 auto 30px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.logo {
  display: flex;
  justify-content: center;
}

.logo img {
  max-width: 100%;
  height: auto;
  display: block;
}

.grid-container {
  display: flex;
  flex-direction: column;
  width: 100%;
}

/* Field Styles (Common for individual items) */
.field {
  background-color: white;
  padding: 15px;
  border: 1px solid #ccc;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.field-top {
  text-align: center;
  font-weight: bold;
  margin-bottom: 10px;
}

.field-bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.left-text {
  font-size: 16px;
  color: #333;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: calc(100% - 30px); /* Adjusted for close-btn */
}

.left-text:hover {
  font-weight: bold;
  cursor: pointer;
}

/* Close Button (for fields) */
.close-btn {
  background-color: #ff4d4d;
  border: none;
  color: white;
  padding: 6px 10px;
  font-size: 14px;
  border-radius: 4px;
  cursor: pointer;
}

.close-btn:hover {
  background-color: #cc0000;
}

/* Toast Notifications */
#toast-container {
  position: fixed;
  bottom: 30px;
  right: 30px;
  z-index: 9999;
}

.toast {
  position: absolute;
  background-color: #333;
  color: #fff;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 13px;
  white-space: nowrap;
  z-index: 9999;
  opacity: 0;
  animation: toastFade 1s forwards;
  pointer-events: none;
}

@keyframes toastFade {
  0% {
    opacity: 0;
    transform: translateY(10px);
  }
  10% {
    opacity: 1;
    transform: translateY(0);
  }
  90% {
    opacity: 1;
    transform: translateY(0);
  }
  100% {
    opacity: 0;
    transform: translateY(-10px);
  }
}

/* Modal Overlays (Generic) */
.app-modal-overlay {
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  overflow: auto;
  background-color: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.3s ease-in-out, visibility 0.3s ease-in-out;
}

.app-modal-overlay.is-visible {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.app-modal-content {
  background-color: #fefefe;
  margin: auto;
  padding: 30px;
  border-radius: 8px;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
  width: 90%;
  max-width: 500px;
  position: relative;
  transform: translateY(-20px);
  transition: transform 0.3s ease-in-out;
}

.app-modal-overlay.is-visible .app-modal-content {
  transform: translateY(0);
}

.app-modal-close-icon {
  color: #aaa;
  position: absolute;
  top: 15px;
  right: 25px;
  font-size: 28px;
  font-weight: bold;
  cursor: pointer;
  transition: color 0.2s;
}

.app-modal-close-icon:hover,
.app-modal-close-icon:focus {
  color: #000;
  text-decoration: none;
}

.app-modal-content h2 {
  text-align: center;
  color: #333;
  margin-bottom: 25px;
  font-size: 1.8em;
}

.app-modal-body {
  margin-bottom: 25px;
}

.app-form-group {
  margin-bottom: 15px;
}

.app-form-group label {
  display: block;
  margin-bottom: 8px;
  font-weight: bold;
  color: #555;
}

.app-form-group input[type="number"],
.app-form-group select {
  width: calc(100% - 20px);
  padding: 12px;
  border: 1px solid #ddd;
  border-radius: 5px;
  font-size: 1em;
  box-sizing: border-box;
}

.app-modal-footer {
  text-align: right;
  border-top: 1px solid #eee;
  padding-top: 20px;
}

/* App Config Modal Specific Styles */
#appConfigModal .app-modal-footer .app-modal-action-button {
  padding: 12px 25px;
  border: none;
  border-radius: 5px;
  font-size: 1.1em;
  cursor: pointer;
  transition: background-color 0.2s, color 0.2s;
  margin-left: 10px;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  box-sizing: border-box;
}

#appConfigModal .app-modal-footer .app-modal-action-primary {
  background-color: #007bff;
  color: white;
}

#appConfigModal .app-modal-footer .app-modal-action-primary:hover {
  background-color: #0056b3;
}

#appConfigModal .app-modal-footer .app-modal-action-secondary {
  background-color: #6c757d;
  color: white;
}

#appConfigModal .app-modal-footer .app-modal-action-secondary:hover {
  background-color: #5a6268;
}

/* Button Styles (General & Specific) */
#config-btn {
  background-color: #008cba; /* Blue color */
  color: white;
  transition: background-color 0.3s ease, transform 0.3s ease, box-shadow 0.3s ease;
}

#config-btn:hover {
  background-color: #007bb5; /* Darker blue on hover */
  transform: translateY(-2px); /* Slight lift */
  box-shadow: 0 6px 15px rgba(0, 0, 0, 0.15); /* Larger shadow */
}

#config-btn:active {
  background-color: #006699; /* Even darker blue on click */
  transform: translateY(0); /* Return to original position */
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1); /* Smaller shadow */
}

#generate-btn {
  background-color: #4caf50; /* Green color */
  color: white;
  transition: background-color 0.3s ease, transform 0.3s ease, box-shadow 0.3s ease;
}

#generate-btn:hover {
  background-color: #45a049; /* Darker green on hover */
  transform: translateY(-2px); /* Slight lift */
  box-shadow: 0 6px 15px rgba(0, 0, 0, 0.15); /* Larger shadow */
}

#generate-btn:active {
  background-color: #3e8e41; /* Even darker green on click */
  transform: translateY(0); /* Return to original position */
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1); /* Smaller shadow */
}

/* Footer Styles */
.footer {
  background-color: #333;
  color: #fff;
  text-align: center;
  padding: 20px 0;
  position: relative;
  width: 100%;
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.2);
  font-family: Arial, sans-serif;
  font-size: 1em;
}

.footer p {
  margin: 0;
  font-size: 1.1em;
}

/* Header Row & Info Box */
.header-row {
  display: flex;
  align-items: center;
  background-color: #ffffff;
  padding: 15px 20px;
  border-radius: 12px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.1);
  box-sizing: border-box;
  flex-wrap: nowrap;
  gap: 10px;
  min-height: 70px;
  width: 100%;
}

.info-text {
  flex-grow: 1;
  flex-shrink: 1;
  flex-basis: auto;
  font-size: 1em;
  color: #333;
  line-height: 1.6;
  margin-bottom: 0;
  display: flex;
  align-items: center;
  height: 100%;
}

.info-box {
  background: #f5f5f5;
  padding: 10px 14px;
  border-left: 4px solid #4a90e2;
  border-radius: 8px;
  font-size: 0.95em;
  line-height: 1.6;
  color: #333;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  width: 100%;
}

/* Button Panel */
.button-panel {
  display: flex;
  gap: 15px;
  flex-wrap: nowrap;
  flex-shrink: 0;
  flex-grow: 0;
  flex: 1 1 auto;
}

.button-panel button {
  flex: 1 1 auto;
  max-width: 180px;
  background-color: #007bff;
  color: white;
  border: none;
  padding: 12px 17px;
  font-size: 0.9em;
  cursor: pointer;
  border-radius: 8px;
  transition: background-color 0.3s ease, transform 0.3s ease, box-shadow 0.2s ease;
  display: flex;
  align-items: center;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  white-space: nowrap;
}

.button-panel button:hover {
  background-color: #0056b3;
  transform: translateY(-4px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
}

.button-panel button:active {
  transform: translateY(0);
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.1);
}

/* Export Modal */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
}

.modal.hidden {
  display: none;
}

.modal-content {
  background: #fff;
  padding: 30px;
  border-radius: 10px;
  width: 90%;
  max-width: 500px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
}

.modal-content h2 {
  margin-top: 0;
  font-size: 1.5em;
}

.export-format {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px 20px;
  margin-top: 10px;
}

.export-format label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.95em;
}

.modal-buttons {
  margin-top: 20px;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.modal-buttons button {
  padding: 10px 18px;
  font-size: 1em;
  border-radius: 6px;
  cursor: pointer;
  border: none;
}

#export-confirm {
  background-color: #4caf50; /* Green color */
  color: white;
  transition: background-color 0.3s ease, transform 0.3s ease, box-shadow 0.3s ease;
}

#export-confirm:hover {
  background-color: #45a049; /* Darker green on hover */
  transform: translateY(-2px); /* Slight lift */
  box-shadow: 0 6px 15px rgba(0, 0, 0, 0.15); /* Larger shadow */
}

#export-cancel {
  background-color: #e0e0e0; /* Light gray */
  color: #333; /* Dark gray text */
  transition: background-color 0.25s ease, box-shadow 0.25s ease;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.08);
    transition: background-color 0.3s ease, transform 0.3s ease, box-shadow 0.3s ease;
}

#export-cancel:hover {
  background-color: #cfcfcf; /* Darker gray on hover */
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.12);
  transform: translateY(-2px); /* Slight lift */
}

.export-fields {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px 20px;
  max-height: 300px;
  overflow-y: auto;
  margin-top: 15px;
  padding-right: 5px;
}

.export-fields label {
  background: #f9f9f9;
  padding: 8px 10px;
  border-radius: 6px;
  border: 1px solid #ddd;
  font-size: 0.95em;
}

.uncheck-btn {
  background-color: #007bff;
  color: white;
  padding: 8px 16px;
  font-size: 1rem;
  font-weight: 500;
  border: 1px solid #ccc; /* This border might conflict with background, consider removing or styling */
  border-radius: 8px;
  cursor: pointer;
  transition: background-color 0.25s ease, box-shadow 0.25s ease;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
    transition: background-color 0.3s ease, transform 0.3s ease, box-shadow 0.3s ease;
}

.uncheck-btn:hover {
  background-color: #0056b3;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transform: translateY(-2px); /* Slight lift */
}

.export-filename {
  margin: 15px 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.export-filename label {
  font-weight: 600;
  font-size: 0.95em;
  color: #444;
}

.export-filename input {
  padding: 8px 10px;
  font-size: 0.9em;
  border: 1px solid #ccc;
  border-radius: 6px;
  width: 60%;
  max-width: 250px;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.06);
  transition: border-color 0.2s ease-in-out;
}

.export-filename input:focus {
  border-color: #007bff;
  outline: none;
}

.field-counter {
  margin-top: 8px;
  font-size: 0.9em;
  color: #555;
  font-weight: 500;
  text-align: right;
}

.export-filters {
  margin: 15px 0;
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
  align-items: flex-end;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.filter-group label {
  font-weight: 600;
  font-size: 0.9em;
  color: #444;
}

.filter-group input,
.filter-group select {
  padding: 8px 10px;
  font-size: 0.9em;
  border: 1px solid #ccc;
  border-radius: 6px;
  width: 150px;
  box-sizing: border-box;
}

.case-count {
  margin-top: 15px;
}

.case-count label {
  font-weight: 600;
  font-size: 0.9em;
  color: #444;
}

.case-count input {
  width: 80px;
  padding: 8px 10px;
  font-size: 0.9em;
  border: 1px solid #ccc;
  border-radius: 6px;
  box-sizing: border-box;
}

/* Sections for grouped fields */
.section {
  width: 100%;
  display: flex;
  flex-direction: column;
}

.section h3 {
  font-size: 1.4em;
  color: #333;
  margin-bottom: 20px;
  padding-bottom: 6px;
  border-bottom: 2px solid #ccc;
}

.section-fields {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
}

/* Specific field styling within sections */
.section > .field,
.section-fields > .field {
  display: inline-flex;
  flex-direction: column;
  flex: 1 1 calc((100% - 40px) / 3); /* 3 columns with 20px gap */
  min-width: 300px;
  max-width: 100%;
  height: 90px;
  padding: 10px;
  box-sizing: border-box;
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 8px;
  justify-content: space-between;
}

.section .field-top {
  font-weight: bold;
  font-size: 1.1em;
  margin-bottom: 5px;
  text-align: left; /* Override general .field-top for section fields */
}

.section .field-bottom {
  background: #f9f9f9;
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 1em;
  flex-grow: 1;
  overflow: hidden;
}

/* Media Queries for Responsiveness */
@media (max-width: 1550px) {
  .header-row {
    flex-direction: column;
    align-items: stretch;
    gap: 20px;
  }

  .button-panel {
    flex-wrap: wrap;
    justify-content: flex-start;
    width: 100%;
  }

  .button-panel button {
    flex: 1 1 200px;
    max-width: 100%;
    min-width: 160px;
    justify-content: center;
  }

  .info-text,
  .info-box {
    width: 100%;
  }
}

@media (max-width: 1024px) {
  .section > .field,
  .section-fields > .field {
    flex: 1 1 calc((100% - 20px) / 2); /* 2 columns */
  }
}

@media (max-width: 768px) {
  .footer {
    padding: 5px 0;
    font-size: 0.9em;
  }

  .footer p {
    font-size: 1em;
  }
}

@media (max-width: 640px) {
  .section > .field,
  .section-fields > .field {
    width: 100%;
    min-width: unset; /* Allow it to shrink below 300px on small screens */
  }
}

@media (max-width: 480px) {
  .footer {
    padding: 5px 0;
    font-size: 0.8em;
  }

  .footer p {
    font-size: 0.9em;
  }
}