@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;600;700&display=swap');

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* Sidebar Container */
.sidebar-container {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 10000; /* ↑ garante que fica acima de tudo em mobile */
}

/* Sidebar Style */
.sidebar {
  position: fixed;
  top: 0;
  left: -250px;
  width: 250px;
  height: 100vh; /* em mobile vamos trocar para 100dvh */
  background-color: white;
  box-shadow: 2px 0 12px rgba(0, 0, 0, 0.15);
  transition: left 0.3s ease;
  display: flex;
  flex-direction: column;
}

.sidebar.active {
  left: 0;
}

/* Sidebar Header */
.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  border-bottom: 1px solid #eee;
  position: relative;
}

/* Logo Style */
.sidebar-logo {
  display: block;
  max-width: 150px;
  margin: 0 auto;
  transition: opacity 0.3s ease;
}

/* Sidebar Search Bar */
.sidebar-search {
  padding: 10px 20px;
  border-bottom: 1px solid #eee;
}

.input-with-filter {
  position: relative;
}

/* Sidebar Search Input */
.input-with-filter input {
  width: 100%;
  padding: 10px 44px 10px 10px; /* mais área táctil */
  border: 1px solid #ccc;
  border-radius: 6px;
  font-size: 14px;
}

/* Sidebar Filter Button */
.sidebar-filter-btn {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: none;
  font-size: 18px;
  cursor: pointer;
  z-index: 10;
  color: #006AFF;
}

.sidebar-filter-btn:focus {
  outline: none;
}

/* Navigation Style */
.sidebar-nav {
  margin-top: 10px;
  flex: 1;
  overflow-y: auto;         /* scrolla a lista */
  scrollbar-width: none; 
  -webkit-overflow-scrolling: touch;
  padding-bottom: 72px;     /* espaço para não ficar por baixo do footer */
}

.sidebar-nav::-webkit-scrollbar { display: none; }

.sidebar-nav ul { list-style: none; }

/* Menu Item Style */
.menu-item a {
  display: block;
  padding: 14px 20px;
  color: #333;
  text-decoration: none;
  transition: background 0.2s, color 0.2s;
  font-size: 14px;
}

