/* ============================================================
   Drawer de navegació mòbil
   Extret de <style> a index.html
   ============================================================ */

.mobile-submenu ul {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
}
.mobile-nav {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  max-width: min(360px, 92vw);
  height: calc(var(--app-height, 100vh));
  background: var(--card);
  z-index: 300;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: rgba(var(--color-primary-rgb), var(--opacity-30))
    transparent;
  transform: translateX(-100%);
  transition: transform 0.3s ease;
}
.mobile-nav.open {
  transform: translateX(0);
}
.mobile-nav::-webkit-scrollbar {
  width: 10px;
}
.mobile-nav::-webkit-scrollbar-thumb {
  background: var(--actionable-border);
  border-radius: 10px;
  border: 2px solid transparent;
  background-clip: content-box;
}
.mobile-nav::-webkit-scrollbar-track {
  background: transparent;
}
.mobile-nav-header {
  padding: 16px 10px 16px 4px;
  border-bottom: 3px solid var(--border-subtle);
  position: sticky;
  top: 0;
  z-index: 3;
  background: var(--card);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.mobile-nav-content {
  padding: 0 0 12px;
  width: calc(100% + 10px);
  padding-right: 10px;
  box-sizing: border-box;
}
.mobile-nav-item {
  border-bottom: 1px solid var(--border-divider-soft);
}
.mobile-nav-table-link {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 16px 20px;
  font-family: var(--font-ui);
  font-size: var(--font-xl);
  font-weight: 700;
  color: var(--drawer-accent);
  text-decoration: none;
  transition: background 0.15s ease;
  background: var(--drawer-item-open-bg);
  box-sizing: border-box;
}
.mobile-nav-table-link:hover {
  background: var(--ui-overlay-hover);
  color: var(--text-max);
}
.table-count-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  padding: 1px 8px;
  font-family: var(--font-ui);
  font-size: var(--font-sm);
  font-weight: 800;
  line-height: 1.4;
  color: #fff;
  background: var(--color-primary);
  border-radius: var(--radius-full);
  white-space: nowrap;
  margin-left: auto;
}
.table-count-badge:empty {
  display: none;
}
.mobile-nav-item--search {
  padding: 0;
}
.mobile-nav-item--search .topbar-search-field--drawer {
  width: 100%;
  max-width: none;
  min-width: 0;
  flex: 1 1 auto;
  margin: 0;
  padding: 14px 16px;
  box-sizing: border-box;
}
.mobile-nav-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  font-family: var(--font-ui);
  font-size: var(--font-xl);
  font-weight: 700;
  color: var(--drawer-accent);
  cursor: pointer;
  transition: background 0.15s ease;
  background: var(--drawer-item-open-bg);
}
.mobile-nav-link:hover {
  background: var(--ui-overlay-hover);
  color: var(--text-max);
}
.mobile-nav-link.active {
  background: var(--drawer-item-open-bg);
  color: var(--drawer-accent);
  font-weight: 700;
}
.mobile-nav-link.active svg {
  stroke: var(--drawer-accent);
}
.mobile-nav-link svg {
  width: 20px;
  height: 20px;
  stroke: var(--drawer-accent);
  stroke-width: 2;
  transition: transform 0.3s ease;
}
.mobile-nav-item details > summary {
  list-style: none;
  cursor: pointer;
}
.mobile-nav-item details > summary::-webkit-details-marker {
  display: none;
}
.mobile-nav-item details[open] .mobile-nav-link svg {
  transform: rotate(180deg);
}
.mobile-nav-item details .mobile-submenu {
  display: block;
  overflow: hidden;
  max-height: 0;
  opacity: 0;
  transition:
    max-height 0.3s ease,
    opacity 0.3s ease;
}
.mobile-nav-item details:not([open]) > :not(summary) {
  display: block;
}
.mobile-nav-item details[open] .mobile-submenu {
  max-height: 2000px;
  opacity: 1;
}
.mobile-nav-item.expanded > .mobile-nav-link svg {
  transform: rotate(180deg);
}
.mobile-submenu {
  background: var(--surface-submenu);
}
.mobile-agenda-wrap {
  padding: 10px;
  background: var(--card);
}
.mobile-agenda-wrap .month {
  border: none;
  padding: 0;
  width: 100%;
  margin-bottom: 15px;
}
.mobile-filters-dates {
  padding-bottom: var(--space-3);
  margin-bottom: var(--space-3);
  border-bottom: 1px solid var(--border-subtle);
}
.mobile-agenda-wrap .field {
  margin-bottom: 10px;
}
.mobile-agenda-wrap .chips {
  margin-bottom: 10px;
}
.mobile-submenu-section {
  padding: 16px 20px;
  border-top: 1px solid var(--border-subtle);
  box-shadow: 0 -16px 36px rgba(var(--shadow-rgb), var(--opacity-15));
}
.mobile-submenu-section:first-child {
  border-top: none;
}
.mobile-submenu-title {
  font-family: var(--font-ui);
  font-size: var(--font-sm);
  font-weight: 800;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin: 0 0 12px 0;
}
.mobile-submenu ul {
  gap: var(--space-1);
}
.mobile-submenu a {
  display: block;
  padding: 10px 12px;
  font-size: var(--font-lg);
  font-weight: 600;
  color: var(--ink);
  border-radius: var(--radius-md);
  transition:
    background 0.15s ease,
    color 0.15s ease;
}
.mobile-submenu a:hover {
  background: var(--actionable-hover);
  color: var(--color-primary-strong);
}
.mobile-backdrop {
  position: fixed;
  inset: 0;
  background: var(--ui-scrim);
  z-index: 299;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.3s ease;
}
.mobile-backdrop.visible {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

/* Cal-popover dins la navegació mòbil */
.mobile-nav .cal-popover .day.cal-opt {
  width: 100%;
}

/* --- Responsive overrides --- */

@media (max-width: 1400px) {
  .mobile-nav .month {
    padding: 6px;
  }
  .mobile-nav .month .grid {
    grid-template-columns: repeat(7, 1fr);
    justify-content: stretch;
    gap: var(--space-1);
    padding: 0;
  }
  .mobile-nav .month .dow {
    grid-template-columns: repeat(7, 1fr);
    justify-content: stretch;
    gap: var(--space-1);
    padding: 0;
  }
  .mobile-nav .day {
    height: 36px;
    width: 36px;
  }
}

@media (max-width: 520px) {
  .mobile-backdrop {
    bottom: 0;
  }
  .mobile-nav {
    height: calc(var(--app-height, 100vh));
  }
}

/* --- Sobreescriptures de tema / tokens (després de carregar tokens base) --- */

.mobile-nav {
  background: var(--drawer-bg);
}
.mobile-nav-header {
  background: var(--drawer-header-bg);
  border-bottom: 3px solid var(--drawer-divider-strong);
}
.mobile-nav-item {
  border-bottom: 1px solid var(--drawer-divider);
}
.mobile-nav-link:hover {
  background: var(--drawer-item-hover);
  color: var(--card);
}
.mobile-nav-link:hover svg {
  stroke: var(--card);
}
.mobile-nav-item details[open] > summary.mobile-nav-link {
  background: var(--drawer-item-hover);
  color: var(--card);
}
.mobile-nav-item details[open] > summary.mobile-nav-link svg {
  stroke: var(--card);
}
.mobile-submenu {
  background: var(--drawer-submenu-bg);
}
.mobile-agenda-wrap {
  background: var(--drawer-submenu-bg);
}
.mobile-submenu-section {
  border-top: 1px solid var(--drawer-divider);
  box-shadow: none;
  background: transparent;
}
.mobile-nav-item details > summary::marker {
  content: "";
}
