/* Ambulancia MediKal – vlastné štýly, mobilné rozhranie (PWA) a tlač (A6 / A4) */

:root {
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

html, body {
  -webkit-tap-highlight-color: transparent;
  scroll-behavior: smooth;
}

/* Ochrana proti nechcenému zoomu na iOS Safari pri písaní do formulárov */
@media (max-width: 767px) {
  input[type="text"],
  input[type="email"],
  input[type="tel"],
  input[type="password"],
  input[type="number"],
  input[type="date"],
  input[type="time"],
  select,
  textarea {
    font-size: 16px !important;
  }
}

@media (max-width: 1023px) {
  body {
    padding-bottom: calc(4.75rem + var(--safe-bottom));
  }
}

/* Trvalá spodná navigačná lišta pre lekára a sestru (výrazná aj normálna) */
body.has-medical-bottom-dock-prominent {
  padding-bottom: calc(5.75rem + var(--safe-bottom));
}

body.has-medical-bottom-dock-prominent #toast-container {
  bottom: calc(5.75rem + var(--safe-bottom));
}

body.has-medical-bottom-dock-normal {
  padding-bottom: calc(3.85rem + var(--safe-bottom));
}

body.has-medical-bottom-dock-normal #toast-container {
  bottom: calc(3.85rem + var(--safe-bottom));
}

/* Pozícia plávajúceho okna Interkom Lekár ↔ Sestra nad spodnou lištou */
.intercom-dock-offset {
  bottom: calc(1rem + var(--safe-bottom));
}

@media (max-width: 1023px) {
  .intercom-dock-offset {
    bottom: calc(5rem + var(--safe-bottom));
  }
}

body.has-medical-bottom-dock-prominent .intercom-dock-offset {
  bottom: calc(6rem + var(--safe-bottom));
}

body.has-medical-bottom-dock-normal .intercom-dock-offset {
  bottom: calc(4.1rem + var(--safe-bottom));
}

/* Spodná mobilná navigačná lišta */
#mobile-bottom-nav {
  padding-bottom: var(--safe-bottom);
}

/* Mobilný bottom-sheet modál */
@media (max-width: 639px) {
  #modal-backdrop {
    align-items: flex-end !important;
    padding: 0 !important;
  }
  #modal-dialog {
    width: 100% !important;
    max-width: 100% !important;
    max-height: 92dvh !important;
    border-bottom-left-radius: 0 !important;
    border-bottom-right-radius: 0 !important;
    border-top-left-radius: 1.5rem !important;
    border-top-right-radius: 1.5rem !important;
    animation: slideUpSheet 0.22s ease-out;
  }
}

