/* ============================================================
   SIDEBAR — disseny millorat
   Sobreescriu les regles de main.css per al sidebar
   ============================================================ */

/* Amplada nova: 260px (actualitza la variable global) */
:root {
  --sidebar-w: 260px;
}

/* ── Estructura base ── */
.sidebar {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ── Header ── */
.sidebar-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 18px 16px;
  border-bottom: 1px solid rgba(255,255,255,.07);
  flex-shrink: 0;
}

.sidebar-logo {
  width: 32px;
  height: 32px;
  object-fit: contain;
  flex-shrink: 0;
  border-radius: 6px;
}

.sidebar-brand {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
  min-width: 0;
}

.sidebar-title {
  font-size: 15px;
  font-weight: 700;
  color: #EFC03A;
  letter-spacing: .1px;
}

.sidebar-sub {
  font-size: 9.5px;
  color: rgba(255,255,255,.35);
  text-transform: uppercase;
  letter-spacing: .8px;
  margin-top: 2px;
}

/* ── Nav menu ── */
.nav-menu {
  list-style: none;
  padding: 10px 0;
  flex: 1;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,.15) transparent;
}

.nav-menu::-webkit-scrollbar       { width: 5px; }
.nav-menu::-webkit-scrollbar-track { background: transparent; }
.nav-menu::-webkit-scrollbar-thumb { background: rgba(255,255,255,.15); border-radius: 3px; }

.nav-menu > li { margin: 1px 10px; }

/* ── Nav links principals ── */
.nav-link {
  display: flex;
  align-items: center;
  gap: 0;
  padding: 10px 12px;
  border-radius: 7px;
  color: rgba(255,255,255,.52);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  transition: background .15s, color .15s, border-left-color .15s;
  border-left: 3px solid transparent;
  position: relative;
}

.nav-link:hover {
  background: rgba(255,255,255,.06);
  color: rgba(255,255,255,.9);
}

.nav-link.active {
  background: rgba(239,192,58,.12);
  color: #EFC03A;
  border-left-color: #EFC03A;
  font-weight: 600;
}

/* Icona i etiqueta */
.nav-icon {
  font-size: 15px;
  width: 22px;
  text-align: center;
  flex-shrink: 0;
  margin-right: 10px;
  opacity: .85;
}

.nav-label,
.nav-sub-text {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Badges ── */
.nav-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
  padding: 2px 6px;
  border-radius: 10px;
  min-width: 18px;
  background: rgba(255,255,255,.2);
  color: #fff;
  flex-shrink: 0;
  margin-left: 4px;
}

/* Respectar l'atribut hidden tot i tenir display inline-flex */
.nav-badge[hidden] { display: none !important; }

.nav-badge--success { background: #1D9E75; }
.nav-badge--warning { background: #FF8C42; }
.nav-badge--danger  { background: #E63946; }
.nav-badge--new {
  background: transparent;
  border: 1px solid #EFC03A;
  color: #EFC03A;
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: .5px;
  padding: 2px 5px;
}

/* ── Divider ── */
.nav-divider {
  height: 1px;
  background: rgba(255,255,255,.06);
  margin: 8px 10px;
}

/* ── Seccions col·lapsables ── */
.nav-section-header {
  display: flex;
  align-items: center;
  gap: 0;
  padding: 8px 12px;
  border-radius: 7px;
  color: rgba(255,255,255,.32);
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .9px;
  cursor: pointer;
  width: 100%;
  background: none;
  border: none;
  transition: color .15s, background .15s;
  margin: 2px 0;
}

.nav-section-header:hover {
  color: rgba(255,255,255,.62);
  background: rgba(255,255,255,.04);
}

.nav-section-header .nav-icon { opacity: .6; }

.nav-section-label { flex: 1; text-align: left; }

.nav-section-arrow {
  font-size: 9px;
  opacity: .4;
  transition: transform .2s ease;
  display: inline-block;
  margin-left: 4px;
}

.nav-section.open > .nav-section-header {
  color: rgba(255,255,255,.55);
}

.nav-section.open > .nav-section-header .nav-section-arrow {
  transform: rotate(90deg);
  opacity: .7;
}

/* ── Sub-menú ── */
.nav-sub-menu {
  list-style: none;
  overflow: hidden;
  max-height: 0;
  transition: max-height .25s ease;
}

.nav-sub-menu li { margin: 1px 0; }

.nav-section.open > .nav-sub-menu {
  max-height: 320px;
}

/* Sub-links */
.nav-sub-link {
  padding-left: 42px !important;
  font-size: 13px !important;
  color: rgba(255,255,255,.44) !important;
  display: flex !important;
  align-items: center !important;
}

.nav-sub-link:hover {
  color: rgba(255,255,255,.82) !important;
}

.nav-sub-link.active {
  color: #EFC03A !important;
  background: rgba(239,192,58,.10) !important;
  border-left-color: #EFC03A !important;
}

/* Punt decoratiu davant del sub-link */
.nav-sub-link::before {
  content: "·";
  position: absolute;
  left: 30px;
  color: rgba(255,255,255,.25);
  font-size: 18px;
  line-height: 0;
  top: 50%;
}

.nav-sub-link.active::before { color: #EFC03A; }

/* ── Footer ── */
.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid rgba(255,255,255,.1);
  flex-shrink: 0;
}

.user-info-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 10px;
  border-radius: 8px;
  transition: background .2s;
}

.user-info-row:hover {
  background: rgba(255,255,255,.05);
}

.user-info {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, #EFC03A 0%, #d4a82e 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  color: #1A1A1A;
  flex-shrink: 0;
  text-transform: uppercase;
}

.user-name {
  font-size: 13px;
  color: rgba(255,255,255,.78);
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.logout-btn-inline {
  display: flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  border: none;
  color: rgba(255,255,255,.4);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  padding: 6px 10px;
  border-radius: 6px;
  transition: background .2s, color .2s;
  flex-shrink: 0;
  white-space: nowrap;
}

.logout-btn-inline:hover {
  background: rgba(230,57,70,.15);
  color: #E63946;
}

.logout-btn-inline .logout-text { font-size: 12px; }
.logout-btn-inline .logout-icon  { font-size: 15px; }

/* ── Mobile ── */
@media (max-width: 768px) {
  :root { --sidebar-w: 260px; }
}
