/* ====== Kořenové proměnné pro sidebar + výšku headeru ====== */
:root{
  --sidebar-w: 250px;
  --sidebar-w-collapsed: 64px;
  --navbar-height: 60px;     /* jediný zdroj pravdy pro výšku headeru */
}

/* ====== Globální layout ====== */

.content {
  margin-top: var(--navbar-height);  /* prostor pod fixním headerem */
  padding: 1rem;
}

footer {
  flex-shrink: 0;
  background-color: #fff;
  padding: 1rem 0;
  text-align: center;
}


/* ====== Header ====== */

.header {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--navbar-height);      /* fixní výška */
  background: var(--primary-color);
  color: #fff;
  display: flex;                     /* obalí .header-row */
  align-items: center;
  justify-content: flex-start;
  padding: 0 1rem;
  z-index: 1100;
}

/* Vnitřní řádek headeru: brand | pill | akce vpravo (CSS Grid) */
.header .header-row {
  display: grid;
  grid-template-columns: 1fr auto 1fr; /* brand | pill | akce */
  align-items: center;
  gap: .5rem;
  width: 100%;
}

.header .menu-toggle {
  font-size: 1.5rem;
  cursor: pointer;
  color: #fff;
}

.header .brand {
  margin-left: 1rem;
  font-weight: bold;
  color: #fff;
  text-decoration: none;
}

/* Slot pro pilulku – uprostřed */
.header .header-row .header-flash-slot {
  min-width: 0;
  justify-self: center;                 /* střed na řádku */
  max-width: clamp(160px, 40vw, 420px); /* responsivní limit */
}

.header .header-row .header-flash-slot .alert {
  border: none;
  box-shadow: none;
  margin: 0;
  line-height: 1.2;
  display: inline-flex;
  align-items: center;
  padding: .15rem .5rem;                /* kompaktní výška */
  font-size: .8rem;                     /* menší text */
  border-radius: 9999px;                /* jistota „pill“ tvaru */
}

.header .header-row .header-flash-slot .alert-success {
  background-color: var(--bs-success);
  color: #fff;
}

/* bílé X na tmavém podkladu */
.header .header-row .header-flash-slot .btn-close,
.header .header-row .header-flash-slot .btn-close-white {
  filter: invert(1);
}

/* text uvnitř pilulky (slot) – používáme .flash-msg stejně jako u overlaye */
.header .header-row .header-flash-slot .flash-msg {
  display: -webkit-box;
  -webkit-line-clamp: 2;     /* max 2 řádky */
  -webkit-box-orient: vertical;
  overflow: hidden;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
  hyphens: auto;
  line-height: 1.25;
  max-width: 100%;
}

/* Akce (obálka + zvoneček) vpravo */
.header .actions {
  justify-self: end;          /* v gridu zarovná doprava */
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  gap: 1rem;
  flex: 0 0 auto;             /* neškáluje se (nezužuje) */
}

.header .actions a {
  color: #fff;
  position: relative;         /* pro badge s absolute pozicí */
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  line-height: 1;
}

.header .actions a:hover { opacity: .9; }


/* ====== Sidebar (mobile default: off-canvas) ====== */

.sidebar {
  position: fixed;
  top: 0;
  left: -250px;
  width: 250px;
  height: 100%;
  background-color: #f4f4f4;          /* světle šedé pozadí */
  box-shadow: 2px 0 8px rgba(0, 0, 0, 0.05); /* jemný stín odleva */
  padding-top: var(--navbar-height);  /* pod fixním headerem */
  transition: left 0.3s ease, width 0.2s ease;
  overflow-y: auto;
  z-index: 1050;
}
.sidebar.open { left: 0; }

.sidebar a {
  display: flex;
  align-items: center;
  padding: 0.75rem 1rem;
  color: #000;
  text-decoration: none;
  border-left: 4px solid transparent;
  position: relative; /* kvůli badge v kolapsu */
}

.sidebar a:hover {
  background: #c8e6c9;
  border-left-color: #1b5e20;
  color: #1b5e20;
}

.sidebar-overlay {
  position: fixed;
  top: 0; left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0,0,0,0.4);
  z-index: 1040;             /* > sticky toolbary (1030–1032), < sidebar (1050) */
  display: none;
}
.sidebar-overlay.visible { display: block; }


/* ====== Tabulkové utilitky ====== */

/* Sloupce s datem/částkou: co nejmenší šířka + bez zalomení */
.col-date,
.col-amount {
  width: 1%;
  white-space: nowrap;
}


/* ====== Notification dropdown ====== */

