/* Playfair Display — bold (naslov, iznosi) */
@font-face {
  font-family: 'Playfair Display';
  src: url('./fonts/PlayfairDisplay-Bold.woff2') format('woff2');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

/* Source Sans 3 — regular */
@font-face {
  font-family: 'Source Sans 3';
  src: url('./fonts/SourceSans3-Regular.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

/* Source Sans 3 — semibold */
@font-face {
  font-family: 'Source Sans 3';
  src: url('./fonts/SourceSans3-Semibold.woff2') format('woff2');
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}

:root {
  --red:         #e8394f;
  --red-dim:     #b02a3c;
  --red-pale:    #1e0a0e;
  --red-border:  #3d1520;
  --bg:          #0f0f0f;
  --surface:     #161616;
  --line:        #272727;
  --text:        #e8e0e1;
  --text-mid:    #a08088;
  --text-muted:  #5a4448;
}

*, *::before, *::after {
  box-sizing: border-box;
}

body {
  font-family: 'Source Sans 3', system-ui, sans-serif;
  margin: 0;
  padding: 48px 24px;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
}

.card {
  max-width: 900px;
  margin: auto;
  background: var(--surface);
  border-top: 2px solid var(--red);
  padding: 40px 48px 44px;
}

.card::before {
  display: none;
}

h1 {
  font-family: 'Source Sans 3', system-ui, sans-serif;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin: 0 0 32px;
}

.description, .amount-note, .footer-note {
  color: var(--text-muted);
  font-size: 15px;
  line-height: 1.6;
}

.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 0;
}

label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin: 0 0 6px;
  color: var(--text-muted);
}

input, select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 0;
  font-size: 17px;
  font-family: 'Source Sans 3', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  transition: border-color .15s;
  appearance: none;
  -webkit-appearance: none;
}

select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%235a4448' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}

input:focus, select:focus {
  outline: none;
  border-color: var(--red);
}

input[aria-invalid="true"],
select[aria-invalid="true"] {
  border-color: var(--red);
  background: var(--red-pale);
}

.actions-cell {
  display: flex;
  flex-direction: column;
}

.actions-cell label {
  visibility: visible;
}

.actions {
  display: flex;
  flex-direction: row;
  gap: 8px;
}

.actions button {
  flex: 1;
}

button {
  padding: 10px 12px;
  border: 1px solid transparent;
  border-radius: 0;
  cursor: pointer;
  font-family: 'Source Sans 3', system-ui, sans-serif;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  transition: background .15s, color .15s, border-color .15s;
}

#calcBtn {
  background: var(--red);
  color: #fff;
}

#calcBtn:hover {
  background: var(--red-dim);
}

#calcBtn:active {
  background: #8a1f2e;
}

#resetBtn {
  background: transparent;
  color: var(--text-muted);
  border-color: var(--line);
}

#resetBtn:hover {
  border-color: var(--text-muted);
  color: var(--text);
}

.results {
  margin-top: 40px;
  border-top: 1px solid var(--line);
}

.row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
  padding: 11px 0;
  border-bottom: 1px solid var(--line);
  transition: background .1s;
}

.row:last-child {
  border-bottom: none;
  padding-top: 16px;
  margin-top: 4px;
}

.row:hover {
  background: none;
}

.k {
  color: var(--text-muted);
  font-size: 15px;
}

.v {
  font-weight: 600;
  font-size: 17px;
  color: var(--text);
  font-family: 'Source Sans 3', system-ui, sans-serif;
  white-space: nowrap;
  letter-spacing: 0.01em;
}

