@import url("https://fonts.googleapis.com/css2?family=Marck+Script&display=swap");

body {
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  background-color: #f3f4f6;
  color: #1f2937;
}

.tab-btn {
  transition: all 0.2s;
}
.tab-btn.active-plan {
  background-color: #f0fdf4;
  color: #15803d;
  border-bottom: 3px solid #16a34a;
  font-weight: bold;
}
.tab-btn.active-unos {
  background-color: #eff6ff;
  color: #1d4ed8;
  border-bottom: 3px solid #2563eb;
  font-weight: bold;
}
.tab-btn.active-izvestaj {
  background-color: #eff6ff;
  color: #1d4ed8;
  border-bottom: 3px solid #2563eb;
  font-weight: bold;
}
.tab-btn.active-radnici {
  background-color: #faf5ff;
  color: #6b21a8;
  border-bottom: 3px solid #9333ea;
  font-weight: bold;
}
.tab-btn.active-baza {
  background-color: #eef2ff;
  color: #4338ca;
  border-bottom: 3px solid #4f46e5;
  font-weight: bold;
}
.tab-btn.active-analitika {
  background-color: #f0fdfa;
  color: #0f766e;
  border-bottom: 3px solid #00a498;
  font-weight: bold;
}
.tab-btn.active-skart {
  background-color: #fef2f2;
  color: #b91c1c;
  border-bottom: 3px solid #dc2626;
  font-weight: bold;
}
.tab-btn.active-listici {
  background-color: #f0fdfa;
  color: #0f766e;
  border-bottom: 3px solid #00a498;
  font-weight: bold;
}

.tab-content {
  display: none;
  animation: fadeIn 0.3s;
}
.tab-content.active {
  display: block;
}
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

#toast {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 50;
  padding: 1rem 1.5rem;
  border-radius: 0.5rem;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
  display: none;
  align-items: center;
  gap: 0.75rem;
  font-weight: 500;
  animation: slideIn 0.3s;
}
@keyframes slideIn {
  from {
    transform: translateY(-100%);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}
.toast-success {
  background-color: #dcfce7;
  color: #166534;
  border: 1px solid #bbf7d0;
}
.toast-error {
  background-color: #fee2e2;
  color: #991b1b;
  border: 1px solid #fecaca;
}

.date-picker-wrapper {
  position: relative;
}
.custom-calendar {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  z-index: 100;
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 0.5rem;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
  padding: 1rem;
  width: 280px;
  margin-top: 0.25rem;
}
.custom-calendar.show {
  display: block;
}
.calendar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  font-weight: 600;
}
.calendar-nav {
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  border-radius: 0.25rem;
  user-select: none;
  border: 1px solid #e5e7eb;
}
.calendar-nav:hover {
  background-color: #f3f4f6;
}
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 0.25rem;
  text-align: center;
}
.calendar-day-header {
  font-size: 0.75rem;
  font-weight: 600;
  color: #6b7280;
  padding-bottom: 0.5rem;
  user-select: none;
}
.calendar-day {
  padding: 0.35rem 0.25rem;
  border-radius: 0.25rem;
  cursor: pointer;
  font-size: 0.875rem;
  user-select: none;
}
.calendar-day:hover:not(.empty):not(.sunday) {
  background-color: #eff6ff;
  color: #1d4ed8;
}
.calendar-day.selected {
  background-color: #2563eb;
  color: white;
}
.calendar-day.today {
  font-weight: bold;
  border: 1px solid #2563eb;
}
.calendar-day.empty {
  visibility: hidden;
}
.calendar-day-header.sunday {
  color: #dc2626;
}
.calendar-day.sunday {
  color: #dc2626;
  background-color: #fef2f2;
  cursor: not-allowed;
  text-decoration: line-through;
  opacity: 0.6;
}

/* =========================================================
   A4 LISTIĆI - UJEDNAČENA VISINA SVIH REDOVA U TABELI
   ========================================================= */
.a4-preview-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
  margin-top: 20px;
}

.a4-page {
  width: 210mm;
  height: 296.5mm;
  padding: 5mm;
  background: #fff;
  box-shadow: 0 0 15px rgba(0, 0, 0, 0.15);
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  gap: 0;
  position: relative;
  overflow: hidden;
  box-sizing: border-box;
}

.quadrant {
  border: 1px solid #000;
  padding: 2.5mm 4mm 2mm 4mm;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  overflow: hidden;
  position: relative;
  box-sizing: border-box;
}

.quadrant:nth-child(1) {
  border-right: 0.5px solid #000;
  border-bottom: 0.5px solid #000;
}
.quadrant:nth-child(2) {
  border-left: 0.5px solid #000;
  border-bottom: 0.5px solid #000;
}
.quadrant:nth-child(3) {
  border-right: 0.5px solid #000;
  border-top: 0.5px solid #000;
}
.quadrant:nth-child(4) {
  border-left: 0.5px solid #000;
  border-top: 0.5px solid #000;
}

.front-header {
  text-align: center;
  font-family: "Marck Script", cursive;
  font-weight: bold;
  font-size: 15.5pt;
  color: #000;
  margin-bottom: 1mm;
  line-height: 1.05;
  flex-shrink: 0;
}

/* Tabela sa fiksiranim, urednim redovima bez automatskog razvlačenja */
.work-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  border: 2px solid #000 !important;
}

