/* ========================= */
/*    Info dla przeglądarki  */
/* ========================= */

:root {
  color-scheme: light dark;
}

html.preload #sidebar,
html.preload #sidebar * {
  transition: none !important;
}

/* ========================= */
/*          Logo             */
/* ========================= */

.logo {
  display: block;
  width: 100%;
  height: auto;
  max-width: 300px;
  margin: 0 auto 1rem auto;
}

body.app-body.dark .logo {
  filter: brightness(0) invert(1);
}

/* ========================= */
/*      Toggle Theme Button  */
/* ========================= */
.theme-btn {
  z-index: 10000;
  pointer-events: auto;
}

.theme-btn i {
  pointer-events: none;
}

#sidebar {
  overflow: visible;
}

#toggle-sidebar .chev {
  transition: transform .15s ease;
}

#sidebar.collapsed #toggle-sidebar .chev {
  transform: rotate(180deg);
}

/* (na wszelki) dopilnuj, że przycisk jest widoczny */
#toggle-sidebar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* domyślny kolor ikon w przycisku */
#toggle-sidebar .chev {
  color: var(--text);
  /* bierze z motywu */
  transition: transform .15s ease, color .15s ease;
}

/* rotacja przy zwinięciu */
#sidebar.collapsed #toggle-sidebar .chev {
  transform: rotate(180deg);
}

/* jeśli przycisk lekko „wystaje” przy zwiniętym */

.theme-btn {
  position: fixed;
  top: 1rem;
  right: 1rem;
  background: var(--form-bg);
  border: 1px solid var(--form-border);
  backdrop-filter: blur(8px);
  color: var(--text-color);
  padding: 0.6rem 0.8rem;
  border-radius: 8px;
  cursor: pointer;
  font-size: 1rem;
  z-index: 1000;
  transition: all 0.2s ease-in-out;
}

.theme-btn:hover {
  background: var(--btn-bg);
  color: var(--btn-text);
}

/* ========================= */
/*      Login Wrapper        */
/* ========================= */
.login-wrapper {
  position: absolute;
  /* centrowanie względem okna */
  inset: 0;
  /* top/right/bottom/left: 0 */
  width: 420px;
  height: 540px;
  /* wrapper = dokładnie rozmiar karty */
  margin: auto;
  /* środek ekranu */
  padding: 0;
  display: flex;
  align-items: stretch;
  justify-content: stretch;
  /* respons gdy ekran bardzo wąski */
  max-width: 92vw;
}

/* ========================= */
/*      Login Container      */
/* ========================= */
.login-container {
  width: 100%;
  height: 100%;
  /* karta wypełnia wrapper 1:1 */
  background: var(--card);
  border-radius: 0.8rem;
  box-shadow: var(--table-shadow);
  padding: 2rem;
  box-sizing: border-box;

  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: center;
  gap: 1.2rem;

  transition: all 0.3s ease;
  overflow: hidden;
}

.login-container .logo {
  height: 100px;
  object-fit: contain;
  user-select: none;
}

.login-container form {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}

.login-container input {
  padding: 0.6rem 1rem;
  border-radius: 0.5rem;
  border: 1px solid rgba(0, 0, 0, 0.1);
  background: rgba(255, 255, 255, 0.6);
  color: inherit;
  font-size: 1rem;
  box-sizing: border-box;
  outline: none;
}

body.dark-mode .login-container input {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.login-container button {
  padding: 0.7rem;
  border-radius: 0.5rem;
  background: var(--accent);
  border: none;
  color: white;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

.login-container button:hover {
  background: #005ecb;
}

/* ========================= */
/*       Login Bottom        */
/* ========================= */
.login-bottom {
  margin-top: auto;
  text-align: center;
  padding-bottom: 1rem;
}

.login-actions {
  display: flex;
  gap: 1rem;
  font-size: 0.9rem;
}

.login-actions a {
  color: var(--accent);
  text-decoration: none;
}

.login-actions a:hover {
  text-decoration: underline;
}

.error {
  color: red;
  font-size: 0.9rem;
  text-align: center;
}

/* ========================= */
/*         Layout App        */
/* ========================= */

.app-layout {
  display: flex;
  min-height: 100vh;
  width: 100%;
  overflow: hidden;
}

/* ========================= */
/*        Sidebar            */
/* ========================= */

#sidebar {
  width: min(240px, 20vw);
  /* max 240px, ale może być mniej na małych ekranach */
  flex-shrink: 0;
  background: var(--card);
  color: var(--text);
  box-shadow: var(--table-shadow);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  height: 100%;
  overflow-y: auto;
  z-index: 1000;
  overflow: hidden;
  transition: width 0.3s ease;
}

.sidebar-header {
  text-align: center;
  margin-bottom: 1rem;
  padding: 1rem;
  border-bottom: 1px solid rgba(0, 0, 0, 0.1);
  /* separator górny */
}

.sidebar-header .logo {
  height: 32px;
  width: auto;
  margin: 0 auto;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  padding: 0 1rem 2rem;
  flex-grow: 1;
  /* <-- klucz do poprawnego wypychania footeru na dół */
}

.sidebar-btn {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  background: none;
  border: none;
  color: var(--text);
  text-align: left;
  font-size: 0.95rem;
  padding: 0.6rem 1rem;
  border-radius: 0.6rem;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.2s ease, color 0.2s ease, gap 0.3s ease;
}

.sidebar-btn:hover {
  background: var(--glass);
  color: var(--accent);
}

.sidebar-footer {
  padding: 1rem;
  border-top: 1px solid rgba(0, 0, 0, 0.1);
  /* separator dolny */
  text-align: center;
  display: flex;
  justify-content: center;
}

.sidebar-icon {
  font-size: 1.5rem;
  width: 1.8rem;
  height: 1.5rem;
  display: inline-block;
  text-align: center;
  vertical-align: middle;
  flex-shrink: 0;
}

.logout-btn {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 0.9rem;
  cursor: pointer;
  padding: 0.5rem 0.8rem;
  border-radius: 0.5rem;
  transition: background 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.logout-btn:hover {
  background: var(--glass);
}

.sidebar-footer form {
  width: 100%;
  display: flex;
  justify-content: center;
}

/* ========================= */
/*      Sidebar - Collapse   */
/* ========================= */

#sidebar.collapsed {
  width: 60px;
  transition: width 0.3s ease;
  overflow: hidden;
}

#sidebar.collapsed .sidebar-label {
  transition: opacity 0.3s ease;
  display: none;
}

