/* Root variables for poster dimensions and ratio */
:root {
  --poster-width: 42in;
  --poster-height: 36in;
  --side-ratio: 1;
  --middle-ratio: 2;
  --primary-color: #000000;
  --text-light: #ffffff;
  --text-dark: #000000;
  --side-bg-color: #ffffff;
  --border-color: #dddddd;
  --section-gap: 1rem;
  --panel-padding: 1.5rem;
  --main-finding-font-size: 1.6rem;
  --poster-title-font-size: 1rem;
  --section-header-font-size: 1rem;
  --body-text-font-size: 0.6rem;
  --authors-font-size: 0.6rem;
  --affiliation-font-size: 0.6rem;
  --list-item-font-size: 0.6rem;
  --subheader-font-size: 0.5rem;
  --figure-caption-font-size: 0.6rem;
  --main-finding-color: #ffffff;
  --poster-title-color: #000000;
  --section-header-color: #000000;
  --body-text-color: #000000;
  --authors-color: #000000;
  --affiliation-color: #000000;
  --list-item-color: #000000;
  --figure-caption-color: #000000;
  --qr-code-dark: #000000;
  --qr-code-light: #ffffff;
  --qr-label-color: #ffffff;
}

/* Global font */
body, input, button, select, textarea {
  font-family: 'Ubuntu', sans-serif;
  box-sizing: border-box;
}
body {
  margin: 0;
  padding: 0;
}

/* Layout */
.app-container {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* Control panel */
.controls {
  width: 320px;
  padding: 1rem;
  overflow-y: auto;
  background: #f8f8f8;
  border-right: 1px solid #ddd;
  height: 100vh;
  flex-shrink: 0;
  position: relative;
  scrollbar-width: thin;
  scrollbar-color: #888 #f1f1f1;
  padding-bottom: 3.2rem;
  z-index: 1;
}
.controls::-webkit-scrollbar {
  width: 8px;
}
.controls::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 4px;
}
.controls::-webkit-scrollbar-thumb {
  background: #888;
  border-radius: 4px;
}
.controls::-webkit-scrollbar-thumb:hover {
  background: #555;
}
.controls h1 {
  margin-top: 0;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border-color);
}
.controls fieldset {
  margin-bottom: 1rem;
  border: 1px solid #ccc;
  padding: 0.5rem;
  border-radius: 4px;
}
.controls legend {
  font-weight: 700;
  padding: 0 0.5rem;
}
.controls label {
  display: block;
  margin: 0.5rem 0;
  font-size: 0.9rem;
}
.controls input[type="text"],
.controls input[type="number"],
.controls textarea,
.controls input[type="color"] {
  width: 100%;
  padding: 0.4rem;
  border: 1px solid #ccc;
  border-radius: 3px;
  margin-top: 0.25rem;
}
.controls textarea {
  resize: vertical;
  min-height: 60px;
}
.controls .export-buttons {
  display: flex;
  gap: 0.75rem;
  margin: 1.5rem 0;
}
.controls button {
  flex: 1;
  padding: 0.75rem;
  cursor: pointer;
  background: var(--primary-color);
  color: var(--text-light);
  border: none;
  border-radius: 4px;
  font-weight: bold;
  transition: background 0.2s;
}
.controls button:hover {
  background: #333;
}

/* Overflow warning styles */
.overflow-warning {
  background-color: #ffeeee;
  color: #d32f2f;
  padding: 0.5rem;
  margin: 0.25rem 0;
  border-radius: 3px;
  font-size: 0.8rem;
  border-left: 3px solid #d32f2f;
  animation: pulse 2s infinite;
  position: absolute;
  z-index: 100;
  box-shadow: 0 2px 5px rgba(0,0,0,0.2);
  max-width: 200px;
  pointer-events: none; /* Allow clicking through the warning */
}

.overflow-warning.left-panel {
  left: 100%;
  top: 50%;
  transform: translateY(-50%);
  margin-left: 10px;
}

.overflow-warning.right-panel {
  right: 100%;
  top: 50%;
  transform: translateY(-50%);
  margin-right: 10px;
}

.overflow-warning.middle-panel {
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  margin-top: 10px;
}

@keyframes pulse {
  0% { opacity: 0.8; }
  50% { opacity: 1; }
  100% { opacity: 0.8; }
}

/* Font size controls styles */
input[type="range"] {
  width: 70%;
  vertical-align: middle;
}
span[id$="FontSizeValue"] {
  display: inline-block;
  width: 20%;
  text-align: right;
  font-size: 0.8rem;
  color: #666;
}

