.sidebar {
  width: 320px;
  background: var(--bg-sidebar);
  height: 100vh;
  display: flex;
  flex-direction: column;
  box-shadow: 4px 0 15px var(--shadow);
  transition: left 0.3s ease;
  flex-shrink: 0;
  position: fixed;
  left: 0;
  top: 0;
  z-index: 100;
  overflow: hidden;
}

.sidebar-header {
  background: var(--primary);
  color: white;
  padding: 24px 16px 16px 16px;
  position: relative;
  width: 100%;
  z-index: 9;
  box-sizing: border-box;
  flex-shrink: 0;
}

.header-top {
  display: flex;
  align-items: center;
  gap: 15px;
  margin-bottom: 20px;
}

.header-icon {
  font-size: 2.2rem;
}

.sidebar-header h1 {
  font-size: 1.3rem;
  font-weight: 700;
  line-height: 1.2;
}

.sidebar-header p {
  font-size: 0.75rem;
  opacity: 0.8;
  font-weight: 300;
}

.search-box {
  position: relative;
  margin-top: 10px;
}

.search-box input {
  width: 100%;
  padding: 12px 15px;
  padding-right: 40px;
  border-radius: 22px;
  border: none;
  background: rgba(255,255,255,0.15);
  color: white;
  font-family: inherit;
  font-size: 16px;
}

.search-box input::placeholder {
  color: rgba(255,255,255,0.6);
}

.search-icon {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  opacity: 0.6;
}

.sidebar-content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 12px 8px 20px 16px;
  max-width: 320px;
  width: 320px;
  box-sizing: border-box;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}

.sidebar-content::-webkit-scrollbar {
  width: 8px;
}

.sidebar-content::-webkit-scrollbar-track {
  background: transparent;
}

.sidebar-content::-webkit-scrollbar-thumb {
  background: #ccc;
  border-radius: 4px;
  transition: background 0.2s;
}

.sidebar-content::-webkit-scrollbar-thumb:hover {
  background: #999;
}

/* Scrollbar per Firefox */
.sidebar-content {
  scrollbar-width: thin;
  scrollbar-color: #ccc transparent;
}

.section-label {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-muted);
  padding: 0 16px 10px 16px;
  letter-spacing: 1px;
}

.categories-list {
  display: flex;
  flex-direction: column;
  padding: 0 8px 0 8px;
}

.cat-item {
  display: flex;
  align-items: center;
  padding: 10px 8px 10px 16px;
  margin: 0 0 2px 0;
  cursor: pointer;
  transition: background 0.2s;
  border-left: 4px solid transparent;
  border-radius: 22px;
}

.cat-item:hover {
  background: #f8f9fa;
}

.cat-item.active {
  background: #ebfcff;
  border-left-color: var(--primary);
  border-radius: 25px;
}

.cat-icon {
  width: 32px;
  height: 32px;
  background: #f0f0f0;
  border-radius: 25px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-right: 15px;
  font-size: 1.1rem;
}

.cat-item.active .cat-icon {
  background: #b6f0ed;
  color: white;
}

.cat-name {
  flex: 1;
  font-size: 0.9rem;
  font-weight: 500;
  color: #444;
}

