/* =========================================================
   DomUpravitel — дополнителни стилови над Tailwind
   Дизајн систем: _/DESIGN.md
   ========================================================= */

:root {
  --du-primary: #00236f;
  --du-primary-container: #1e3a8a;
  --du-outline-variant: #c5c5d3;
  --du-sidebar-width: 264px;
}

* { -webkit-tap-highlight-color: transparent; }

html, body { min-height: 100%; }

body {
  font-feature-settings: 'cv02', 'cv03', 'cv04', 'cv11';
}

/* Иконите на Material Symbols */
.material-symbols-outlined {
  font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
  user-select: none;
  line-height: 1;
}
.material-symbols-outlined.filled { font-variation-settings: 'FILL' 1; }
.icon-sm { font-size: 18px; }
.icon-md { font-size: 20px; }
.icon-lg { font-size: 24px; }
.icon-xl { font-size: 32px; }

/* Броевите во табели се порамнуваат */
.tabular { font-variant-numeric: tabular-nums; }

/* --------------------------------------------------------
   Анимации
   -------------------------------------------------------- */
@keyframes loading {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(300%); }
}
@keyframes du-fade-in {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: none; }
}
@keyframes du-scale-in {
  from { opacity: 0; transform: scale(.97) translateY(8px); }
  to   { opacity: 1; transform: none; }
}
@keyframes du-slide-in {
  from { opacity: 0; transform: translateX(16px); }
  to   { opacity: 1; transform: none; }
}
.du-fade   { animation: du-fade-in .18s ease-out both; }
.du-pop    { animation: du-scale-in .18s ease-out both; }
.du-slide  { animation: du-slide-in .22s ease-out both; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
  }
}

/* --------------------------------------------------------
   Навигација
   -------------------------------------------------------- */
.du-nav-link {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px 10px 20px;
  border-radius: 0 9999px 9999px 0;
  margin-right: 12px;
  font-size: 14px;
  font-weight: 500;
  color: #444651;
  transition: background-color .15s, color .15s;
}
.du-nav-link:hover { background-color: #eceef0; color: #191c1e; }
.du-nav-link.active {
  background-color: #e6e8ea;
  color: var(--du-primary);
  font-weight: 600;
}
.du-nav-link.active::before {
  content: '';
  position: absolute;
  left: 0; top: 50%;
  height: 60%;
  width: 4px;
  transform: translateY(-50%);
  border-radius: 0 4px 4px 0;
  background-color: var(--du-primary-container);
}
.du-nav-link .material-symbols-outlined { font-size: 22px; }

/* Долна навигација на мобилен */
.du-tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  flex: 1 1 0;
  padding: 8px 4px calc(8px + env(safe-area-inset-bottom, 0px));
  font-size: 11px;
  font-weight: 500;
  color: #444651;
}
.du-tab.active { color: var(--du-primary-container); font-weight: 600; }
.du-tab.active .material-symbols-outlined { font-variation-settings: 'FILL' 1; }

/* --------------------------------------------------------
   Компоненти
   -------------------------------------------------------- */
.du-card {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: .5rem;
}

.du-kpi {
  position: relative;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-left-width: 4px;
  border-radius: .5rem;
  padding: 20px;
}

/**
 * Ширината стои во `:where()`, значи со специфичност нула.
 *
 * `app.css` намерно доаѓа по `tailwind.css` за да може да го надгласи.
 * Но тогаш `.du-input { width: 100% }` ја победуваше и `sm:w-52`, зашто
 * двете се по една класа, а последната пишана победува. Резултатот се
 * гледаше на дванаесет екрани: полето за пребарување се собираше на
 * педесетина пиксели, а списоците до него се растегнуваа преку половина
 * екран. Никаква грешка никаде — само крив распоред.
 *
 * Со нулта специфичност 100 % останува основното однесување, а секоја
 * зададена ширина (`w-full`, `sm:w-52`) го надгласува — што и е смислата
 * на помошните класи.
 */
:where(.du-input) { width: 100%; }