.row:last-child .k {
  color: var(--text-mid);
  font-weight: 600;
  font-size: 15px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.row:last-child .v {
  color: var(--red);
  font-size: 22px;
  font-weight: 700;
}

code {
  background: var(--red-pale);
  color: var(--red);
  padding: 1px 5px;
  font-size: 13px;
  border: 1px solid var(--red-border);
}

.error {
  margin-top: 12px;
  color: var(--red);
  font-size: 15px;
  line-height: 1.5;
}

.footer-note {
  margin-top: 32px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}

.amount-note {
  margin-top: 6px;
}

.description strong, .amount-note strong, .footer-note strong {
  color: var(--text-mid);
  font-weight: 600;
}

a {
  color: var(--red);
  text-decoration: underline;
  text-decoration-color: var(--red-border);
  text-underline-offset: 3px;
  transition: color .15s, text-decoration-color .15s;
}

a:hover {
  color: #ff6070;
  text-decoration-color: var(--red);
}

.description {
  margin-bottom: 32px;
}

@media (max-width: 640px) {
  body {
    padding: 0;
  }

  .card {
    padding: 24px 20px 32px;
  }

  h1 {
    margin-bottom: 24px;
  }

  .grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .actions-cell label {
    display: none;
  }

  .row {
    flex-wrap: wrap;
    gap: 4px;
  }

  .k {
    flex: 1 1 100%;
  }

  .v {
    flex: 1 1 100%;
    text-align: right;
  }
}

/* ============================================================
   PRINT STYLES
   ============================================================ */
@media print {

  :root {
    --red-deep:    #7a0c1e;
    --red-mid:     #b01a2e;
    --red-bright:  #d42b42;
    --red-light:   #f5c6cc;
    --red-pale:    #fdf1f3;
    --card-bg:     #ffffff;
    --text-dark:   #1a0a0d;
    --text-mid:    #5a2d35;
    --text-muted:  #666666;
    --border:      #e8c8cc;
  }

  @page {
    size: A4 portrait;
    margin: 10mm 12mm;
  }

  html, body {
    background: #fff !important;
    margin: 0;
    padding: 0;
    font-size: 9pt;
    color: #000;
  }

  .card {
    box-shadow: none !important;
    border-top: 3pt solid #b01a2e !important;
    background: #fff !important;
    border-radius: 0;
    padding: 0;
    max-width: 100%;
  }

  .card::before {
    display: none;
  }

  /* Hide everything except title and results */
  .grid,
  .actions-cell,
  .actions,
  .amount-note,
  .description,
  .footer-note,
  #status {
    display: none !important;
  }

  h1 {
    font-size: 14pt !important;
    line-height: 1.2;
    margin: 0 0 6pt !important;
    color: #7a0c1e;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .results {
    margin-top: 4pt;
    border-top: 1pt solid #e8c8cc;
    padding-top: 4pt;
  }

  .row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding: 2.5pt 4pt;
    break-inside: avoid;
  }

  .row:hover {
    background: none;
  }

  .row:not(:last-child) {
    border-bottom: 0.5pt solid #e8c8cc;
  }

  .row:last-child {
    margin-top: 3pt;
    background: #fdf1f3 !important;
    border-top: 1pt solid #f5c6cc;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .k {
    font-size: 8.5pt !important;
    color: #444;
  }

  .v {
    font-size: 10pt !important;
    font-weight: 700;
    color: #7a0c1e;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .row:last-child .v {
    font-size: 11pt !important;
    color: #b01a2e;
  }

  a::after {
    content: none !important;
  }
}

/* ── Custom dropdowns ───────────────────────────────────────── */
.custom-select {
  position: relative;
  width: 100%;
  user-select: none;
}

.custom-select__trigger {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 0;
  font-size: 17px;
  font-family: 'Source Sans 3', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
  box-sizing: border-box;
  transition: border-color .15s;
}

.custom-select__trigger:focus {
  outline: none;
  border-color: var(--red);
}

.custom-select.is-open .custom-select__trigger {
  border-color: var(--red);
  border-bottom-color: transparent;
}

.custom-select__arrow {
  width: 10px;
  height: 6px;
  flex-shrink: 0;
  margin-left: 10px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%235a4448' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: center;
  transition: transform .15s;
}

.custom-select.is-open .custom-select__arrow {
  transform: rotate(180deg);
}

.custom-select__listbox {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 100;
  margin: 0;
  padding: 0;
  list-style: none;
  background: var(--surface);
  border: 1px solid var(--red);
  border-top: none;
  max-height: 280px;
  overflow-y: auto;
  display: none;
}

.custom-select.is-open .custom-select__listbox {
  display: block;
}

.custom-select__option {
  padding: 9px 12px;
  font-size: 16px;
  font-family: 'Source Sans 3', system-ui, sans-serif;
  color: var(--text-mid);
  cursor: pointer;
  transition: background .1s, color .1s;
  border-bottom: 1px solid var(--line);
}

.custom-select__option:last-child {
  border-bottom: none;
}

.custom-select__option:hover {
  background: var(--red-pale);
  color: var(--text);
}

.custom-select__option.is-selected {
  color: var(--text);
  font-weight: 600;
}

.custom-select__option.is-selected::before {
  content: '— ';
  color: var(--red);
  font-size: 0.9em;
}

/* Hide native selects from print too */
@media print {
  .custom-select { display: none !important; }
}

#taxPp {
  width: 80px;
  flex: 0 0 80px;
  text-align: center;
}

/* ── Izvedeni staž ──────────────────────────────────────────── */
.staz {
  margin-top: 32px;
}

.staz-section {
  border-top: 1px solid var(--line);
  padding-top: 20px;
}

.staz-heading {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.staz-note {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 6px;
}

::selection {
  background: var(--red);
  color: #fff;
}