.cat-count {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* Stili per i gruppi di categorie */
.cat-group {
  margin-bottom: 8px;
  display: flex;
  flex-direction: column;
}

.cat-group-header {
  display: flex;
  align-items: center;
  padding: 10px 8px 10px 16px;
  margin: 8px 0 2px 0;
  cursor: pointer;
  transition: background 0.2s;
  border-radius: 22px;
  font-weight: 600;
  color: #333;
  user-select: none;
}

.cat-group-header:hover {
  background: #f8f9fa;
}

.cat-group-header.expanded {
  background: #f0f0f0;
}

.cat-group-header .cat-icon {
  margin-right: 12px;
  width: 28px;
  height: 28px;
  font-size: 1.1rem;
}

.expand-icon {
  margin-left: auto;
  font-size: 0.7rem;
  transition: transform 0.2s;
}

.cat-group-items {
  display: flex;
  flex-direction: column;
  padding-left: 16px;
  margin-bottom: 4px;
}

.cat-subitem {
  padding-left: 24px;
  padding-right: 8px;
  font-size: 0.85rem;
}

.cat-subitem .cat-icon {
  width: 28px;
  height: 28px;
  font-size: 0.9rem;
  margin-right: 12px;
  background: transparent;
}

.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid #eee;
  background: #fafafa;
  max-width: 320px;
  box-sizing: border-box;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.file-info {
  font-size: 0.7rem;
  color: #aaa;
  font-style: italic;
  display: flex;
  align-items: center;
  justify-content: center;
}

.file-info a {
  display: flex;
  align-items: center;
  justify-content: center;
}

.file-info img {
  width: 24px;
  height: 24px;
  transition: transform 0.2s ease;
}

.file-info a:hover img {
  transform: scale(1.1);
}

/* Tablet - 768px e sotto */
@media (max-width: 768px) {
  .sidebar {
    width: 75vw;
    position: fixed;
    left: -75vw;
    transition: left 0.3s ease;
  }
  
  .sidebar.open {
    left: 0;
  }
  
  .sidebar-header,
  .sidebar-content,
  .sidebar-footer {
    max-width: 75vw;
    width: 75vw;
  }
  
  .header-icon {
    font-size: 1.8rem;
  }
  
  .sidebar-header h1 {
    font-size: 1.1rem;
  }
  
  .cat-item {
    padding: 8px 8px 8px 12px;
  }
  
  .cat-icon {
    width: 28px;
    height: 28px;
    margin-right: 12px;
  }
}

/* Smartphone grande - 480px e sotto */
@media (max-width: 480px) {
  .sidebar {
    width: 85vw;
    left: -85vw;
  }
  
  .sidebar-header,
  .sidebar-content,
  .sidebar-footer {
    max-width: 85vw;
    width: 85vw;
  }
  
  .sidebar-header {
    padding: 16px 12px 12px 12px;
  }
  
  .header-top {
    gap: 10px;
    margin-bottom: 15px;
  }
  
  .header-icon {
    font-size: 1.5rem;
  }
  
  .sidebar-header h1 {
    font-size: 1rem;
  }
  
  .sidebar-header p {
    font-size: 0.65rem;
  }
  
  .search-box input {
    padding: 10px 12px;
    padding-right: 35px;
    font-size: 14px;
  }
  
  .section-label {
    font-size: 0.65rem;
    padding: 0 12px 8px 12px;
  }
  
  .cat-item {
    padding: 8px 6px 8px 10px;
    margin: 0 0 1px 0;
  }
  
  .cat-icon {
    width: 26px;
    height: 26px;
    margin-right: 10px;
    font-size: 0.95rem;
  }
  
  .cat-name {
    font-size: 0.85rem;
  }
  
  .cat-count {
    font-size: 0.75rem;
  }
  
  .cat-group-header {
    padding: 8px 6px 8px 10px;
    font-size: 0.9rem;
  }
  
  .cat-group-header .cat-icon {
    width: 24px;
    height: 24px;
    margin-right: 10px;
  }
  
  .sidebar-footer {
    padding: 10px 12px;
  }
  
  .file-info {
    font-size: 0.65rem;
  }
}

/* Smartphone piccolo - 360px e sotto */
@media (max-width: 360px) {
  .sidebar {
    width: 90vw;
    left: -90vw;
  }
  
  .sidebar-header,
  .sidebar-content,
  .sidebar-footer {
    max-width: 90vw;
    width: 90vw;
  }
  
  .header-top {
    gap: 8px;
    margin-bottom: 12px;
  }
  
  .header-icon {
    font-size: 1.3rem;
  }
  
  .header-icon img {
    width: 48px !important;
    height: 48px !important;
  }
  
  .sidebar-header h1 {
    font-size: 0.9rem;
  }
  
  .cat-item,
  .cat-group-header {
    padding: 6px 4px 6px 8px;
  }
  
  .cat-icon {
    width: 24px;
    height: 24px;
    margin-right: 8px;
    font-size: 0.9rem;
  }
  
  .cat-name {
    font-size: 0.8rem;
  }
}