.du-input {
  border: 1px solid var(--du-outline-variant);
  border-radius: .25rem;
  background: #fff;
  padding: 9px 12px;
  font-size: 14px;
  color: #191c1e;
  transition: border-color .15s, box-shadow .15s;
}
.du-input::placeholder { color: #94a3b8; }
.du-input:focus {
  outline: none;
  border-color: var(--du-primary-container);
  box-shadow: 0 0 0 3px rgba(30, 58, 138, .12);
}
.du-input:disabled { background: #f2f4f6; color: #757682; }
.du-input.error { border-color: #ba1a1a; }
select.du-input {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='%23444651'%3E%3Cpath fill-rule='evenodd' d='M5.23 7.21a.75.75 0 011.06.02L10 11.17l3.71-3.94a.75.75 0 111.08 1.04l-4.25 4.5a.75.75 0 01-1.08 0l-4.25-4.5a.75.75 0 01.02-1.06z' clip-rule='evenodd'/%3E%3C/svg%3E");
  background-position: right .6rem center;
  background-repeat: no-repeat;
  background-size: 1.15em;
  padding-right: 2.2rem;
}
.du-label {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  font-weight: 600;
  color: #444651;
}
.du-help { margin-top: 4px; font-size: 12px; color: #757682; }
.du-error { margin-top: 4px; font-size: 12px; color: #ba1a1a; }

.du-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: .25rem;
  padding: 9px 16px;
  font-size: 14px;
  font-weight: 600;
  transition: background-color .15s, border-color .15s, opacity .15s;
  white-space: nowrap;
}
.du-btn:disabled { opacity: .55; cursor: not-allowed; }
.du-btn-primary   { background: var(--du-primary-container); color: #fff; }
.du-btn-primary:hover:not(:disabled)   { background: #16307a; }
.du-btn-secondary { background: #fff; color: #191c1e; border: 1px solid var(--du-outline-variant); }
.du-btn-secondary:hover:not(:disabled) { background: #f2f4f6; }
.du-btn-ghost     { color: #444651; }
.du-btn-ghost:hover:not(:disabled)     { background: #eceef0; }
.du-btn-danger    { background: #ba1a1a; color: #fff; }
.du-btn-danger:hover:not(:disabled)    { background: #9d1515; }
.du-btn-sm { padding: 6px 12px; font-size: 13px; }

.du-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border-radius: 9999px;
  padding: 3px 10px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .02em;
  white-space: nowrap;
}

/* Табели */
.du-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.du-table thead th {
  position: sticky; top: 0;
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
  padding: 12px 16px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: #444651;
  white-space: nowrap;
}
.du-table tbody td {
  border-bottom: 1px solid #eef2f6;
  padding: 12px 16px;
  height: 48px;
  vertical-align: middle;
}
.du-table tbody tr:nth-child(even) { background: #fbfcfd; }
.du-table tbody tr:hover { background: #f2f6fc; }
.du-table tbody tr:last-child td { border-bottom: none; }

/* Скролање */
.du-scroll { overflow: auto; }
.du-scroll::-webkit-scrollbar { width: 10px; height: 10px; }
.du-scroll::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 9999px; border: 3px solid transparent; background-clip: content-box; }
.du-scroll::-webkit-scrollbar-thumb:hover { background: #94a3b8; background-clip: content-box; }
.du-scroll::-webkit-scrollbar-track { background: transparent; }

/* Скелетон при вчитување */
.du-skeleton {
  background: linear-gradient(90deg, #eceef0 25%, #f4f6f8 37%, #eceef0 63%);
  background-size: 400% 100%;
  animation: du-shimmer 1.3s ease infinite;
  border-radius: .25rem;
}
@keyframes du-shimmer {
  0%   { background-position: 100% 50%; }
  100% { background-position: 0 50%; }
}

/* Безбедна зона за iOS */
.pt-safe { padding-top: env(safe-area-inset-top, 0px); }
.pb-safe { padding-bottom: env(safe-area-inset-bottom, 0px); }

/* Печатење на извештаи */
@media print {
  .no-print { display: none !important; }
  body { background: #fff; }
  main { padding: 0 !important; }
  .du-card { break-inside: avoid; border-color: #cbd5e1; }
}

/* -----------------------------------------------------------------
   Законски документи: потврда и повик (модул `legal`)

   Хартијата е составена за екран, но нејзиниот вистински излез е
   печатач — потврдата се носи кај нотар. Затоа документот се пресликува
   во сад надвор од апликацијата и само тој се печати; инаку модалот го
   влече и екранот зад себе.
   ----------------------------------------------------------------- */
#du-print { display: none; }

.du-sheet {
  max-width: 190mm;
  margin: 0 auto;
  color: #0f172a;
}

/* Погуст ред: документот треба да собере дванаесет ставки на еден лист */
.du-table-tight th,
.du-table-tight td { padding-top: .3rem; padding-bottom: .3rem; }

@media print {
  html.du-printing body > *:not(#du-print) { display: none !important; }
  html.du-printing #du-print { display: block !important; }
  html.du-printing .du-sheet { max-width: none; }
  /* Прегледот на екран има граници и сенка; на хартија тие само трошат тонер */
  html.du-printing .du-sheet table { width: 100%; border-collapse: collapse; }
  html.du-printing .du-sheet th,
  html.du-printing .du-sheet td { border-bottom: 1px solid #cbd5e1; }
  @page { margin: 16mm; }
}
