:root { --bg: #000000; --header: #000000; --text: #fff; --card: #000000; }

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; scrollbar-width: none; -ms-overflow-style: none; }
::-webkit-scrollbar { display: none; width: 0; height: 0; }

img { max-width: 100%; height: auto; }

html { background-color: #000000; transition: background-color 0.3s; height: 100%; width: 100%; overflow: hidden; }

body { 
  background-color: var(--bg); 
  color: var(--text); 
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif; 
  margin: 0; 
  padding: 0; 
  transition: 0.3s;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-size: 16px;
  height: 100dvh;
  width: 100%;
  overflow: hidden;
}

.app-wrapper {
  width: 100%;
  max-width: 30rem;
  min-height: 100dvh; /* Zabezpečí roztiahnutie na celú výšku obrazovky */
  position: relative;
  text-align: center;
  background-color: var(--bg); /* Nastaví pozadie pre celý wrapper */
  display: flex;
  flex-direction: column;
  margin: 0 auto;
  overflow-y: auto;
  overflow-x: hidden;
  align-items: center;
}

header { 
  position: fixed;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 30rem;
  z-index: 1000;
  background-color: var(--header); 
  padding: env(safe-area-inset-top) 10px 0 10px;
  height: 45px;
  display: grid;
  grid-template-columns: 80px 1fr auto;
  align-items: center; 
  box-shadow: 0 0.125rem 0.3125rem rgba(0,0,0,0.1); 
  box-sizing: border-box;
}
.header-logo-container { height: 100%; display: flex; align-items: center; justify-content: flex-start; overflow: hidden; }
.header-logo { height: 85%; max-height: 38px; width: auto; object-fit: contain; pointer-events: none; }
.header-title {
  justify-self: center;
  text-align: center;
  font-weight: 800;
  font-size: clamp(1rem, 4.5vw, 1.4rem); /* Responzívna veľkosť písma */
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
header button { background-color: transparent; border: none; font-size: 1rem; cursor: pointer; padding: 5px; color: var(--text); display: flex; align-items: center; justify-self: flex-end; white-space: nowrap; }

/* Pridanie odsadenia pre obsah, aby nebol pod hlavičkou */
#viewProfileModal, #editProfileModal, #editMedicationModal, #archiv, #manualModal, #infoModal, #archivVahyModal {
  padding-top: calc(45px + env(safe-area-inset-top) + 0.5rem);
  padding-bottom: env(safe-area-inset-bottom);
}

/* Zjednotenie horného okraja pre nadpisy v hlavných sekciách */
#viewProfileModal h2, #editProfileModal h2, #editMedicationModal h2, #archiv h2, #manualModal h2, #infoModal h2, #archivVahyModal h2 {
  margin-top: 0;
}

.dropdown-content { display: none; position: absolute; right: 0.5rem; top: calc(45px + env(safe-area-inset-top)); background-color: var(--card); width: max-content; max-width: 90vw; box-shadow: 0 0.5rem 1.5rem rgba(0,0,0,0.3); z-index: 1001; border-radius: 1rem; overflow: hidden; max-height: calc(100dvh - 5rem); flex-direction: column; padding: 0.5rem; box-sizing: border-box; border: 1px solid rgba(128,128,128,0.2); }
.dropdown-content button { display: block; width: 100%; padding: 0.625rem 0.9375rem; border: none; background: none; text-align: left; font-size: 1rem; cursor: pointer; color: var(--text); flex-shrink: 1; border-bottom: 1px solid rgba(128,128,128,0.1); white-space: nowrap; }
.dropdown-content button:last-child { border-bottom: none; }

.form-container, .modal-form-grid { 
  margin: 0 auto;
  width: 100%;
  padding: 0.5rem 0.5rem calc(env(safe-area-inset-bottom) + 0.5rem);
  display: grid; 
  grid-template-columns: repeat(2, 1fr); 
  gap: 0.6rem; 
  align-items: center;
  overflow-y: auto; /* Umožní scrollovanie, ak sa obsah nezmestí */
  height: 100%; /* Zabezpečí, že kontajner vyplní dostupný priestor */
}

