/* ==========================================================================
   HUB-3A INŽENJERSKI STIL I TISKARSKA PRECIZNOST
   ========================================================================== */

:root {
  --bg-main: #121212;
  --bg-surface: #1e1e1e;
  --bg-border: #2d2d2d;
  --text-primary: #ededed;
  --text-muted: #8e8e93;
  --accent-red: #d32f2f;
  --accent-green: #388e3c;
  --accent-blue: #0288d1;
  --hub-border-color: #d84315; /* Službena crveno-narančasta boja HUB-3A obrasca */
  --hub-bg: #fffbf5;
  --hub-text: #111111;
  
  /* Kalibracijski pomak pisača */
  --offset-x: 0mm;
  --offset-y: 0mm;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body.dark-theme {
  background-color: var(--bg-main);
  color: var(--text-primary);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ================= KONTROLNA TRAKA ================= */
.control-bar {
  background-color: var(--bg-surface);
  border-bottom: 1px solid var(--bg-border);
  padding: 10px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.control-group {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-right: 12px;
}

.logo-hub {
  font-weight: 800;
  font-size: 1.15rem;
  letter-spacing: 0.5px;
  color: #ff5722;
}

.version-badge {
  font-size: 0.7rem;
  background-color: #333;
  padding: 2px 6px;
  border-radius: 4px;
  color: #bbb;
}

.selector-box {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
}

.selector-box select {
  background-color: #2a2a2a;
  border: 1px solid #444;
  color: #fff;
  padding: 6px 10px;
  border-radius: 4px;
  outline: none;
  font-size: 0.85rem;
}

/* Gumbi */
button {
  cursor: pointer;
  border: none;
  border-radius: 4px;
  padding: 7px 14px;
  font-size: 0.85rem;
  font-weight: 600;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-primary {
  background-color: #ff5722;
  color: #fff;
}
.btn-primary:hover { background-color: #f4511e; }

.btn-primary-alt {
  background-color: #2e7d32;
  color: #fff;
}
.btn-primary-alt:hover { background-color: #1b5e20; }

.btn-secondary {
  background-color: #333;
  color: #eee;
  border: 1px solid #444;
}
.btn-secondary:hover { background-color: #444; }

.btn-icon {
  background-color: #2a2a2a;
  color: #eee;
  border: 1px solid #444;
  padding: 6px 10px;
}
.btn-icon:hover { background-color: #3d3d3d; }

/* Padajući izbornik s više opcija */
.dropdown-more {
  position: relative;
  display: inline-block;
}

.dropdown-content {
  display: none;
  position: absolute;
  right: 0;
  background-color: #252525;
  min-width: 180px;
  box-shadow: 0 8px 16px rgba(0,0,0,0.4);
  border: 1px solid #444;
  border-radius: 4px;
  z-index: 1000;
  overflow: hidden;
}

.dropdown-content button,
.dropdown-content .file-label {
  width: 100%;
  text-align: left;
  padding: 10px 14px;
  background: none;
  color: #ddd;
  border-radius: 0;
  display: block;
  font-size: 0.85rem;
  font-weight: normal;
}
.dropdown-content button:hover,
.dropdown-content .file-label:hover { background-color: #333; }

.dropdown-more:hover .dropdown-content { display: block; }

/* Bočna ladica za kalibraciju */
.drawer {
  position: fixed;
  top: 54px;
  right: 0;
  width: 320px;
  background: #1e1e1e;
  border-left: 1px solid #333;
  padding: 20px;
  box-shadow: -4px 0 12px rgba(0,0,0,0.5);
  z-index: 99;
}
.drawer.hidden { display: none; }
.drawer-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.drawer-desc {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 18px;
}
.slider-group {
  margin-bottom: 16px;
}
.slider-group label {
  display: block;
  font-size: 0.85rem;
  margin-bottom: 6px;
}
.slider-group input[type="range"] {
  width: 100%;
}
.full-width { width: 100%; justify-content: center; margin-top: 10px; }

/* ================= RADNI PROSTOR ================= */
.workspace {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 24px 16px;
  overflow-x: auto;
}

/* ================= FOTOREALISTIČNA HUB-3A UPLATNICA ================= */
.slip-container {
  width: 210mm;
  height: 99mm;
  min-width: 210mm;
  min-height: 99mm;
  background-color: var(--hub-bg);
  color: var(--hub-text);
  border: 1px solid #ccc;
  box-shadow: 0 10px 30px rgba(0,0,0,0.6);
  display: flex;
  position: relative;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  user-select: none;
}

.mono-font {
  font-family: "JetBrains Mono", "Courier New", Courier, monospace !important;
  font-weight: 600;
}

/* Perforacija između odreska i naloga */
.perforation-line {
  width: 1px;
  height: 100%;
  border-left: 1px dashed #aaa;
}

/* Lijeva strana: Odrezak (Talon) - točno 58mm širine */
.slip-talon {
  width: 58mm;
  height: 99mm;
  padding: 5mm;
  display: flex;
  flex-direction: column;
  background-color: #fffdf9;
  font-size: 7pt;
}

.section-title {
  font-size: 6.5pt;
  font-weight: 800;
  color: var(--hub-border-color);
  letter-spacing: 0.5px;
  margin-bottom: 3mm;
  text-transform: uppercase;
}

.talon-readonly-text {
  font-size: 7pt;
  line-height: 1.25;
  color: #000;
  min-height: 10mm;
  word-break: break-all;
}

.talon-readonly-text.small {
  min-height: 6mm;
  font-size: 6.5pt;
}

.talon-readonly-value {
  font-size: 9pt;
  font-weight: 800;
  color: #000;
  margin: 1mm 0 2mm 0;
}

.talon-readonly-mono {
  font-family: "JetBrains Mono", monospace;
  font-size: 6.5pt;
  font-weight: 600;
  color: #000;
  min-height: 4mm;
  word-break: break-all;
}

/* Desna strana: Glavni nalog - točno 151mm širine */
.slip-main {
  width: 151mm;
  height: 99mm;
  padding: 4mm 6mm;
  display: flex;
  flex-direction: column;
}

.main-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--hub-border-color);
  padding-bottom: 1.5mm;
  margin-bottom: 2mm;
}

.main-title {
  font-size: 9pt;
  font-weight: 900;
  color: var(--hub-border-color);
  letter-spacing: 0.5px;
}

.currency-indicator {
  font-size: 7pt;
  color: #333;
}

.main-grid {
  display: flex;
  gap: 4mm;
}

.grid-col-left {
  width: 82mm;
  display: flex;
  flex-direction: column;
  gap: 2mm;
}

.grid-col-right {
  width: 59mm;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

/* Okviri unosa */
.input-fieldset {
  border: 1px solid var(--hub-border-color);
  border-radius: 2px;
  padding: 1mm 2mm 1.5mm 2mm;
  position: relative;
}

.input-fieldset legend {
  font-size: 5.5pt;
  font-weight: 700;
  color: var(--hub-border-color);
  text-transform: uppercase;
  padding: 0 1mm;
}

.input-with-counter {
  position: relative;
  display: flex;
  align-items: center;
}

.char-counter {
  position: absolute;
  right: 1mm;
  font-size: 5pt;
  color: #999;
  pointer-events: none;
}

/* Polja unosa u obrascu */
.slip-input {
  width: 100%;
  border: none;
  background: transparent;
  color: #000;
  font-size: 7.5pt;
  line-height: 1.3;
  padding: 0.6mm 0;
  outline: none;
}

.slip-input:focus {
  background-color: rgba(255, 87, 34, 0.08);
}

.uppercase { text-transform: uppercase; }
.text-right { text-align: right; }

/* Iznos */
.amount-container {
  width: 100%;
  border: 1px solid var(--hub-border-color);
  border-radius: 2px;
  padding: 1mm 2mm;
  margin-bottom: 2mm;
  background: #fff;
}

.field-label-bold {
  font-size: 6pt;
  font-weight: 800;
  color: var(--hub-border-color);
  display: block;
}

.amount-input-wrap {
  display: flex;
  align-items: center;
}

.currency-prefix {
  font-size: 9pt;
  font-weight: 700;
  color: #444;
  margin-right: 1mm;
}

.amount-input {
  font-size: 11pt !important;
  font-weight: 800;
  color: #000;
}

/* Barkod okvir */
.barcode-container {
  width: 59mm;
  height: 25mm;
  border: 1px dashed var(--hub-border-color);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  background: #fff;
  padding: 1mm;
  position: relative;
}

#pdf417Canvas {
  max-width: 100%;
  max-height: 21mm;
  image-rendering: pixelated;
}

.barcode-status-text {
  font-size: 4.5pt;
  color: #666;
  text-transform: uppercase;
  margin-top: 0.5mm;
}

/* Donji redovi naloga */
.main-bottom-grid {
  margin-top: 2mm;
  display: flex;
  flex-direction: column;
  gap: 1.5mm;
}

.field-iban {
  border: 1px solid var(--hub-border-color);
  border-radius: 2px;
  padding: 1mm 2mm;
  background: #fff;
}

.input-feedback-wrap {
  display: flex;
  align-items: center;
  position: relative;
}

.status-indicator {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  margin-left: 4px;
}
.status-indicator.valid { background-color: var(--accent-green); }
.status-indicator.invalid { background-color: var(--accent-red); }

.row-model-pnb {
  display: flex;
  gap: 2mm;
}

.field-model {
  width: 20mm;
  border: 1px solid var(--hub-border-color);
  border-radius: 2px;
  padding: 1mm 2mm;
  background: #fff;
}

.field-pnb {
  flex: 1;
  border: 1px solid var(--hub-border-color);
  border-radius: 2px;
  padding: 1mm 2mm;
  background: #fff;
}

.row-purpose-desc {
  display: flex;
  gap: 2mm;
}

.field-purpose {
  width: 40mm;
  border: 1px solid var(--hub-border-color);
  border-radius: 2px;
  padding: 0.8mm 1.5mm;
  background: #fff;
}

.field-desc {
  flex: 1;
  border: 1px solid var(--hub-border-color);
  border-radius: 2px;
  padding: 0.8mm 2mm;
  background: #fff;
}

.field-label {
  font-size: 5.5pt;
  font-weight: 700;
  color: var(--hub-border-color);
  display: block;
}

.validation-error {
  color: var(--accent-red);
  font-size: 5pt;
  font-weight: bold;
  height: 6px;
  margin-top: 1px;
}

/* ================= SIGURNOST I DISCLAIMER ================= */
.safety-section {
  width: 210mm;
  margin-top: 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.critical-warning-box {
  background-color: rgba(211, 47, 47, 0.15);
  border: 1.5px solid var(--accent-red);
  border-radius: 4px;
  padding: 12px 16px;
  color: #ff6b6b;
  font-size: 0.85rem;
  line-height: 1.4;
  font-weight: 700;
  text-transform: uppercase;
}

.legal-disclaimer {
  font-size: 0.72rem;
  color: var(--text-muted);
  line-height: 1.4;
  text-align: justify;
}

/* ==========================================================================
   STRIKTNA PRAVILA ZA ISPIS NA FIZIČKI GOTOV OBRAZAC (@media print)
   ========================================================================== */
@media print {
  @page {
    size: 210mm 99mm;
    margin: 0;
  }

  html, body {
    width: 210mm;
    height: 99mm;
    margin: 0 !important;
    padding: 0 !important;
    background: transparent !important;
  }

  /* Sakrij sve elemente osim same uplatnice */
  .no-print,
  .control-bar,
  .safety-section,
  .char-counter,
  .validation-error,
  .status-indicator,
  .drawer {
    display: none !important;
  }

  .workspace {
    padding: 0 !important;
    margin: 0 !important;
  }

  /* Ukloni sve tvorničke crte i obrube jer već postoje na gotovom papiru */
  .slip-container {
    box-shadow: none !important;
    border: none !important;
    background: transparent !important;
    position: absolute;
    left: var(--offset-x) !important;
    top: var(--offset-y) !important;
  }

  .slip-section,
  .input-fieldset,
  .amount-container,
  .barcode-container,
  .field-iban,
  .field-model,
  .field-pnb,
  .field-purpose,
  .field-desc,
  .perforation-line,
  .main-header-row {
    border: none !important;
    background: transparent !important;
  }

  .section-title,
  .main-title,
  .currency-indicator,
  .field-label,
  .field-label-bold,
  .currency-prefix,
  .barcode-status-text,
  legend {
    visibility: hidden !important; /* Sakrij naslove i kućice */
  }

  /* Podaci moraju biti oštri, crni i točno u kućicama */
  .slip-input,
  .talon-readonly-text,
  .talon-readonly-value,
  .talon-readonly-mono {
    color: #000 !important;
    font-weight: bold !important;
    background: transparent !important;
  }

  #pdf417Canvas {
    visibility: visible !important;
  }
}