@keyframes slideUpSheet {
  from {
    transform: translateY(32px);
    opacity: 0.7;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

/* Jemný scrollbar pre horizontálne prvky */
.no-scrollbar::-webkit-scrollbar {
  display: none;
}
.no-scrollbar {
  -ms-overflow-style: none;
  scrollbar-width: none;
}

/* Animácia mikrofónu pri hlasovom diktovaní */
@keyframes pulseMic {
  0%, 100% { box-shadow: 0 0 0 0 rgba(225, 29, 72, 0.55); }
  50% { box-shadow: 0 0 0 10px rgba(225, 29, 72, 0); }
}
.mic-recording {
  animation: pulseMic 1.2s infinite;
}

/* Informačný monitor čakárne – presné pomery strán 9:16 (na výšku) a 16:9 (na šírku) */
.tv-frame-portrait {
  width: 100%;
  max-width: 480px;
  aspect-ratio: 9 / 16;
  margin-left: auto;
  margin-right: auto;
}

.tv-frame-landscape {
  width: 100%;
  max-width: 1120px;
  aspect-ratio: 16 / 9;
  margin-left: auto;
  margin-right: auto;
}

.tv-frame-fullscreen-portrait {
  width: min(100vw, calc(100dvh * 9 / 16));
  height: min(100dvh, calc(100vw * 16 / 9));
  aspect-ratio: 9 / 16;
  margin: auto;
}

.tv-frame-fullscreen-landscape {
  width: min(100vw, calc(100dvh * 16 / 9));
  height: min(100dvh, calc(100vw * 9 / 16));
  aspect-ratio: 16 / 9;
  margin: auto;
}

/* Samostatný celoobrazovkový TV kiosk (?monitor=tv): vyplní 100 % obrazovky bez čiernych okrajov a skryje kurzor myši */
body.tv-standalone-mode,
body.tv-standalone-mode * {
  cursor: none !important;
}

body.tv-standalone-mode .tv-frame-fullscreen-portrait,
body.tv-standalone-mode .tv-frame-fullscreen-landscape {
  width: 100vw !important;
  height: 100dvh !important;
  max-width: none !important;
  aspect-ratio: auto !important;
  margin: 0 !important;
  border-radius: 0 !important;
}

/* Na reálnom otočenom monitore v čakárni (Raspberry Pi na výšku) vyplní 100 % displeja */
@media (orientation: portrait) {
  .tv-frame-portrait {
    max-width: 100%;
  }
}

@keyframes tvSlideFadeIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.tv-slide-enter {
  animation: tvSlideFadeIn 0.38s ease-out;
}

@keyframes tvProgressFill {
  from { width: 0%; }
  to { width: 100%; }
}

.tv-progress-bar-active {
  animation-name: tvProgressFill;
  animation-timing-function: linear;
  animation-fill-mode: forwards;
}

/* Jednoriadkový bežiaci text (TV ticker) pre RSS spravodajstvo */
.tv-rss-ticker-viewport {
  overflow: hidden;
  white-space: nowrap;
  position: relative;
  -webkit-mask-image: linear-gradient(to right, transparent 0%, #000 14px, #000 calc(100% - 14px), transparent 100%);
  mask-image: linear-gradient(to right, transparent 0%, #000 14px, #000 calc(100% - 14px), transparent 100%);
}

@keyframes tvRssTickerScroll {
  0% {
    transform: translate3d(0, 0, 0);
  }
  100% {
    transform: translate3d(-50%, 0, 0);
  }
}

.tv-rss-ticker-track {
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
  will-change: transform;
  animation-name: tvRssTickerScroll;
  animation-duration: var(--ticker-duration, 90s);
  animation-timing-function: linear;
  animation-iteration-count: infinite;
}

#tv-teraz-rss-bar:hover .tv-rss-ticker-track {
  animation-play-state: paused;
}

/* Kalendár – rýchle príkazy dňa napevno v riadku pod dátumom, pri úzkom stĺpci pod sebou vpravo */
.cal-day-header {
  container-type: inline-size;
  container-name: calday;
}

.cal-day-quick-actions {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: flex-start;
  gap: 0.55rem;
  margin-top: 0.375rem;
  padding-top: 0.375rem;
  border-top: 1px solid rgba(203, 213, 225, 0.65);
}

.cal-day-quick-actions-today {
  background: rgba(255, 255, 255, 0.95);
  border-top: none;
  border-radius: 0.5rem;
  padding: 0.25rem 0.5rem;
  margin-top: 0.45rem;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.08);
}

@container calday (max-width: 180px) {
  .cal-day-quick-actions {
    flex-direction: column;
    align-items: flex-end;
    gap: 0.125rem;
  }
}

/* Náhľad tlačenej kartičky A6 na obrazovke (presný pomer strán 148 × 105 mm na šírku s viditeľnou 5+ mm rezervou) */
.a6-paper-preview {
  width: 148mm;
  height: 105mm;
  max-width: 100%;
  aspect-ratio: 148 / 105;
  padding: 6mm;
  margin-left: auto;
  margin-right: auto;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  box-shadow: 0 8px 24px -6px rgba(15, 23, 42, 0.16);
  box-sizing: border-box;
  display: flex;
  align-items: stretch;
  justify-content: center;
}

.a6-paper-preview > .a6-card-print,
.a6-paper-preview > .a6-duplex-page {
  width: 100%;
  height: 100%;
  max-width: none;
  margin: 0;
  box-sizing: border-box;
  overflow: hidden;
}

.a6-duplex-page {
  position: relative;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  column-gap: 10mm;
  background: transparent;
}

.a6-duplex-panel {
  height: 100%;
  min-width: 0;
  box-sizing: border-box;
  overflow: hidden;
  border: none;
}

/* Režim vysoko kontrastnej čiernobielej tlače (čistá čierna #000 na bielej #fff bez šedých pozadí pre ČB tlačiarne) */
.print-bw-mode,
.print-bw-mode * {
  color: #000000 !important;
  border-color: #000000 !important;
  background-color: #ffffff !important;
  background-image: none !important;
  box-shadow: none !important;
}

.print-bw-mode img {
  filter: grayscale(100%) contrast(130%) !important;
}

.print-bw-mode .bw-strong-box {
  border: 1.5px solid #000000 !important;
  background-color: #ffffff !important;
}

.print-bw-mode .bw-soft-box {
  border: 1px solid #000000 !important;
  background-color: #ffffff !important;
}

.print-bw-mode .bw-badge-pill {
  border: 1px solid #000000 !important;
  background-color: #ffffff !important;
}

.print-bw-mode .bw-icon-badge {
  border: 1.5px solid #000000 !important;
  background-color: #ffffff !important;
  color: #000000 !important;
}

@media (max-width: 639px) {
  .a6-paper-preview {
    width: 100%;
    height: auto;
    min-height: 240px;
    padding: 3.5mm;
  }
  .a6-duplex-page {
    column-gap: 5mm;
  }
}

/* Tlačové štýly pre kartičku A6 (presne 148 × 105 mm na šírku s min. 5–6 mm rezervou z každej strany) a Ranný zoznam A4 */
#print-root {
  display: none;
}

@media print {
  html, body {
    margin: 0 !important;
    padding: 0 !important;
    background: #ffffff !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  body > *:not(#print-root) {
    display: none !important;
  }

  #print-root {
    display: block !important;
    margin: 0 !important;
    padding: 0 !important;
    background: #ffffff !important;
    color: #0f172a !important;
  }

  body.print-mode-a6 .a6-duplex-wrapper {
    display: block !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  body.print-mode-a6 .a6-duplex-wrapper > * + * {
    margin-top: 0 !important;
  }

  body.print-mode-a6 .a6-duplex-screen-label {
    display: none !important;
  }

  /* Každý list A6 má @page 148x105mm s okrajom 5mm (= tlačová plocha 138x95mm); vnútorný rámik je 136x92.5mm -> celková bezpečná rezerva ~6mm z každej strany bez rizika prázdnej strany */
  body.print-mode-a6 .a6-paper-preview {
    width: 138mm !important;
    height: 94mm !important;
    max-width: none !important;
    aspect-ratio: auto !important;
    padding: 0.75mm 1mm !important;
    margin: 0 !important;
    border: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    background: #ffffff !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    overflow: hidden !important;
    page-break-inside: avoid !important;
    break-inside: avoid !important;
    page-break-after: always !important;
    break-after: page !important;
  }

  body.print-mode-a6 .a6-paper-preview:last-of-type {
    page-break-after: auto !important;
    break-after: auto !important;
  }

  body.print-mode-a6 .a6-card-print {
    width: 136mm !important;
    height: 92.5mm !important;
    min-height: 0 !important;
    max-width: none !important;
    margin: 0 !important;
    border: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    box-sizing: border-box !important;
    overflow: hidden !important;
    page-break-inside: avoid !important;
    break-inside: avoid !important;
  }

  body.print-mode-a6 .a6-duplex-page {
    width: 136mm !important;
    height: 92.5mm !important;
    min-height: 0 !important;
    max-width: none !important;
    margin: 0 !important;
    border: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    column-gap: 10mm !important;
    box-sizing: border-box !important;
    overflow: hidden !important;
    page-break-inside: avoid !important;
    break-inside: avoid !important;
  }

  body.print-mode-a6 .a6-duplex-panel {
    border: none !important;
    border-radius: 0 !important;
  }

  body.print-mode-a4 .a4-sheet-print {
    width: 100%;
    padding: 4mm;
    box-sizing: border-box;
  }

  .no-print {
    display: none !important;
  }
}