.menu-item a:hover { background: #006AFF; color: #fff; }

/* Active */
.menu-item a.active { background: #006AFF; color: #fff; }

/* Sidebar btn (abrir) */
.open-sidebar-btn {
  position: fixed;
  top: 20px;
  left: 20px;
  background-color: #006AFF;
  border: none;
  color: #fff;
  border-radius: 50%;
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  cursor: pointer;
  z-index: 11000; /* acima da sidebar */
}

.open-sidebar-btn:hover { background-color: #006AFF; }

/* close sidebar icon */
.hamburger-icon {
  position: absolute;
  top: 6px;
  right: 6px;
  background: transparent;
  border: none;
  cursor: pointer;
  width: 24px;
  height: 18px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: flex-start;
  gap: 3px;
  padding: 0;
}

.hamburger-icon .bar {
  display: block;
  height: 2px;
  background-color: #006AFF;
  border-radius: 2px;
  transition: all 0.3s;
}

.hamburger-icon .bar:nth-child(1) { width: 70%; }
.hamburger-icon .bar:nth-child(2) { width: 50%; }
.hamburger-icon .bar:nth-child(3) { width: 30%; }

/* Sidebar Footer (Settings and Login section) */
.sidebar-footer {
  position: sticky;   /* fixa no fim do fluxo da coluna */
  bottom: 0;
  margin-top: auto;   /* empurra para o fundo */
  width: 100%;
  border-top: 1px solid #eee;
  padding: 10px 10px;
  display: flex;
  justify-content: space-between;
  background: white;
  gap: 8px;
}

.sidebar-footer-item {
  text-decoration: none;
  color: #333;
  display: inline-flex;
  align-items: center;
  font-size: 14px;
  gap: 6px;
  padding: 10px 12px;           /* maior target táctil */
  border-radius: 8px;
}

.sidebar-footer-item:hover { color: #006AFF; background: #f3f7ff; }

/* --- Breakpoints --- */

/* 1450px */
@media only screen and (max-width: 1450px) {
  .sidebar { width: 220px; left: -220px; }
  .sidebar.active { left: 0; }
}

/* 1100px */
@media only screen and (max-width: 1100px) {
  .sidebar { width: 200px; left: -200px; }
  .sidebar.active { left: 0; }
}

/* 600px — MODO “DRAWER” A TODA A LARGURA */
@media only screen and (max-width: 600px) {
  .sidebar {
    width: 100vw;         /* ocupa o ecrã todo */
    left: -100vw;         /* escondida fora do ecrã */
    height: 100dvh;       /* respeita barra de URL móvel */
  }
  .sidebar.active { left: 0; }
  .open-sidebar-btn { left: 10px; top: 12px; }
}

/* --- Filter Style--- */
.filter-menu {
  position: absolute;
  top: 110%;
  right: 0;
  background: #fff;
  border: 1px solid #ccc;
  border-radius: 8px;
  padding: 8px 0;
  box-shadow: 0 2px 6px rgba(0,0,0,0.15);
  display: none;
  z-index: 100002; 
  min-width: 140px;
}

.filter-category {
  padding: 6px 10px;
  border-bottom: 1px solid #eee;
}
.filter-category:last-child { border-bottom: none; }

.filter-category-title {
  font-size: 0.9rem;
  font-weight: bold;
  margin-bottom: 6px;
  display: block;
  color: #006AFF;
}

.filter-menu button {
  width: 100%;
  background: none;
  border: none;
  text-align: left;
  padding: 8px 15px;
  cursor: pointer;
  border-radius: 6px;
  font-family: 'Poppins', sans-serif;
  transition: background 0.2s;
  font-size: 14px;
}

.filter-menu button:hover,
.filter-menu button.active { background: #f1f1f1; }

/* Modal “Filter by Tag” */
#filterByTagModal .modal-dialog { max-width: 300px; }
#filterByTagModal .modal-header { padding: 8px 15px; }
#filterByTagModal .modal-body { padding: 15px; }
#filterByTagModal #tagSearchInput { font-size: 0.9rem; padding: 5px; }
#filterByTagModal #tagList .list-group-item { font-size: 0.9rem; padding: 5px 10px; }

/* ================================ */
/* Night Mode Adjustments for Sidebar */
/* ================================ */
body.night-mode .sidebar { background-color: #1e1e1e !important; color: #ffffff !important; }
body.night-mode .sidebar-header { border-bottom: 1px solid #444444 !important; }
body.night-mode .sidebar-search { border-bottom: 1px solid #444444 !important; }
body.night-mode .sidebar-search input { background-color: #2c2c2c !important; border: 1px solid #444444 !important; color: #ffffff !important; }
body.night-mode .sidebar-filter-btn { color: #ffffff !important; }
body.night-mode .menu-item a { color: #ffffff !important; }
body.night-mode .menu-item a:hover { background: #006AFF !important; color: #ffffff !important; }
body.night-mode .menu-item a.active { background: #006AFF !important; color: #ffffff !important; }
body.night-mode .sidebar-footer { background: #1e1e1e !important; border-top: 1px solid #444444 !important; }
body.night-mode .sidebar-footer-item { color: #ffffff !important; }
body.night-mode .sidebar-footer-item:hover { color: #ffffff !important; background: #2c2c2c !important; }
body.night-mode .hamburger-icon .bar { background-color: #ffffff !important; }
body.night-mode .filter-menu { background: #1e1e1e !important; border: 1px solid #444444 !important; color: #ffffff !important; }
body.night-mode .filter-menu .filter-category-title { color: #6aa8ff !important; }
body.night-mode .filter-menu button { background: none !important; color: #ffffff !important; }
body.night-mode .filter-menu button:hover,
body.night-mode .filter-menu button.active { background: #2c2c2c !important; }

/* Bloqueio de scroll no body quando a sidebar está aberta */
body.no-scroll { overflow: hidden; }

/* ----- Garantir que o último item não fica tapado ----- */
.sidebar-nav {
  /* valor de base; será sobrescrito em runtime pelo JS abaixo */
  --sidebar-footer-h: 84px;
  padding-bottom: calc(env(safe-area-inset-bottom, 0px) + var(--sidebar-footer-h));
}

/* Último item ganha margem de scroll para nunca ficar por baixo do footer */
#sidebar-menu .menu-item:last-child a {
  scroll-margin-bottom: calc(env(safe-area-inset-bottom, 0px) + 120px);
}

/* Fallback extra: um espaçador visual no fim da lista */
.sidebar-nav::after {
  content: "";
  display: block;
  height: calc(env(safe-area-inset-bottom, 0px) + var(--sidebar-footer-h));
}