/* Poster preview canvas */
.poster-preview {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  background: #eaeaea;
  overflow: auto;
  padding: 2rem;
}
.panel-container {
  background: #fff;
  width: calc(var(--poster-width) / 5); /* Scale down for preview */
  height: calc(var(--poster-height) / 5);
  display: flex;
  box-shadow: 0 0 15px rgba(0,0,0,0.2);
  flex-shrink: 0;
}

/* Panels */
.panel {
  overflow: hidden; /* Hide overflow instead of scrolling */
  box-sizing: border-box;
}
.panel.middle {
  flex: var(--middle-ratio);
  color: var(--text-light);
  padding: var(--panel-padding);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  position: relative; /* Make middle panel relative for QR positioning */
}

/* Restore side panel ratio behavior */
.side {
  flex: var(--side-ratio);
  background-color: var(--side-bg-color);
  padding: var(--panel-padding);
}

/* Side panel content */
.side-content {
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden; /* Changed from auto to hidden to prevent scrolling */
  padding-right: 5px;
}
.side-content .section {
  margin-bottom: 0.5rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border-color);
  overflow: hidden; /* Ensure sections don't scroll internally */
}
.side-content .section:last-child {
  border-bottom: none;
}
.side-content h2 {
  font-size: var(--subheader-font-size);
  margin: 0.4rem 0;
  font-weight: bold;
  color: var(--section-header-color);
}
.side-content .poster-title-section h1 {
  font-size: var(--poster-title-font-size);
  margin: 0 0 0.5rem 0;
  color: var(--poster-title-color);
}
.side-content .authors {
  font-size: var(--authors-font-size);
  font-style: italic;
  color: var(--authors-color);
}
.side-content .affiliation {
  font-size: var(--affiliation-font-size);
  margin-bottom: 0.5rem;
  color: var(--affiliation-color);
}

/* Affiliation specific font size */
.side-content .poster-title-section .affiliation p {
  font-size: var(--affiliation-font-size);
}

/* Section content */
.side-content .section > div:not(.figure-block) {
  font-size: var(--body-text-font-size);
  line-height: 1.3;
  color: var(--body-text-color);
}

.side-content .section li {
  font-size: var(--list-item-font-size);
  line-height: 1.4;
}

.side-content .section h3, 
.side-content .section .subheader {
  font-size: var(--subheader-font-size);
  margin: 0.8rem 0 0.3rem 0;
  font-weight: bold;
}

.figure-block {
  margin: 0.5rem 0;
}

/* Results section styling */
#previewResults ul {
  padding-left: 1.5rem;
  margin: 0.5rem 0;
}
#previewResults li {
  margin-bottom: 0.25rem;
}

/* Figures */
.figures {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.figure-container {
  text-align: center;
}
.figure-image {
  margin-bottom: 0.5rem;
  background-size: contain;
  background-position: center;
  background-repeat: no-repeat;
  min-height: 120px;
}
.figure-title {
  font-size: var(--subheader-font-size);
  font-weight: bold;
  color: var(--section-header-color);
}
.figure-caption {
  font-size: var(--figure-caption-font-size);
  color: var(--figure-caption-color);
}

/* Middle panel styling */
.middle-content {
  width: 90%;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  text-align: center;
  overflow: hidden;
}
#mainFinding {
  font-size: var(--main-finding-font-size);
  font-weight: bold;
  margin: auto 0;
  line-height: 1.2;
  overflow: hidden;
  color: var(--main-finding-color);
}
.main-image-container {
  margin: 1rem 0;
  background-size: contain;
  background-position: center;
  background-repeat: no-repeat;
  height: 30%;
}
.qr-container {
  margin-top: auto;
  text-align: center;
  position: relative;
}
#qrLabelText {
  margin-bottom: 0.5rem;
  font-size: var(--qr-label-font-size);
  color: var(--qr-label-color);
}

/* QR positioning classes */
.qr-pos-bottom-left { position: absolute; bottom: 10px; left: 10px; }
.qr-pos-bottom-center { position: absolute; bottom: 10px; left: 50%; transform: translateX(-50%); }
.qr-pos-bottom-right { position: absolute; bottom: 10px; right: 10px; }

/* Label positioning uses same classes */
.qr-label-pos-bottom-left { position: absolute; bottom: 10px; left: 10px; }
.qr-label-pos-bottom-center { position: absolute; bottom: 10px; left: 50%; transform: translateX(-50%); }
.qr-label-pos-bottom-right { position: absolute; bottom: 10px; right: 10px; }

/* Middle panel figure styles */
#mainImageContainer {
  position: relative;
  width: 100%;
  height: 300px; /* adjust as needed */
  overflow: hidden;
}
#mainImageContainer img {
  position: absolute;
  top: 0;
  left: 0;
  max-width: 100%;
  max-height: 100%;
  cursor: move;
}

