/* ===========================================
   GESTIOLEX - Sidebar Layout
   =========================================== */

:root {
  --sidebar-min-width: 120px;
  --sidebar-padding: 20px;
  --sidebar-bg: #f8f9fa;
  --sidebar-border: #e9ecef;
  --sidebar-text: #495057;
  --sidebar-hover: #e9ecef;
  --sidebar-active: #0B5E70;
  --navbar-height: 56px;
}

/* Layout principale con sidebar */
.app-wrapper {
  display: flex;
  min-height: 100vh;
  padding-top: var(--navbar-height);
}

/* Sidebar */
.app-sidebar {
  width: max-content;
  min-width: var(--sidebar-min-width);
  max-width: 280px;
  background-color: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border);
  position: fixed;
  top: var(--navbar-height);
  left: 0;
  bottom: 0;
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 1000;
  transition: transform 0.3s ease;
  padding-right: var(--sidebar-padding);
  padding-bottom: 50px; /* Spazio per la versione */
}

/* Contenuto principale */
.app-content {
  flex: 1;
  padding: 1.5rem;
  min-width: 0;
  transition: margin-left 0.3s ease;
}

/* Header sidebar con logo/titolo */
.sidebar-header {
  padding: 1rem;
  border-bottom: 1px solid var(--sidebar-border);
  font-weight: 600;
  color: var(--sidebar-active);
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Navigazione sidebar */
.sidebar-nav {
  padding: 0.5rem 0;
}

.sidebar-nav .nav {
  padding: 0;
  margin: 0;
  list-style: none;
}

.sidebar-nav .nav-item {
  margin: 0;
}

.sidebar-nav .nav-link {
  display: flex;
  align-items: center;
  padding: 0.65rem 1rem;
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 0.9rem;
  border-left: 3px solid transparent;
  transition: all 0.2s ease;
}

.sidebar-nav .nav-link:hover {
  background-color: var(--sidebar-hover);
  color: var(--sidebar-active);
}

.sidebar-nav .nav-link.active {
  background-color: rgba(11, 94, 112, 0.1);
  color: var(--sidebar-active);
  border-left-color: var(--sidebar-active);
  font-weight: 500;
}

.sidebar-nav .nav-link i {
  width: 20px;
  margin-right: 0.75rem;
  text-align: center;
  font-size: 0.95rem;
}

/* Sottovoci sidebar */
.sidebar-nav .nav-link.sub-item {
  font-size: 0.75rem;
  padding-top: 0.15rem;
  padding-bottom: 0.15rem;
  margin-top: -0.3rem;
  color: #6c757d;
}

.sidebar-nav .nav-link.sub-item:hover {
  color: var(--sidebar-active);
}

.sidebar-nav .nav-link.sub-item.active {
  color: var(--sidebar-active);
  font-weight: 500;
}

.sidebar-nav .nav-link.sub-item i {
  font-size: 0.8rem;
  width: 16px;
}

/* Separatore sidebar */
.sidebar-divider {
  height: 0;
  margin: 0.4rem 1rem;
  border-top: 1px solid var(--sidebar-border);
}

.sidebar-nav li:has(.sidebar-divider) {
  list-style: none;
}

/* Titolo sezione sidebar */
.sidebar-section-title {
  padding: 1rem 1rem 0.5rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: #6c757d;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Placeholder quando sidebar è vuota */
.sidebar-empty {
  padding: 2rem 1rem;
  text-align: center;
  color: #adb5bd;
  font-size: 0.85rem;
}

.sidebar-empty i {
  font-size: 2rem;
  margin-bottom: 0.5rem;
  display: block;
}

/* ===========================================
   NAVBAR MODIFICHE
   =========================================== */

/* Brand Gestiolex nell'angolo */
.navbar-brand-corner {
  width: auto;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  padding-left: 0.5rem;
  padding-right: 1rem;
  margin-right: 0;
  flex-shrink: 0;
}

/* Hamburger per mobile */
.sidebar-toggle {
  display: none;
  background: none;
  border: none;
  color: white;
  font-size: 1.25rem;
  padding: 0.5rem;
  margin-right: 0.5rem;
  cursor: pointer;
}

.sidebar-toggle:hover {
  color: rgba(255,255,255,0.8);
}

/* ===========================================
   RESPONSIVE - MOBILE
   =========================================== */

@media (max-width: 991.98px) {
  /* Mostra hamburger */
  .sidebar-toggle {
    display: block;
  }
  
  /* Sidebar nascosta di default su mobile */
  .app-sidebar {
    transform: translateX(-100%);
    width: 200px;
  }
  
  .app-sidebar.show {
    transform: translateX(0);
    box-shadow: 4px 0 10px rgba(0,0,0,0.1);
  }
  
  /* Contenuto occupa tutta la larghezza */
  .app-content {
    margin-left: 0 !important;
  }
  
  /* Brand più stretto su mobile */
  .navbar-brand-corner {
    width: auto;
    border-right: none;
  }
  
  /* Overlay quando sidebar è aperta */
  .sidebar-overlay {
    display: none;
    position: fixed;
    top: var(--navbar-height);
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.3);
    z-index: 999;
  }
  
  .sidebar-overlay.show {
    display: block;
  }
}

/* ===========================================
   SCROLLBAR CUSTOM (sidebar)
   =========================================== */

.app-sidebar::-webkit-scrollbar {
  width: 6px;
}

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

.app-sidebar::-webkit-scrollbar-thumb {
  background-color: #ced4da;
  border-radius: 3px;
}

.app-sidebar::-webkit-scrollbar-thumb:hover {
  background-color: #adb5bd;
}

/* ===========================================
   ANIMAZIONE BADGE NUOVE EMAIL
   =========================================== */

@keyframes pulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.2); }
  100% { transform: scale(1); }
}