.work-table th,
.work-table td {
  padding: 0 3px;
  text-align: center;
  vertical-align: middle;
  font-size: 9pt;
}

.work-table th {
  border-top: 2px solid #000 !important;
  border-bottom: 2px solid #000 !important;
  height: 5.2mm;
  font-weight: 800;
  color: #000;
  background-color: #f1f5f9;
}

/* Svaki red u tabeli sada ima strogo fiksiranu i identičnu visinu */
.work-table td {
  height: 5.35mm;
  border-top: 0.75px solid #000;
  border-bottom: 0.75px solid #000;
}

.work-table tbody tr:last-child td {
  border-bottom: 2px solid #000 !important;
}

.work-table th:first-child,
.work-table td:first-child {
  border-left: 2px solid #000 !important;
  border-right: 2px solid #000 !important;
}

.work-table th:nth-child(2),
.work-table td:nth-child(2) {
  border-left: 2px solid #000 !important;
  border-right: 2px solid #000 !important;
}

.col-sifra {
  width: 25mm;
}
.col-komada {
  width: auto;
}

.signature-box {
  margin-top: 1mm;
  height: 6mm;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  padding-right: 1mm;
  flex-shrink: 0;
}

.signature-box img {
  max-height: 5.8mm;
  max-width: 48mm;
  object-fit: contain;
}

.default-sig {
  font-family: "Georgia", "Times New Roman", serif;
  font-style: italic;
  font-size: 11.5pt;
  color: #111;
  letter-spacing: 0.5px;
}

.back-header {
  text-align: center;
  font-family: "Marck Script", cursive;
  font-weight: bold;
  font-size: 15.5pt;
  color: #000;
  margin-bottom: 1mm;
  line-height: 1.05;
  flex-shrink: 0;
}

.back-sections {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  flex-grow: 1;
  height: 100%;
  gap: 2mm;
}

.section-block {
  display: flex;
  flex-direction: column;
  flex: 1 1 0%;
  justify-content: space-between;
}

.section-title {
  font-weight: 800;
  font-size: 8.5pt;
  margin-bottom: 0.5mm;
  letter-spacing: 0.3px;
  color: #000;
  flex-shrink: 0;
}

.write-line {
  border-bottom: 0.85px solid #000;
  flex: 1 1 0%;
  width: 100%;
}

/* RESPONZIVNOST TABELA ZA MOBILNE */
@media (max-width: 767px) {
  .responsive-table thead {
    display: none;
  }
  .responsive-table,
  .responsive-table tbody,
  .responsive-table tr,
  .responsive-table td {
    display: block;
    width: 100%;
  }
  .responsive-table tr {
    margin-bottom: 1rem;
    border: 1px solid #e5e7eb;
    border-radius: 0.5rem;
    padding: 0.5rem;
    background-color: #fff;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
  }
  .responsive-table td {
    text-align: right;
    padding: 0.5rem;
    border-bottom: 1px solid #f3f4f6;
    position: relative;
    padding-left: 45%;
    min-height: 40px;
  }
  .responsive-table td:last-child {
    border-bottom: 0;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    justify-content: center;
    padding-left: 0;
    padding-top: 1.5rem;
  }
  .responsive-table td:last-child::before {
    top: 0.5rem;
    left: 0.5rem;
    width: 100%;
  }
  .responsive-table td::before {
    content: attr(data-label);
    position: absolute;
    left: 0.5rem;
    width: 40%;
    padding-right: 10px;
    white-space: nowrap;
    text-align: left;
    font-weight: 600;
    color: #6b7280;
    font-size: 0.75rem;
    text-transform: uppercase;
  }
  .responsive-table td input,
  .responsive-table td select {
    width: 100% !important;
    text-align: right;
  }
}

@media (min-width: 768px) {
  .responsive-table td::before {
    content: none;
  }
  .responsive-table td {
    padding-left: 0.75rem;
    text-align: left;
    display: table-cell;
  }
  .responsive-table td.text-right {
    text-align: right;
  }
  .responsive-table td.text-center {
    text-align: center;
  }
  .responsive-table td.flex {
    display: flex;
  }
}

/* =========================================================
   STROGA PRAVILA ZA ŠTAMPU (TAČNO 1 LIST / 2 STRANE)
   ========================================================= */
@media print {
  @page {
    size: 210mm 297mm;
    margin: 0mm !important;
  }

  html,
  body {
    width: 210mm !important;
    margin: 0 !important;
    padding: 0 !important;
    background: #fff !important;
  }

  body > *:not(#glavnaAplikacija),
  #glavnaAplikacija > *:not(#tab-listici),
  .no-print-listici {
    display: none !important;
  }

  #glavnaAplikacija,
  #tab-listici,
  #listiciPrintArea,
  .a4-preview-area {
    display: block !important;
    position: static !important;
    width: 210mm !important;
    max-width: none !important;
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
    box-shadow: none !important;
    gap: 0 !important;
  }

  .a4-page {
    width: 210mm !important;
    height: 296.5mm !important;
    max-height: 296.5mm !important;
    padding: 5mm !important;
    margin: 0 !important;
    box-shadow: none !important;
    page-break-after: always !important;
    break-after: page !important;
    page-break-inside: avoid !important;
    break-inside: avoid !important;
  }

  .a4-page:last-child {
    page-break-after: auto !important;
    break-after: auto !important;
  }
}