/* Make QR and label draggable */
#middlePanel {
  position: relative;
}
#qrContainer {
  position: absolute;
  bottom: 10px;
  left: 10px;
  cursor: move;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
}

#qrLabelText {
  font-size: var(--subheader-font-size) !important; /* Match subheader size */
  margin-bottom: 5px;
  text-align: center;
  color: var(--qr-label-color);
  font-weight: normal;
  line-height: 1.2;
  width: 100%;
  word-wrap: break-word;
}

/* Responsive adjustments */
@media (max-width: 1024px) {
  .app-container {
    flex-direction: column;
  }
  .controls {
    width: 100%;
    height: auto;
    max-height: 40vh;
  }
}

/* Color picker styles */
.section-color-picker {
  display: inline-block;
  width: 20px;
  height: 20px;
  vertical-align: middle;
  margin-left: 5px;
}

/* Color picker squares */
.controls input[type="color"],
#qrSettings input[type="color"] {
  width: 20px;
  height: 20px;
  padding: 0;
  border: none;
}

/* Utility to hide sections */
.hidden-section {
  display: none !important;
}

/* Override affiliation container paragraphs */
#previewAffiliation p {
  font-size: var(--affiliation-font-size);
  color: var(--affiliation-color);
  margin: 0;
}

/* Custom section styles */
.custom-section-control {
  margin-bottom: 1rem;
  padding: 0.5rem;
  background: #f5f5f5;
  border-radius: 4px;
}

.custom-section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.custom-section-header input[type="text"] {
  flex: 1;
  margin-right: 1rem;
}

.custom-section-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.custom-section-control textarea {
  width: 100%;
  min-height: 100px;
  margin-top: 0.5rem;
}

.custom-section-control .section-visibility {
  margin-right: 0.25rem;
}

.custom-section-control .removeSection {
  padding: 0.25rem 0.5rem;
  background: #ff4444;
  color: white;
  border: none;
  border-radius: 3px;
  cursor: pointer;
  font-size: 0.8rem;
}

.custom-section-control .removeSection:hover {
  background: #cc0000;
}

/* Section visibility controls */
.section-visibility-controls {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.section-visibility-controls label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
}

.section-visibility-controls input[type="checkbox"] {
  margin: 0;
}

/* Hidden section animation */
.hidden-section {
  display: none !important;
}

/* Override affiliation container paragraphs */
#previewAffiliation p {
  font-size: var(--affiliation-font-size);
  color: var(--affiliation-color);
  margin: 0;
}

/* Section Management Styles */
.section-visibility-controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 12px;
}

.hidden-section {
  display: none !important;
}

.add-section-btn {
  width: 100%;
  padding: 8px;
  background: #4CAF50;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  margin-top: 8px;
}

.add-section-btn:hover {
  background: #45a049;
}

.custom-section-control {
  margin: 12px 0;
  padding: 12px;
  border: 1px solid #ddd;
  border-radius: 4px;
  background: #f9f9f9;
}

.custom-section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.custom-section-header input[type="text"] {
  flex: 1;
  margin-right: 12px;
  padding: 4px 8px;
}

.custom-section-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.removeSection {
  background: #ff4444;
  color: white;
  border: none;
  border-radius: 4px;
  padding: 4px 8px;
  cursor: pointer;
}

.removeSection:hover {
  background: #cc0000;
}

.custom-section-control textarea {
  width: 100%;
  min-height: 100px;
  padding: 8px;
  margin-top: 8px;
  resize: vertical;
}

/* Smooth transitions for section visibility */
.section {
  transition: opacity 0.3s ease;
}

.section.hidden-section {
  opacity: 0;
  height: 0;
  margin: 0;
  padding: 0;
  overflow: hidden;
}

/* Enable scrolling in side panels to view all sections including figures */
.panel.side {
  overflow-y: auto;
}

/* Hide old figure containers */
.section.figures {
  display: none !important;
}

/* Gradient controls button spacing */
#gradientPicker button {
  margin-right: 0.5rem;
  margin-top: 0.5rem;
}

/* Fixed site title top-right */
#fixedSiteTitle {
  position: fixed;
  top: 10px;
  right: 20px;
  margin: 0;
  font-size: 1.5rem;
  z-index: 1000;
  color: var(--text-dark);
}

/* Sidebar footer fixed to bottom */
#sidebar-footer {
  position: static;
  width: 100%;
  margin-top: 1.5rem;
  margin-bottom: 1.5rem;
  padding: 0.7rem 0 0.7rem 0;
  background: #fff;
  text-align: center;
  color: #222;
  font-weight: 500;
  border-top: 1px solid #e2e2e2;
  border-bottom: 1px solid #e2e2e2;
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
}
#sidebar-footer.visible {
  opacity: 1;
  pointer-events: auto;
}

