:root {
  --bg-main: #121212;
  --bg-surface: #1e1e1e;
  --bg-border: #2d2d2d;
  --text-primary: #ededed;
  --text-muted: #8e8e93;
  --accent-red: #d32f2f;
  --accent-green: #388e3c;
  --hub-border-color: #d84315;
  --hub-bg: #fffbf5;
  --hub-text: #111111;
}

* {
  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;
}

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-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; }

.safari-db-group { display: inline-flex; gap: 6px; }

.file-upload-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  border-radius: 4px;
}

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

/* UPLATNICA NA ZASLONU (Proširena na 960px radi 50% većeg barkoda) */
.slip-container {
  width: 960px;
  max-width: 96vw;
  background-color: var(--hub-bg);
  color: var(--hub-text);
  border: 1px solid #ccc;
  border-radius: 4px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.6);
  display: flex;
  position: relative;
  user-select: none;
}

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

.perforation-line {
  width: 1px;
  border-left: 1px dashed #aaa;
}

/* LIJEVA STRANA (TALON) */
.slip-talon {
  width: 250px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  background-color: #fffdf9;
  font-size: 8pt;
}

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

.talon-readonly-text {
  font-size: 8pt;
  line-height: 1.3;
  color: #000;
  min-height: 36px;
  word-break: break-all;
}
.talon-readonly-text.small { min-height: 24px; font-size: 7.5pt; }
.talon-readonly-value { font-size: 11pt; font-weight: 800; color: #000; margin: 4px 0 8px 0; }
.talon-readonly-mono { font-family: monospace; font-size: 7.5pt; font-weight: 600; color: #000; min-height: 16px; word-break: break-all; }

/* DESNA STRANA (GLAVNI NALOG) */
.slip-main {
  flex: 1;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
}

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

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

.currency-indicator { font-size: 8.5pt; color: #333; }
.main-grid { display: flex; gap: 16px; }

/* Platitelj i Primatelj */
.grid-col-left {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Iznos i Veliki Barkod */
.grid-col-right {
  width: 360px; /* Širok stupac za veliki barkod */
  display: flex;
  flex-direction: column;
  align-items: stretch;
}

.input-fieldset {
  border: 1px solid var(--hub-border-color);
  border-radius: 3px;
  padding: 6px 10px;
  position: relative;
}

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

.input-with-counter { position: relative; display: flex; align-items: center; }
.char-counter { position: absolute; right: 4px; font-size: 6pt; color: #999; pointer-events: none; }

.slip-input {
  width: 100%;
  border: none;
  background: transparent;
  color: #000;
  font-size: 8.5pt;
  line-height: 1.35;
  padding: 3px 0;
  outline: none;
}
.slip-input:focus { background-color: rgba(255, 87, 34, 0.08); }
.uppercase { text-transform: uppercase; }
.text-right { text-align: right; }

.amount-container {
  width: 100%;
  border: 1px solid var(--hub-border-color);
  border-radius: 3px;
  padding: 6px 10px;
  margin-bottom: 8px;
  background: #fff;
}

.field-label-bold { font-size: 7pt; font-weight: 800; color: var(--hub-border-color); display: block; }
.amount-input-wrap { display: flex; align-items: center; }
.currency-prefix { font-size: 11pt; font-weight: 700; color: #444; margin-right: 4px; }
.amount-input { font-size: 13pt !important; font-weight: 800; color: #000; }

/* ================= 50% VEĆI BARKOD OKVIR ================= */
.barcode-container-large {
  width: 100%;
  min-height: 165px; /* 50% viši i masivniji okvir */
  border: 1.5px solid var(--hub-border-color);
  border-radius: 4px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  background: #ffffff;
  padding: 8px;
  box-shadow: inset 0 0 6px rgba(0,0,0,0.06);
}

#pdf417Canvas {
  width: 100%;
  max-width: 344px;
  height: auto;
  max-height: 145px; /* Prikaz u punoj veličini bez sužavanja */
  display: block;
  image-rendering: -webkit-optimize-contrast;
  image-rendering: pixelated; /* Kristalna oštrina piksela bez blur efekta */
}

.barcode-status-text {
  font-size: 6.5pt;
  font-weight: 700;
  color: #666;
  text-transform: uppercase;
  margin-top: 6px;
  text-align: center;
}

/* Donji dio uplatnice */
.main-bottom-grid {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

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

.input-feedback-wrap { display: flex; align-items: center; position: relative; }
.status-indicator { width: 14px; height: 14px; border-radius: 50%; margin-left: 6px; }
.status-indicator.valid { background-color: var(--accent-green); }
.status-indicator.invalid { background-color: var(--accent-red); }

.row-model-pnb { display: flex; gap: 8px; }
.field-model { width: 90px; border: 1px solid var(--hub-border-color); border-radius: 3px; padding: 6px 10px; background: #fff; }
.field-pnb { flex: 1; border: 1px solid var(--hub-border-color); border-radius: 3px; padding: 6px 10px; background: #fff; }

.row-purpose-desc { display: flex; gap: 8px; }
.field-purpose { width: 170px; border: 1px solid var(--hub-border-color); border-radius: 3px; padding: 6px 8px; background: #fff; }
.field-desc { flex: 1; border: 1px solid var(--hub-border-color); border-radius: 3px; padding: 6px 10px; background: #fff; }
.field-label { font-size: 6.5pt; font-weight: 700; color: var(--hub-border-color); display: block; }

.validation-error { color: var(--accent-red); font-size: 6.5pt; font-weight: bold; height: 8px; margin-top: 2px; }

/* SIGURNOST */
.safety-section { width: 960px; max-width: 96vw; 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; }

/* ================= RESPONZIVNOST ZA MOBITELE I TABLETE ================= */
@media screen and (max-width: 900px) {
  .control-bar { flex-direction: column; align-items: stretch; padding: 12px; }
  .control-group { flex-direction: column; align-items: stretch; width: 100%; gap: 8px; }
  .brand { justify-content: center; margin-bottom: 4px; }
  .selector-box { width: 100%; }
  .selector-box select { flex: 1; }
  .actions-right { margin-top: 6px; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  .actions-right button, .safari-db-group, .file-upload-btn { width: 100%; justify-content: center; }
  .safari-db-group { display: contents; }
  .workspace { padding: 8px; overflow-x: hidden; }

  .slip-container {
    width: 100% !important; max-width: 100% !important; flex-direction: column; box-shadow: 0 4px 12px rgba(0,0,0,0.4);
  }
  .slip-talon, .perforation-line { display: none !important; }
  .slip-main { width: 100% !important; padding: 12px; }
  .main-grid { flex-direction: column; gap: 12px; }
  .grid-col-left, .grid-col-right { width: 100% !important; align-items: stretch; }
  .amount-container { margin-bottom: 12px; }
  .amount-input { font-size: 14pt !important; }

  .barcode-container-large {
    width: 100% !important;
    min-height: 155px;
    padding: 10px;
  }
  #pdf417Canvas {
    width: 100% !important;
    max-width: 100% !important;
    max-height: 140px;
  }

  .row-model-pnb, .row-purpose-desc { flex-direction: column; gap: 8px; }
  .field-model, .field-purpose { width: 100% !important; }
  .slip-input { font-size: 11pt; padding: 6px 0; }
  .safety-section { width: 100% !important; padding: 0 4px; }
}

@media print {
  body { display: none !important; }
}