#notificationDropdown {
  position: fixed;
  top: var(--navbar-height);
  right: 1rem;
  width: 300px;
  max-height: 400px;
  background: #fff;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
  border-radius: 0.25rem;
  display: none;
  overflow: auto;
  z-index: 1200;
}

#notificationDropdown .header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 1rem;
  border-bottom: 1px solid #ddd;
}

#notificationDropdown ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

#notificationDropdown li {
  padding: 0.5rem 1rem;
  border-bottom: 1px solid #eee;
}

#notificationDropdown li:last-child { border-bottom: none; }

#notificationDropdown a {
  color: #000;
  text-decoration: none;
}


/* ====== FLASH pilulka – overlay přes header (viditelná i nepřihlášeným) ====== */

.flash-pill-overlay {
  position: fixed;
  top: calc(var(--navbar-height) / 2); /* střed fixního headeru */
  transform: translateY(-50%);
  right: 1rem;                   /* vpravo */
  left: auto;
  z-index: 2001;                 /* nad headerem i dropdownem */
  max-width: min(94vw, 560px);   /* širší na mobilech i desktopu */
  padding: 0;
  pointer-events: none;          /* kliky propadnou, krom alertu níže */
}

/* Vzhled pilulky + grid uvnitř: ikonka | text | +N | X */
.flash-pill-overlay .alert,
.header .header-row .header-flash-slot .alert {
  pointer-events: auto;          /* umožní klik na X */
  margin: 0;
  border: none;
  box-shadow: 0 6px 20px rgba(0,0,0,.15);
  padding: .5rem .9rem;
  font-size: .95rem;
  border-radius: 9999px;
  display: grid;
  grid-template-columns: auto 1fr auto auto; /* ikona | text | +N | X */
  align-items: center;                        /* X vertikálně doprostřed */
  column-gap: .5rem;
  row-gap: .25rem;
}

/* barvy (success apod. řeší Bootstrap); bílé X na tmavém podkladu */
.flash-pill-overlay .btn-close,
.flash-pill-overlay .btn-close-white,
.header .header-row .header-flash-slot .btn-close,
.header .header-row .header-flash-slot .btn-close-white {
  filter: invert(1);
  position: static;              /* grid se postará o pozici vpravo */
  width: .95rem;
  height: .95rem;
  margin: 0 0 0 .25rem;
  opacity: .9;
}

/* Text: max 2 řádky, zalamování dlouhých slov/URL */
.flash-pill-overlay .flash-msg,
.header .header-row .header-flash-slot .flash-msg {
  display: -webkit-box;
  -webkit-line-clamp: 2;         /* MAX 2 řádky */
  -webkit-box-orient: vertical;
  overflow: hidden;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
  hyphens: auto;
  line-height: 1.25;
  max-width: 100%;
}

/* Odznak +N s malým odsazením */
.flash-pill-overlay .alert .badge,
.header .header-row .header-flash-slot .alert .badge {
  margin-left: .15rem;
}

/* Jemné doladění na velmi malých šířkách */
@media (max-width: 520px) {
  .flash-pill-overlay { max-width: 96vw; right: .5rem; }
  .flash-pill-overlay .alert { padding: .45rem .75rem; font-size: .9rem; }
}


/* ====== Desktop rozšíření: mini-collapsible sidebar ====== */
@media (min-width: 992px) {
  /* Sidebar je na desktopu stále viditelný, ne off-canvas */
  .sidebar {
    left: 0;                    /* dock vlevo */
    width: var(--sidebar-w);    /* plná šířka */
  }

  /* Obsah odsadíme od sidebaru */
  .content {
    margin-left: var(--sidebar-w);
  }

  /* Kolaps: pouze ikonky */
  html.sidebar-collapsed .sidebar {
    width: var(--sidebar-w-collapsed);
  }
  html.sidebar-collapsed .content {
    margin-left: var(--sidebar-w-collapsed);
  }

  /* V kolapsu schovat textové labely a zbytečné prvky */
  html.sidebar-collapsed .sidebar .nav-label,
  html.sidebar-collapsed .sidebar .text-uppercase.small,
  html.sidebar-collapsed .sidebar hr,
  html.sidebar-collapsed #emailCollapse,
  html.sidebar-collapsed .collapse-icon,
  html.sidebar-collapsed .sidebar .small.text-muted {
    display: none !important;
  }

  /* Centrovat odkazy v kolapsu; badge ponechat vpravo nahoře */
  html.sidebar-collapsed .sidebar a { justify-content: center; }
  html.sidebar-collapsed .sidebar a .badge {
    position: absolute; right: 10px; top: 6px;
  }
}