#sidebar.collapsed .sidebar-btn {
  justify-content: center;
  gap: 0;
  /* ważne przy braku labelki */
}

#sidebar.collapsed .sidebar-icon {
  margin-right: 0;
}

#sidebar.collapsed .logo {
  max-width: 40px;
  margin: 0 auto;
  transition: all 0.3s ease;
}

/* ========================= */
/*     Toggle Sidebar Btn    */
/* ========================= */

#toggle-sidebar {
  position: absolute;
  right: -0.6rem;
  top: 50%;
  transform: translateY(-50%);
  background: var(--card);
  border: none;
  border-radius: 50%;
  width: 2rem;
  height: 2rem;
  box-shadow: var(--table-shadow);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.3s ease, background 0.3s;
  z-index: 10;
}

#sidebar.collapsed #toggle-sidebar i {
  transform: rotate(180deg);
}

/* ========================= */
/*     Sidebar - Logo       */
/* ========================= */
/* Ustal konkretne, całkowite piksele (dopasuj liczby do swoich) */
.full-logo {
  width: 128px;
  height: auto;
}

.collapsed-logo {
  width: 28px;
  height: 28px;
}

/* 2) Przełączanie widoczności – bez skalowania jednego pliku */
.full-logo {
  display: block;
}

.collapsed-logo {
  display: none;
  margin: 0 auto;
}

#sidebar.collapsed .full-logo {
  display: none;
}

#sidebar.collapsed .collapsed-logo {
  display: block;
}

/* ========================= */
/*        Main Content       */
/* ========================= */

#main-content {
  margin-left: 240px;
  padding: 2rem;
}

.app-main {
  flex: 1;
  min-width: 0;
  overflow-x: auto;
  display: flex;
  justify-content: center;
  align-items: stretch;
  box-sizing: border-box;
  margin-left: 0;
  /* domyślnie nic nie zabiera */
  transition: margin-left .3s ease;
  /* odsuwamy content */
}

#sidebar:not(.collapsed)~.app-main {
  margin-left: min(240px, 20vw);
  /* miejsce tylko gdy pasek otwarty */
}

/* ========================= */
/*     Użytkownicy - Tabela  */
/* ========================= */

.users-container {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 1000px;
  margin: 4rem auto 0 auto;
  /* ⬅ lepiej czytelnie napisać wszystkie */
  /*             ↑   ↑
       góra — 4rem   poziom — auto */

  background: var(--card);
  padding: 2rem;
  border-radius: 0.8rem;
  box-shadow: var(--table-shadow);
  font-size: 0.9rem;
  color: var(--text);
  box-sizing: border-box;
}


.users-container h2 {
  margin-bottom: 1.5rem;
  font-size: 1.3rem;
  text-align: center;
  color: var(--text);
}

.users-table {
  width: 100%;
  border-collapse: collapse;
  border-radius: var(--table-radius);
  overflow: hidden;
}

.users-table thead {
  background: var(--glass);
  color: var(--text);
}

.users-table th,
.users-table td {
  padding: 0.8rem 1rem;
  text-align: left;
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.users-table tr:last-child td {
  border-bottom: none;
}

.status-dot {
  width: 1rem;
  height: 1rem;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  display: inline-block;
}

.status-dot.active {
  background: #28a745;
  /* zielony */
}

.status-dot.inactive {
  background: #dc3545;
  /* czerwony */
}

.btn-delete {
  background: #dc3545;
  color: white;
  border: none;
  border-radius: 0.5rem;
  padding: 0.4rem 0.8rem;
  cursor: pointer;
  font-size: 0.85rem;
  transition: background 0.2s;
}

.btn-delete:hover {
  background: #a71d2a;
}

/* ========================= */
/*       Panel – Kafelki     */
/* ========================= */

.tiles-container {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr));
  gap: 1.2rem;
  width: 100%;
  max-width: 1000px;
  margin: 0 auto;
  padding: 64px 2rem 2rem;
  /* ↑ tu padding od góry */
  justify-content: center;
  /* trzyma kafelki w środku */
  overflow-x: hidden;
  box-sizing: border-box;
}

.tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--card);
  color: var(--text);
  border-radius: 0.8rem;
  box-shadow: var(--table-shadow);
  padding: 1rem 1rem;
  text-align: center;
  text-decoration: none;
  transition: transform 0.15s ease, background 0.15s ease;
  min-height: 150px;
}

.tile:hover {
  background: var(--glass);
  transform: translateY(-2px);
  color: var(--accent);
}

.tile-icon {
  font-size: 2rem;
  margin-bottom: 0.6rem;
}

.tile-label {
  font-size: 0.95rem;
}

/* Kafel "W przygotowaniu" – nieklikalny i wyszarzony */
.tile.disabled {
  pointer-events: none;
  opacity: 0.6;
}

/* ========================= */
/*  TEST: Sidebar na dole    */
/*  Zakres: max-width: 768px */
/* ========================= */
@media (max-width: 768px) {
  :root {
    --mobile-bottom-bar-h: 64px;
  }

  /* Pasek dolny – na dół, pełna szerokość, JEDEN RZĄD */
  #sidebar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0 !important;
    top: auto !important;
    width: 100% !important;
    max-width: 100% !important;
    height: calc(var(--mobile-bottom-bar-h) + env(safe-area-inset-bottom));
    padding: 0 env(safe-area-inset-left) env(safe-area-inset-bottom) env(safe-area-inset-right);

    display: flex;
    flex-direction: row !important;
    /* <<< klucz: wymuś poziomo */
    align-items: stretch;
    justify-content: stretch;
    gap: 0;

    background: var(--card);
    box-shadow: 0 -6px 18px rgba(0, 0, 0, .15);
    border-radius: 0;
    z-index: 1000;
  }

  /* Niepotrzebne elementy */
  #sidebar .sidebar-header,
  #sidebar .sidebar-section-title,
  #toggle-sidebar {
    display: none !important;
  }

  /* Spłaszcz grupy, żeby dzieci (linki + logout) były rodzeństwem */
  #sidebar .sidebar-nav,
  #sidebar .sidebar-footer,
  #sidebar .sidebar-footer form {
    display: contents;
  }

  /* Każdy kafelek = równa szerokość; tylko ikonka */
  #sidebar a.sidebar-btn,
  #sidebar .logout-btn {
    display: flex !important;
    align-items: center;
    justify-content: center;
    flex: 1 1 0;
    /* równe kafelki */
    min-width: 0;
    width: auto !important;
    /* nadpisz ewentualne width:100% z desktopu */
    padding: 8px 0;
  }

  /* Logout to <button> – neutralny wygląd */
  #sidebar .logout-btn {
    background: none;
    border: 0;
    color: inherit;
    cursor: pointer;
  }

  /* Tylko ikony (bez labeli) */
  #sidebar .sidebar-label {
    display: none !important;
  }

  #sidebar .sidebar-icon,
  #sidebar .logout-btn i {
    width: 22px;
    height: 22px;
    display: block;
  }

  /* Treść nad paskiem */
  .app-main,
  main,
  #content,
  .main-container {
    margin-left: 0 !important;
    padding-bottom: calc(var(--mobile-bottom-bar-h) + env(safe-area-inset-bottom) + 16px);
  }
}

/* ========================= */
/*  Sidebar - Disabled Btn   */
/* ========================= */
.sidebar-btn.disabled {
  opacity: 0.4;
  /* wyszarzone */
  pointer-events: none;
  /* nie da się kliknąć */
  cursor: not-allowed;
  /* pokazuje brak możliwości */
}

/* ===== Flash popup ===== */
.flash-stack {
  position: fixed;
  inset: 0;
  /* nie rozpycha układu */
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 2000;
  gap: 12px;
  /* kilka naraz = kolumna */
  pointer-events: none;
  /* klik przechodzi, oprócz kart */
}

.flash {
  pointer-events: auto;
  max-width: min(560px, 92vw);
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--glass-border);
  border-radius: .8rem;
  padding: .9rem 1.1rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .25);
  font-size: .95rem;
  display: flex;
  align-items: center;
  gap: .75rem;
  opacity: 0;
  transform: translateY(6px) scale(.98);
  animation: flash-in .18s ease-out forwards;
}

.flash .flash-close {
  margin-left: .5rem;
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: .5rem;
  cursor: pointer;
  background: var(--glass);
  color: var(--text);
}

/* warianty */
.flash.success {
  border-color: #2ecc71;
}

.flash.error {
  border-color: #e74c3c;
}

.flash.info {
  border-color: #3498db;
}

@keyframes flash-in {
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* wygaszanie */
.flash.flash-hide {
  transition: opacity .18s ease, transform .18s ease;
  opacity: 0;
  transform: translateY(6px) scale(.98);
}