/* Aplikuje horné odsadenie iba na hlavný formulár, nie na tie v modáloch */
#formular.form-container {
  padding-top: calc(45px + env(safe-area-inset-top) + 0.5rem);
}
#manualDatum, #pulse, #manualPulse { grid-column: span 2; }
input { min-width: 0; padding: 0.75rem; font-size: 16px; background-color: var(--card); color: var(--text); border: 1px solid #ccc; border-radius: 0.8rem; appearance: none; width: 100%; box-sizing: border-box; }
button.main { grid-column: span 2; background-color: #4CAF50; color: white; border: none; padding: 1rem; width: 100%; cursor: pointer; margin: 0.3rem 0; font-size: 1.1rem; border-radius: 0.8rem; font-weight: bold; box-shadow: 0 0.25rem 0.375rem rgba(0,0,0,0.1); min-height: 3.5rem; }
button.secondary { background-color: #2196F3; color: white; border: none; padding: 0.6rem 0.4rem; flex: 1; min-width: 0; cursor: pointer; font-size: 0.9rem; border-radius: 0.75rem; min-height: 2.8rem; }

#authScreen { position: fixed; top: 0; left: 0; width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; background: var(--bg); z-index: 1002; overflow: hidden; }
.auth-form { width: 90%; max-width: 20rem; display: flex; flex-direction: column; align-items: center; gap: 0.3rem; }
.auth-form h2 { margin: -1.5rem 0 0.8rem 0; font-size: 1.6rem; }
.auth-form h3 { margin: 0 0 0.3rem 0; font-size: 1.1rem; }
.auth-form input { margin-bottom: 0.4rem; }
.tab-buttons { display: flex; gap: 0.4rem; margin-bottom: 0.6rem; width: 100%; justify-content: center; }

.record-list { display: flex; flex-direction: column; width: 100%; border: 1px solid rgba(128,128,128,0.1); border-radius: 0.8rem; overflow-x: auto; margin-top: 0.5rem; padding-bottom: 2rem; }
.archive-header { display: grid; grid-template-columns: 28% 11% 11% 12% 12% 12% 14%; font-weight: bold; font-size: 9px; text-transform: uppercase; background-color: var(--header); border-bottom: 2px solid rgba(0,0,0,0.1); padding: 8px 1px; text-align: center; width: 100%; min-width: 340px; box-sizing: border-box; gap: 1px; }
.record-row { display: grid; grid-template-columns: 28% 11% 11% 12% 12% 12% 14%; align-items: center; background-color: var(--card); padding: 10px 1px; border-bottom: 1px solid rgba(128,128,128,0.2); width: 100%; min-width: 340px; box-sizing: border-box; font-size: 10px; text-align: center; gap: 1px; }
.record-list { display: flex; flex-direction: column; width: 100%; border: 1px solid rgba(128,128,128,0.1); border-radius: 0.8rem; overflow-x: hidden; margin-top: 0.5rem; padding-bottom: 2rem; }
.archive-header { display: grid; grid-template-columns: 28% 11% 11% 12% 12% 12% 14%; font-weight: bold; font-size: 9px; text-transform: uppercase; background-color: var(--header); border-bottom: 2px solid rgba(0,0,0,0.1); padding: 8px 1px; text-align: center; width: 100%; box-sizing: border-box; gap: 1px; }
.record-row { display: grid; grid-template-columns: 28% 11% 11% 12% 12% 12% 14%; align-items: center; background-color: var(--card); padding: 10px 1px; border-bottom: 1px solid rgba(128,128,128,0.2); width: 100%; box-sizing: border-box; font-size: 10px; text-align: center; gap: 1px; }

/* Štýly pre režim "Iba Tlak" */
body.bp-only #inr, body.bp-only #tab, body.bp-only #manualInr, body.bp-only #manualTab { display: none; }
body.bp-only .archive-header, body.bp-only .record-row { grid-template-columns: 35% 15% 15% 15% 20%; }
body.bp-only .col-inr, body.bp-only .col-tab { display: none; }
body.bp-only #leg_item_purple, body.bp-only #leg_item_yellow { display: none; }
body.bp-only #info_tab_row, body.bp-only #info_inr_row { display: none; }

/* Tlačové štýly pre PDF export */
@media print {
  body * { visibility: hidden; }
  #monthDetailContent, #monthDetailContent * { visibility: visible; }
  #monthDetailContent { position: absolute; left: 0; top: 0; width: 100%; }
  .record-row div:last-child { display: none; } /* Skryť ikonu koša */
}

.modal { display: none; position: fixed; z-index: 2000; left: 0; top: 0; width: 100%; height: 100%; background-color: rgba(0,0,0,0.6); backdrop-filter: blur(4px); justify-content: center; align-items: center; padding: 1rem; }
.modal-content { background-color: var(--card); padding: 1rem; border-radius: 1.5rem; width: 100%; max-width: 20.5rem; max-height: 90dvh; overflow-y: auto; display: flex; flex-direction: column; text-align: left; box-sizing: border-box; }
#infoModal .modal-content { justify-content: center; gap: 0.2rem; }
.info-card { background-color: var(--card); padding: 1rem; border-radius: 1rem; text-align: left; border: 1px solid rgba(128,128,128,0.1); box-shadow: 0 0.2rem 0.5rem rgba(0,0,0,0.05); margin-bottom: 1rem; display: flex; flex-direction: column; gap: 0.2rem; }
#infoModal p { margin: 0.3rem 0; font-size: 0.9rem; line-height: 1.3; }

#splashScreen { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: var(--bg); display: flex; align-items: center; justify-content: center; flex-direction: column; z-index: 999; transition: opacity 0.5s ease; }
#splashScreen img { width: 10rem; height: 10rem; animation: pulse 1.5s infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: 0.7; transform: scale(1.1); } }
#dialogMessage { white-space: pre-line; }

/* Responzivita pre štandardné a menšie mobily */
@media (max-width: 480px) {
  html, body { font-size: 14px; }
  .app-wrapper { padding-left: 0.6rem; padding-right: 0.6rem; }
  input, textarea { padding: 0.65rem; font-size: 16px !important; } /* Prevencia Safari zoomu */
  button.main { min-height: 3.2rem; padding: 0.8rem; font-size: 1rem; }
  .modal-content { padding: 1.2rem; }
}

/* Podpora pre veľmi úzke ALEBO nízke mobilné obrazovky (Galaxy S, iPhone SE a iné) */
@media (max-width: 390px), (max-height: 750px) {
  body { font-size: 13px; } 
  .app-wrapper { padding-left: 0.5rem; padding-right: 0.5rem; }
  .modal { padding: 0.5rem; }
  .modal-content { padding: 1rem; border-radius: 1.2rem; }
  .form-container, .modal-form-grid { grid-template-columns: repeat(2, 1fr); gap: 0.4rem; }
  button.main, #manualDatum, #pulse, #manualPulse { grid-column: span 2; min-height: 2.6rem; margin: 0.1rem 0; }
  header { grid-template-columns: 70px 1fr 70px; padding: env(safe-area-inset-top) 5px 0 5px; height: 40px; }
  .auth-form h2 { font-size: 1.4rem; }
  .auth-form { width: 100%; }
  .dropdown-content { right: 0.25rem; max-width: 95vw; }

  /* Špeciálne zmenšenie Informačného modálu pre okamžitú viditeľnosť bez scrollovania */
  #infoModal .modal-content { padding: 0.8rem; gap: 0; max-height: 95dvh; justify-content: flex-start; }
  #infoModal h3 { font-size: 1.1rem; margin: 0 0 0.2rem 0; text-align: center; }
  #infoModal .info-card { padding: 0.8rem; gap: 0; }
  #infoModal h2 { font-size: 1.1rem; margin: 0 0 0.2rem 0; text-align: center; }
  #infoModal p { font-size: 0.85rem; margin: 0.15rem 0; line-height: 1.15; }
  #infoModal small { font-size: 0.7rem; display: inline-block; margin-top: 0.1rem; line-height: 1; }
  #infoModal hr { margin: 0.3rem 0; opacity: 0.15; }
  #infoModal #info_legend_title { font-size: 0.85rem; margin-bottom: 0.2rem; }
  #infoModal .modal-content > div { font-size: 0.75rem !important; line-height: 1.2 !important; margin-bottom: 0.2rem; }
  #infoModal .info-card > div { font-size: 0.75rem !important; line-height: 1.2 !important; margin-bottom: 0.2rem; }
  #infoModal button.main { min-height: 2.5rem; padding: 0.4rem; margin-top: 0.5rem; font-size: 0.95rem; }
}

/* --- DYNAMICKÉ TRIEDY PRESUNUTÉ Z JAVASCRIPTU --- */

/* Farby pre hodnoty (INR, TAB, SYS, DIA, PULZ) */
.val-purple { background-color: #9c27b0; color: #fff; font-weight: bold; }
.val-yellow { background-color: #ffeb3b; color: #000; font-weight: bold; }
.val-green { background-color: #00e676; color: #000; font-weight: bold; }
.val-red { background-color: #ff1744; color: #fff; font-weight: bold; }
.val-blue { background-color: #2196F3; color: #fff; font-weight: bold; }
.delete-icon { cursor: pointer; }

/* Mesačný archív */
.month-header { display: flex; justify-content: space-between; align-items: center; background: var(--header); padding: 0.5rem; border-radius: 0.5rem; margin: 1.2rem 0 0.5rem 0; }
.month-header h3 { margin: 0; font-size: 1rem; border: none; padding: 0; background: transparent; }
button.main.pdf-export-btn { margin: 0; min-height: 0; padding: 0.4rem 0.6rem; width: auto; font-size: 0.8rem; background-color: #2196F3; }
.btn-monthly-archive { margin-top: 1.5rem; background-color: #444; }
.month-btn { background-color: #2196F3 !important; margin-bottom: 0.3rem;}
#monthlyArchiveListModal button[onclick*="zavrietMesacnyArchivList"], #btn_close_month { background-color: #4CAF50 !important; }
#dialogCancelBtn { background-color: #2196F3 !important; }

/* Karta liekov */
.med-item { display: flex; justify-content: space-between; align-items: center; padding: 0.6rem 0.8rem; border-radius: 0.5rem; line-height: 1.3; word-break: break-word; }
.med-item.even { background-color: rgba(76, 175, 80, 0.4); }
.med-item.odd { background-color: rgba(76, 175, 80, 0.2); }
.med-delete-btn { cursor: pointer; margin-left: 0.5rem; font-size: 1.4rem; font-weight: bold; color: #ff5252; line-height: 1; padding: 0 0.4rem; }
.empty-meds { opacity: 0.5; padding: 0.5rem 0; font-style: italic; }

/* Archív váhy */
.archive-header.weight-row, .record-row.weight-row { grid-template-columns: 45% 35% 20%; }
.record-row.weight-row { font-size: 13px; padding: 12px 5px; }
.weight-val { font-weight: bold; font-size: 14px; }
.weight-del { cursor: pointer; font-size: 16px; }
.trend-up { color: #ff1744; font-weight: 900; }
.trend-down { color: #00e676; font-weight: 900; }
.trend-flat { color: #888; font-weight: 900; }
.empty-records { text-align: center; padding: 1rem; opacity: 0.5; }