/* Base reset for consistent printing */
html, body {
  margin: 0;
  padding: 0;
}

body {
  font-family: Arial, sans-serif;
  background: #f5f7fa;
  color: #222;
}

/* Layout: main page */
.container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  padding: 16px;
  align-items: start;
}

@media (max-width: 900px) {
  .container {
    grid-template-columns: 100%;
  }
  .form-row {
    grid-template-columns: 100%;
  }
}

.panel {
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  padding: 16px;
  display: flex;
  flex-direction: column;
}

.panel form {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0; /* important for flex items to scroll */
}

.scroll-content {
  flex: 1;
  overflow-y: auto;
  min-height: 0; /* ensure it doesn't overflow parent */
  padding-right: 8px; /* space for scrollbar */
}

.panel.full {
  grid-column: 1 / -1;
}

.panel h2 {
  margin: 0 0 12px 0;
  font-size: 18px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 8px;
}

label {
  font-size: 12px;
  color: #333;
}

input[type="text"],
input[type="number"],
input[type="password"],
select,
textarea {
  width: 100%;
  padding: 8px;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 14px;
  box-sizing: border-box;
}

textarea {
  min-height: 80px;
}

/* Details / Summary Styles */
details {
  border: 1px solid #ddd;
  border-radius: 4px;
  margin-bottom: 8px;
  background-color: #fff;
  overflow: hidden;
}

summary {
  padding: 10px;
  background-color: #f5f5f5;
  cursor: pointer;
  font-weight: bold;
  list-style: none; /* Hide default triangle */
  position: relative;
}

summary::-webkit-details-marker {
  display: none;
}

summary::after {
  content: '+';
  position: absolute;
  right: 10px;
  font-weight: bold;
  font-size: 16px;
}

details[open] summary::after {
  content: '-';
}

details[open] summary {
  border-bottom: 1px solid #ddd;
}

.form-section {
  padding: 12px;
  border-radius: 0; /* Let details handle radius */
  margin-bottom: 0;
  border: none !important; /* Override zebra striping borders */
  background-color: transparent !important; /* Override zebra striping */
}

/* Remove old zebra striping as we use accordions now */
/*
.form-section:nth-of-type(odd) {
  background-color: #f9f9f9;
}

.form-section:nth-of-type(even) {
  background-color: #ffffff;
  border: 1px solid #eee;
}
*/

hr {
  border: 0;
  border-top: 1px solid #e0e0e0;
  margin: 12px 0;
}

.actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.btn {
  padding: 8px 12px;
  border: 1px solid #888;
  border-radius: 4px;
  background: #f0f0f0;
  cursor: pointer;
}

.btn.primary {
  background: #1976d2;
  border-color: #1976d2;
  color: #fff;
}

.preview-frame {
  width: 100%;
  height: 800px;
  border: 1px solid #ccc;
  border-radius: 8px;
}

/* Print Page Styles */
@page {
  size: A4;
  margin: 0;
}

.page {
  width: 210mm;
  height: 297mm;
  background: #fff;
  box-sizing: border-box;
}

.page-inner {
  box-sizing: border-box;
  width: 100%;
  height: 100%;
}

/* Label grid container */
.label-grid {
  display: grid;
  box-sizing: border-box;
  width: 100%;
  height: 100%;
  grid-auto-rows: max-content;
}

/* Individual grid cell (for visual debugging/preview) */
.grid-cell {
  box-sizing: border-box;
  border: 1px dashed #ddd;
  position: relative; /* label container is relative for absolute children */
  overflow: hidden;   /* prevent text overflow outside label bounds */
}

/* Label content block */
.label-item {
  width: 100%;
  height: 100%;
  box-sizing: border-box;
  position: relative; /* children positioned absolutely inside */
  padding-left: 5mm;
  padding-right: 5mm;
}

.draggable {
  cursor: move;
  user-select: none;
}

.dragging {
  outline: 1px dashed #1976d2;
}

.resizable::after {
  content: '';
  position: absolute;
  right: 0;
  bottom: 0;
  width: 10px;
  height: 10px;
  background: #1976d2;
  cursor: se-resize;
}

.resize-handle {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 10px;
  height: 10px;
  background: #1976d2;
  cursor: se-resize;
}

.label-title {
  max-width: 100%;
  overflow: hidden;
  /* individual styles applied inline */
}

.label-caption {
  max-width: 100%;
  overflow: hidden;
}

.label-description {
  max-width: 100%;
  overflow: hidden;
  line-height: 0.95;
}

.label-additional {
  max-width: 100%;
  overflow: hidden;
}

/* Print adjustments */
@media print {
  body {
    background: #fff;
  }
  .no-print {
    display: none !important;
  }
}
