/* --- Reset/struktura bazowa --- */
html, body {
  height: 100%;
  margin: 0;
  padding: 0;
}
body {
  font-family: sans-serif;
  display: flex;
  flex-direction: column;
  height: 100vh;
  box-sizing: border-box;
}

/* --- Header / Footer --- */
header {
  height: 50px;
  background-color: #df0000;
  color: white;
  display: grid;
  grid-template-columns: auto 1fr auto; /* lewo | środek | prawo */
  align-items: center;
  padding: 0 20px;
  font-size: 20px;
  box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}
.header-left   { justify-self: start; }
.header-center { justify-self: center; text-align: center; }
.header-right  { justify-self: end; }

footer {
  height: 40px;
  background-color: #eee;
  text-align: center;
  font-size: 14px;
  line-height: 40px;
  border-top: 1px solid #ccc;
}

/* --- Główna sekcja: 3 panele: lewy | środek | prawy --- */
.main {
  flex: 1;
  display: flex;         /* 3-kolumnowy layout */
  overflow: hidden;
}

/* Lewy panel (menu) */
.sidebar {
  width: 200px;
  background-color: #f4f4f4;
  padding: 10px;
  border-right: 1px solid #ccc;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  box-sizing: border-box;
}
.menu-top {
  display: flex;
  flex-direction: column;
}
.menu-bottom {
  border-top: 1px solid #ccc;
  padding-top: 10px;
  margin-top: 10px;
  display: flex;
  flex-direction: column;
}

/* Linki w menu */
.sidebar a {
  display: block;
  margin: 6px 0;
  text-decoration: none;
  color: #333;
}
.sidebar a:hover {
  color: #0074D9;
}
.sidebar a.active-link {
  font-weight: bold;
  color: #df0000;
}

/* Sekcje menu */
.sidebar details { margin-top: 10px; }
.sidebar summary {
  cursor: pointer;
  font-weight: normal;
  margin: 6px 0;
  padding: 4px;
  background-color: transparent;
  border-radius: 3px;
}
.sidebar details[open] summary {
  background-color: #d0d0d0;
}
.sidebar details a {
  margin: 4px 0 4px 24px;
  font-size: 1em;
  display: block;
  color: #444;
}
.sidebar details a:hover {
  color: #0074D9;
  text-decoration: underline;
}

/* Środkowy panel (treść) */
.content {
  flex: 1 1 auto;
  padding: 20px;
  overflow-y: auto;
  box-sizing: border-box;
  min-width: 0; /* ważne, żeby treść się nie rozpychała kosztem prawego panelu */
}

/* Prawy panel (telefon) */
.rightbar {
  width: 360px;                    /* stała szerokość prawego panelu */
  max-width: 40vw;                 /* na węższych ekranach niech nie zajmuje za dużo */
  border-left: 1px solid #ccc;
  padding: 12px;
  background: #fafafa;
  overflow-y: auto;                /* niezależne przewijanie w panelu */
  box-sizing: border-box;
}

.rightbar {
  width: 340px;                    /* lub jaką masz szerokość */
  min-width: 280px;
  border-left: 1px solid #ccc;
  padding: 10px;
  overflow-y: auto;
  transition: width .2s ease, min-width .2s ease, padding .2s ease, opacity .2s ease;
}

.rightbar--hidden {
  width: 0;
  min-width: 0;
  padding: 0;
  opacity: 0;
  border-left: none;
  pointer-events: none;         /* brak interakcji gdy schowany */
}

/* Na bardzo małych ekranach domyślnie schowaj prawy panel */
@media (max-width: 900px) {
  .rightbar {
    width: 0;
    min-width: 0;
    padding: 0;
    opacity: 0;
    border-left: none;
    pointer-events: none;
  }
}

#togglePhoneBtn {
  border: 0;
  background: #fff;
  padding: 6px 10px;
  border-radius: 6px;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(0,0,0,.1);
}
#togglePhoneBtn:hover { background: #f5f5f5; }

/* Użyteczne klaski/utility */
.sticky-header {
  position: sticky;
  top: 0;
  background-color: white;
  z-index: 100;
}

/* Tabele */
.table-container { max-height: 1000px; overflow-y: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 2px;
}
th, td {
  border: 1px solid #ccc;
  padding: 8px 12px;
  text-align: left;
}
th { background-color: #f5f5f5; }
tr:nth-child(even) { background-color: #fafafa; }
thead th {
  position: sticky;
  top: 0;
  background-color: #f2f2f2;
  z-index: 50;
}

/* Nagłówki raportów / filtry */
.header-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  padding: 8px 10px;
  background-color: white;
  z-index: 100;
  border-bottom: 1px solid #ccc;
}
.header-bar h2 { margin: 0; }

.date-filter-form {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.date-filter-form input[type="date"] {
  padding: 4px;
  font-size: 0.9rem;
}
.date-filter-form button {
  padding: 6px 12px;
  font-size: 0.9rem;
  background-color: #df0000;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
}
.date-filter-form button:hover {
  background-color: #b90000;
}

/* Sort w nagłówkach tabel */
th a { color: black; text-decoration: none; }
th a.active-sort { color: #df0000; font-weight: bold; }