.pulse-animation {
  animation: pulse 0.5s ease-in-out 3;
}

/* ===========================================
   VERSIONE IN FONDO ALLA SIDEBAR
   =========================================== */

.sidebar-version {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 8px 0;
  text-align: center;
  font-size: 9px;
  color: #aaa;
  background: linear-gradient(to bottom, transparent, #f8f9fa);
}

/* ===========================================
   RICERCA RAPIDA SIDEBAR
   =========================================== */

.sidebar-search {
  border-bottom: 1px solid var(--sidebar-border);
  margin-bottom: 0.5rem;
  max-width: 160px;
}

.sidebar-search input {
  font-size: 0.8rem;
  border-radius: 6px;
  padding: 4px 8px;
}

.sidebar-search input:focus {
  border-color: var(--sidebar-active);
  box-shadow: 0 0 0 2px rgba(11, 94, 112, 0.15);
}

.sidebar-search-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: white;
  border: 1px solid #dee2e6;
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  max-height: 350px;
  overflow-y: auto;
  z-index: 1050;
  margin-top: 4px;
}

.sidebar-search-section {
  padding: 6px 10px;
  font-size: 0.7rem;
  font-weight: 600;
  color: #6c757d;
  background: #f8f9fa;
  border-bottom: 1px solid #eee;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.sidebar-search-item {
  display: block;
  padding: 6px 10px;
  font-size: 0.75rem;
  color: #212529;
  text-decoration: none;
  border-bottom: 1px solid #f0f0f0;
  transition: background 0.15s;
}

.sidebar-search-item:hover {
  background: #e9f5f7;
  color: var(--sidebar-active);
  text-decoration: none;
}

.sidebar-search-item:last-child {
  border-bottom: none;
}

.sidebar-search-item .item-type {
  font-size: 0.7rem;
  color: #999;
  margin-left: 6px;
}

.sidebar-search-empty {
  padding: 12px;
  text-align: center;
  color: #999;
  font-size: 0.85rem;
}

.sidebar-search-viewall {
  padding: 8px 12px;
  border-top: 1px solid #eee;
  text-align: center;
  background: #f8f9fa;
}

.sidebar-search-viewall a {
  color: var(--sidebar-active);
  font-size: 0.85rem;
  font-weight: 500;
  text-decoration: none;
}

.sidebar-search-viewall a:hover {
  text-decoration: underline;
}

/* Tooltip ricerca allineato a sinistra */
.tooltip-inner {
  text-align: left;
}

/* ===========================================
   RECENTI SIDEBAR
   =========================================== */

.sidebar-section-header {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Preferiti e Recenti nella sidebar */
#sidebar-favorites-list,
#sidebar-recents-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

#sidebar-favorites-list .nav-item,
#sidebar-recents-list .nav-item {
  position: relative;
}

.sidebar-recent-item,
.sidebar-favorite-item {
  display: block;
  font-size: 0.8rem !important;
  padding: 0.4rem 0.5rem !important;
  color: #666 !important;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer !important;
  text-decoration: none !important;
  border-radius: 4px;
  pointer-events: auto !important;
  position: relative;
  z-index: 1;
}

.sidebar-recent-item:hover,
.sidebar-favorite-item:hover {
  color: var(--sidebar-active) !important;
  background: var(--sidebar-hover);
  text-decoration: none !important;
}

.sidebar-favorite-remove,
.sidebar-recent-remove {
  opacity: 0;
  transition: opacity 0.2s;
  font-size: 0.85rem !important;
  line-height: 1;
  cursor: pointer !important;
  color: #dc3545 !important;
  background: transparent;
  border: none;
  padding: 4px 8px !important;
  margin-left: auto;
  flex-shrink: 0;
  pointer-events: auto !important;
  position: relative;
  z-index: 2;
}

.sidebar-fav-item:hover .sidebar-favorite-remove,
.sidebar-recent-row:hover .sidebar-recent-remove,
.nav-item:hover .sidebar-favorite-remove,
.nav-item:hover .sidebar-recent-remove {
  opacity: 1;
}

.sidebar-favorite-remove:hover,
.sidebar-recent-remove:hover {
  color: #a71d2a !important;
  background: rgba(220, 53, 69, 0.1);
  border-radius: 4px;
}

/* Pulsante stella preferito */
#btn-toggle-favorite {
  text-decoration: none;
  transition: transform 0.2s;
}

#btn-toggle-favorite:hover {
  transform: scale(1.2);
}

#btn-toggle-favorite.is-favorite {
  color: #ffc107 !important;
}
