/* Reset */
* {
  box-sizing: border-box;
}
html, body {
  margin: 0;
  padding: 0;
  font-family: sans-serif;
  background: #fff;
  color: #333;
}
body {
  /* Omogućeno vertikalno skrolovanje */
  overflow-y: scroll;
}

/* Glavni omotač */
.app-wrap {
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 240px;
  background: #ffffff;
  box-shadow: 2px 0 5px rgba(0,0,0,0.1);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
}

/* Main content */
.main-content {
  margin-left: 240px;
  padding-bottom: 60px; /* prostor za footer */
  padding-top: 10px;
  padding-right: 10px;
  padding-left: 10px;
}

.table-container {
  width: 100%;
  overflow-x: auto;
}

/* Sticky footer (fiksiran) */
footer {
  position: fixed;
  bottom: 0;
  left: 240px;
  right: 0;
  height: 50px;
  background: #eee;
  border-top: 1px solid #ccc;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 10px;
  z-index: 10;
}
.footer-left {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  font-size: 0.9rem;
}
.footer-right {
  display: flex;
  align-items: center;
}
.legend-item {
  display: flex;
  align-items: center;
  gap: 4px;
}
.legend-color {
  width: 14px;
  height: 14px;
  display: inline-block;
  border-radius: 2px;
}
.legend-color.a4 { background: #929292; }
.legend-color.a3 { background: #6A9D5A; }
.legend-color.ploter { background: #4A90A4; }
.legend-color.velike { background: #D45D5D; }
.legend-color.male { background: #8E6FAC; }

/* Drop area */
.drop-area {
  border: 2px dashed #aaa;
  border-radius: 6px;
  padding: 12px;
  text-align: center;
  font-weight: bold;
  color: #555;
  cursor: pointer;
  line-height: 1.4;
  word-wrap: break-word;
}
.drop-area.dragover {
  background: #f0f0f0;
}

/* input-row */
.input-row {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.input-row label {
  font-weight: bold;
  font-size: 0.85rem;
  color: #555;
}
.input-row input,
.input-row select {
  padding: 6px;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 0.85rem;
  color: #333;
}

/* Vrednosti */
.values-frame {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.value-box {
  background: #fafafa;
  border: 1px solid #eee;
  border-radius: 4px;
  padding: 6px;
  text-align: center;
  font-size: 0.85rem;
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.05);
}
.value-box h4 {
  margin: 0 0 4px 0;
  font-size: 0.85rem;
  color: #333;
}
.value-box p {
  margin: 0;
  font-weight: bold;
}
.value-box small {
  display: block;
  margin-top: 2px;
  font-size: 0.75rem;
  color: #666;
}

/* Naslovi sekcija */
.section-title {
  margin: 0;
  font-size: 0.9rem;
  font-weight: bold;
  color: #444;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Kategorije i filteri */
.category-frame,
.filters-frame {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}
.category-frame button,
.filters-frame button {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px;
  font-size: 0.8rem;
  border: 1px solid #444;
  border-radius: 4px;
  background: none;
  color: #444;
  cursor: pointer;
  transition: 0.2s;
}
.category-frame button:hover,
.filters-frame button:hover {
  filter: brightness(1.1);
}
.btn-icon {
  margin-right: 5px;
}
.category-frame button.has-pages {
  background: #444;
  color: #fff;
  border: none;
}
.category-frame button.has-pages .btn-icon {
  color: #fff;
}
.filters-frame button.active {
  background: #444;
  color: #fff;
  border: none;
}
.filters-frame button.active .btn-icon {
  color: #fff;
}

/* Tabela */
table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  margin-bottom: 20px;
  min-width: 600px;
}
thead {
  background: #f0f0f0;
}
th, td {
  padding: 8px;
  text-align: center;
  border-bottom: 1px solid #ddd;
  font-size: 0.85rem;
  white-space: nowrap;
}
th {
  cursor: pointer;
  user-select: none;
  font-weight: bold;
}
tbody tr:hover {
  background: #f9f9f9;
}

/* Boje za kategorije */
tbody tr.A4 { background: #929292; color: #fff; }
tbody tr.A3 { background: #6A9D5A; color: #fff; }
tbody tr.velike { background: #D45D5D; color: #fff; }
tbody tr.male { background: #8E6FAC; color: #fff; }
tbody tr.ploter { background: #4A90A4; color: #fff; }

/* Dugme RESET */
.btn-reset {
  padding: 6px 10px;
  font-size: 0.8rem;
  color: #c42727;
  background: #fff;
  border: 1px solid #c42727;
  border-radius: 4px;
  transition: background 0.2s, color 0.2s;
  cursor: pointer;
}
.btn-reset:hover {
  background: #fdd;
  color: #a31f1f;
}

/* Modal - preview */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.7);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: 10px;
}
.modal-overlay.active {
  display: flex;
}
.modal-content {
  background: #fff;
  border-radius: 6px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  width: 90%;
  max-width: 900px;
  max-height: 100%;
  box-sizing: border-box;
}
.preview-info {
  font-size: 0.9rem;
  font-weight: bold;
  margin-bottom: 10px;
  color: #333;
  text-align: center;
  word-wrap: break-word;
}

/* Ovde stavljamo canvas i scroll panning. 
   Koristimo flex centriranje + transform-origin center. */
.preview-canvas-wrapper {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: auto;
  background: #666;
  border-radius: 4px;
  margin-bottom: 10px;
  cursor: grab; 
  max-height: 650px; /* optional, da ne bude preveliko */
}

.preview-canvas-wrapper:active {
  cursor: grabbing;
}
.preview-canvas-wrapper canvas {
  box-shadow: 0 0 4px rgba(0,0,0,0.3);
  transform-origin: center center;
}

/* Toolbar */
.preview-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}
.preview-toolbar button {
  padding: 6px 10px;
  border: none;
  border-radius: 4px;
  font-weight: 600;
  cursor: pointer;
  background: #999;
  color: #fff;
  transition: background 0.2s;
}
.preview-toolbar button:hover {
  background: #777;
}

/* Responsive - manji ekrani */
@media screen and (max-width: 600px) {
  .sidebar {
    position: static;
    width: auto;
    max-height: none;
    border-bottom: 1px solid #ccc;
    padding: 8px 10px;
  }
  .main-content {
    margin-left: 0;
  }
  footer {
    left: 0;
  }

  /* Sakrij 5. i 6. kolonu (Kategorija, Orjentacija) */
  th:nth-child(5), td:nth-child(5),
  th:nth-child(6), td:nth-child(6) {
    display: none;
  }

  table {
    min-width: 100%;
  }
}
