:root {
  --cogestione-grid-gap: 12px;
}

.page-actions a[href="cogestione-qr.html"] {
  display: none;
}

.cogestione-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-lg);
  align-items: start;
}

.cogestione-summary,
.cogestione-activities {
  border-radius: 0;
}

.card-header-content {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.calendar-legend {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
  margin-bottom: var(--space-md);
  font-size: 0.85rem;
  color: var(--color-text-muted);
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 0.7rem;
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 1px solid var(--color-border);
  display: inline-block;
}

.legend-dot-activity {
  background: var(--color-accent);
  border-color: var(--color-accent);
}

.legend-dot-call {
  background: rgba(56, 189, 248, 0.28);
  border-color: #38bdf8;
}

.legend-dot-break {
  background: rgba(253, 224, 71, 0.28);
  border-color: #fde047;
}

.legend-dot-enrolled {
  background: #22c55e;
  border-color: #22c55e;
}

.calendar-full-wrapper {
  border: 1px solid var(--color-border);
  background: var(--color-bg);
  padding: var(--space-sm);
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.cogestione-calendar {
  min-height: calc(100dvh - 260px);
}

.calendar-full-wrapper--mobile {
  overflow-x: hidden;
}

.cogestione-calendar--mobile {
  min-height: calc(100dvh - 340px);
}

.cogestione-summary .card-header,
.cogestione-activities .card-header {
  align-items: flex-end;
  gap: var(--space-md);
}

.calendar-skeleton {
  display: grid;
  gap: var(--space-sm);
}

.calendar-skeleton-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-sm);
}

.calendar-skeleton-grid .skeleton-card {
  min-height: 90px;
}

.cogestione-summary .fc {
  --fc-border-color: var(--color-border);
  --fc-page-bg-color: var(--color-bg);
  --fc-neutral-bg-color: var(--color-bg-elevated);
  --fc-list-event-hover-bg-color: rgba(255, 255, 255, 0.04);
  --fc-today-bg-color: rgba(255, 92, 0, 0.12);
  --fc-event-border-color: transparent;
  --fc-button-bg-color: transparent;
  --fc-button-border-color: var(--color-border);
  --fc-button-hover-bg-color: rgba(255, 255, 255, 0.06);
  --fc-button-hover-border-color: var(--color-accent);
  --fc-button-active-bg-color: var(--color-accent);
  --fc-button-active-border-color: var(--color-accent);
  --fc-button-text-color: var(--color-text);
  color: var(--color-text);
}

.cogestione-summary .fc .fc-toolbar {
  padding: var(--space-sm);
  margin-bottom: var(--space-sm);
}

.cogestione-summary .fc .fc-toolbar-title {
  font-family: var(--font-display);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 1rem;
}

.cogestione-summary .fc .fc-button {
  border-radius: 0;
  box-shadow: none;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.68rem;
  padding: 0.45rem 0.65rem;
}

.cogestione-summary .fc .fc-col-header-cell-cushion,
.cogestione-summary .fc .fc-timegrid-axis-cushion {
  text-transform: uppercase;
  letter-spacing: 0.07em;
  font-size: 0.7rem;
  color: var(--color-text-muted);
  padding: 0.35rem;
}

.cogestione-summary .fc .fc-timegrid-slot-label-cushion {
  color: var(--color-text-muted);
  font-size: 0.76rem;
}

.cogestione-summary .fc .fc-event {
  border-radius: 0;
  border-left: 3px solid transparent;
  background: rgba(255, 92, 0, 0.16);
  color: #fff;
  transition: transform var(--duration-fast) var(--ease-out), box-shadow var(--duration-fast) var(--ease-out);
}

.cogestione-summary .fc .fc-event.fc-phase-activity {
  border-left-color: var(--color-accent);
}

.cogestione-summary .fc .fc-event.fc-phase-activity.fc-phase-empty {
  border-left-color: #94a3b8;
  background: rgba(148, 163, 184, 0.2);
}

.cogestione-summary .fc .fc-event.fc-phase-activity.fc-phase-enrolled {
  border-left-color: #22c55e;
  background: rgba(34, 197, 94, 0.25);
}

.cogestione-summary .fc .fc-event.fc-phase-security {
  border-left-color: #f59e0b;
  background: rgba(245, 158, 11, 0.22);
  color: #fef3c7;
  cursor: default;
}

.cogestione-summary .fc .fc-event.fc-phase-disabled {
  border-left-color: #6b7280;
  background: rgba(107, 114, 128, 0.22);
  color: rgba(245, 245, 245, 0.9);
  cursor: not-allowed;
  opacity: 0.88;
}

.cogestione-summary .fc .fc-event.fc-phase-call {
  border-left-color: #38bdf8;
  background: rgba(56, 189, 248, 0.2);
  color: #dff5ff;
}

.cogestione-summary .fc .fc-event.fc-phase-break {
  border-left-color: #fde047;
  background: rgba(253, 224, 71, 0.16);
  color: #fff8cc;
}

.cogestione-summary .fc .fc-event.fc-phase-clickable {
  cursor: pointer;
}

.cogestione-summary .fc .fc-event.fc-phase-static {
  cursor: default;
}

.cogestione-summary .fc .fc-event-location {
  font-size: 0.93rem;
  font-weight: 500;
  opacity: 0.85;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
  letter-spacing: 0.01em;
}

.cogestione-summary .fc .fc-event:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.22);
}

.cogestione-summary .fc .fc-event.fc-phase-disabled:hover {
  transform: none;
  box-shadow: none;
}

.cogestione-summary .fc .fc-timegrid-event-harness {
  margin-right: 2px;
}

.cogestione-summary .fc .fc-timegrid-event {
  min-height: 0;
}

.cogestione-summary .fc .fc-timegrid-event.fc-phase-activity {
  min-height: 42px;
}

.cogestione-summary .fc .fc-timegrid-event .fc-event-main {
  padding: 0.3rem 0.35rem;
}

.cogestione-summary .fc .fc-timegrid-event .fc-event-time,
.cogestione-summary .fc .fc-timegrid-event .fc-event-title {
  white-space: normal;
  overflow: hidden;
  text-overflow: clip;
  line-height: 1.2;
}

.cogestione-summary .fc .fc-timegrid-event .fc-event-time {
  font-size: 0.74rem;
}

.cogestione-summary .fc .fc-timegrid-event .fc-event-title {
  font-weight: 500;
  font-size: 0.93rem;
}

.cogestione-summary .fc .fc-timegrid-more-link {
  color: var(--color-accent);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.activity-list {
  display: grid;
  gap: var(--space-md);
}

.activity-card {
  position: relative;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg, 14px);
  padding: var(--space-lg) var(--space-lg) var(--space-md);
  background: var(--color-bg-elevated);
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  color: var(--color-text);
  overflow: visible;
  transition: border-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
}

.activity-card::before {
  content: '';
  position: absolute;
  left: 0;
  top: 12px;
  bottom: 12px;
  width: 3px;
  border-radius: 0 2px 2px 0;
  background: var(--color-accent);
  opacity: 0;
  transition: opacity 0.18s ease;
}

.activity-card:hover {
  border-color: var(--color-accent);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.2);
  transform: translateY(-2px);
}

.activity-card:hover::before {
  opacity: 1;
}

.activity-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--space-md);
  flex-shrink: 0;
}

.activity-card-header-text {
  min-width: 0;
  flex: 1;
  overflow: hidden;
}

.activity-card-badges {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  align-items: flex-end;
  flex-shrink: 0;
}

.activity-card-title {
  font-family: var(--font-display, inherit);
  font-size: 1.08rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  line-height: 1.25;
  overflow-wrap: anywhere;
  margin-bottom: 4px;
}

.activity-card-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--color-text-muted);
  font-size: 0.84rem;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.activity-card-meta + .activity-card-meta {
  margin-top: 2px;
}

.activity-card-enrolled {
  color: #22c55e;
  font-weight: 600;
}

.activity-card-enrolled::before {
  content: '';
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #22c55e;
  flex-shrink: 0;
}

.activity-card-times {
  list-style: none;
  display: grid;
  gap: 0.35rem;
  padding: 0;
  margin: 0;
  color: var(--color-text-muted);
  font-size: 0.85rem;
}

.activity-slot-list {
  display: grid;
  gap: var(--space-sm);
  flex: 1;
  min-height: 0;
  overflow: hidden;
  align-content: start;
}

.activity-slot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-sm);
  padding: 0.7rem 0.9rem;
  border-radius: var(--radius-md, 10px);
  border: 1px solid var(--color-border);
  background: rgba(255, 255, 255, 0.02);
}

.activity-slot.is-enrolled {
  border-color: rgba(34, 197, 94, 0.45);
  background: rgba(34, 197, 94, 0.07);
}

.activity-slot-info {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  min-width: 0;
  flex: 1;
}

.activity-slot-title {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--color-text);
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.activity-slot-meta {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.activity-slot-actions .btn {
  min-width: 110px;
  justify-content: center;
}

.activity-card-times li {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.activity-card-times li::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--color-accent);
  display: inline-block;
}

.activity-actions {
  display: flex;
  gap: var(--space-sm);
  flex-wrap: wrap;
  flex-shrink: 0;
  padding-top: var(--space-xs);
  border-top: 1px solid var(--color-border);
  margin-top: var(--space-xs);
}

.activity-detail-header {
  align-items: flex-start;
}

.activity-detail-main {
  flex: 1;
  min-width: 0;
}

.activity-detail-image {
  width: 72px;
  height: 72px;
  object-fit: cover;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md, 10px);
  flex-shrink: 0;
}

.activity-detail-image--placeholder {
  display: grid;
  place-items: center;
  background: var(--color-bg-elevated);
  color: var(--color-text-muted);
  border-radius: var(--radius-md, 10px);
}

.activity-detail-grid {
  display: grid;
  grid-template-columns: repeat(1, minmax(0, 1fr));
  gap: var(--space-sm);
  color: var(--color-text-muted);
  font-size: 0.86rem;
  background: rgba(255,255,255,0.025);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md, 10px);
  padding: var(--space-sm) var(--space-md);
}

.filters {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--space-sm);
  align-items: end;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.filter-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-text-muted);
}

.empty-state {
  padding: var(--space-xl);
  text-align: center;
  border: 1px dashed var(--color-border);
}

.empty-state-icon {
  width: 48px;
  height: 48px;
  margin: 0 auto var(--space-sm);
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 1px solid var(--color-border);
}

/* Skeleton loaders */
@keyframes skeleton-shimmer {
  0% {
    background-position: -200% 0;
  }
  100% {
    background-position: 200% 0;
  }
}

.skeleton-line,
.skeleton-card,
.skeleton-pill {
  background: linear-gradient(
    90deg,
    var(--color-bg-elevated) 25%,
    rgba(255, 255, 255, 0.06) 50%,
    var(--color-bg-elevated) 75%
  );
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.5s infinite ease-in-out;
}

.skeleton-card {
  border: 1px solid var(--color-border);
}

.skeleton-line {
  height: 12px;
  border-radius: 4px;
}

.skeleton-line-lg {
  height: 16px;
  width: 70%;
}

.skeleton-line-sm {
  height: 10px;
  width: 55%;
}

.skeleton-line-xs {
  height: 8px;
  width: 40%;
}

.skeleton-pill {
  width: 64px;
  height: 20px;
  border-radius: 999px;
}

@media (max-width: 900px) {
  .cogestione-summary .card-header,
  .cogestione-activities .card-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .cogestione-summary .fc .fc-toolbar {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.6rem;
  }

  .cogestione-summary .fc .fc-toolbar-chunk {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
  }
}

@media (max-width: 720px) {
  .page-actions,
  .summary-actions {
    width: 100%;
  }

  .summary-actions .btn {
    justify-content: center;
    width: 100%;
  }

  .filters {
    grid-template-columns: 1fr;
  }

  .activity-card-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .activity-card {
    min-height: 0;
    padding: var(--space-md);
  }

  .activity-detail-grid {
    grid-template-columns: 1fr;
  }

  .activity-card-badges {
    align-items: flex-start;
  }

  .activity-slot {
    flex-direction: column;
    align-items: flex-start;
    width: 100%;
    padding: var(--space-sm);
  }

  .activity-slot.is-enrolled {
    width: 100%;
  }

  .activity-slot-info,
  .activity-slot-title,
  .activity-slot-meta {
    width: 100%;
  }

  .activity-slot-actions {
    width: 100%;
  }

  .activity-slot-actions .btn {
    width: 100%;
    min-width: 0;
  }

  .cogestione-summary .fc .fc-toolbar-title {
    font-size: 1.45rem;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .cogestione-summary .fc .fc-toolbar {
    width: 100%;
    display: flex;
    flex-direction: row !important;
    align-items: center;
    justify-content: space-between;
    gap: 0;
    padding: var(--space-xs) var(--space-sm);
    margin-bottom: 0;
  }

  .cogestione-summary .fc .fc-toolbar-chunk {
    flex: 0 0 auto;
    align-items: center;
  }

  /* Center chunk (title) takes remaining space */
  .cogestione-summary .fc .fc-toolbar-chunk:nth-child(2) {
    flex: 1 1 0;
    display: flex;
    justify-content: center;
    min-width: 0;
    padding: 0 var(--space-xs);
  }

  /* Prev / Next buttons — large tap targets */
  .cogestione-summary .fc .fc-prev-button,
  .cogestione-summary .fc .fc-next-button {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50% !important;
    border: 2px solid var(--color-accent) !important;
    background: rgba(255, 92, 0, 0.10) !important;
    color: var(--color-accent) !important;
    padding: 0 !important;
    font-size: 1.1rem;
    transition: background var(--duration-fast), transform var(--duration-fast);
  }

  .cogestione-summary .fc .fc-prev-button:hover,
  .cogestione-summary .fc .fc-next-button:hover {
    background: rgba(255, 92, 0, 0.22) !important;
    transform: scale(1.08);
  }

  .cogestione-summary .fc .fc-prev-button:active,
  .cogestione-summary .fc .fc-next-button:active {
    background: var(--color-accent) !important;
    color: #fff !important;
    transform: scale(0.95);
  }

  .cogestione-summary .fc .fc-prev-button:disabled,
  .cogestione-summary .fc .fc-next-button:disabled {
    opacity: 0.3;
    border-color: var(--color-border) !important;
    background: transparent !important;
    cursor: not-allowed;
    transform: none;
  }

  .cogestione-summary .fc .fc-icon {
    font-size: 1.2rem;
  }

  .cogestione-summary .fc .fc-timegrid-axis {
    width: 52px;
  }

  .cogestione-summary .fc .fc-timegrid-slot {
    min-height: 2.9rem;
  }

  .cogestione-summary .fc .fc-timegrid-event .fc-event-time {
    font-size: 0.82rem;
  }

  .cogestione-summary .fc .fc-timegrid-event .fc-event-title {
    font-size: 0.92rem;
  }

  .cogestione-summary .fc .fc-event-location {
    font-size: 0.92rem;
  }

  .cogestione-calendar {
    min-height: calc(100dvh - 220px);
  }
}

/* ============================================
   480px — Small mobile
   ============================================ */
@media (max-width: 480px) {
  .page-actions .btn {
    width: 100%;
    justify-content: center;
  }

  .cogestione-summary .fc .fc-toolbar-title {
    font-size: 1.3rem;
  }

  .cogestione-summary .fc .fc-button {
    padding: 0.35rem 0.5rem;
    font-size: 0.62rem;
  }

  .calendar-legend {
    gap: 0.3rem 0.5rem;
  }

  .legend-item {
    font-size: 0.62rem;
  }

  .calendar-full-wrapper {
    padding: 2px;
  }

  .cogestione-summary .fc .fc-toolbar {
    gap: 0.45rem;
    padding: 0.4rem;
  }

  .cogestione-summary .fc .fc-timegrid-axis {
    width: 46px;
  }

  .cogestione-calendar {
    min-height: calc(100dvh - 300px);
  }

  .cogestione-summary .fc .fc-col-header-cell-cushion,
  .cogestione-summary .fc .fc-timegrid-axis-cushion {
    font-size: 0.62rem;
    padding: 0.2rem;
  }

  .cogestione-summary .fc .fc-timegrid-slot-label-cushion {
    font-size: 0.65rem;
  }

  .activity-card {
    gap: var(--space-xs);
  }

  .activity-card-title {
    font-size: 0.98rem;
  }

  .activity-card-meta {
    font-size: 0.8rem;
  }

  .cogestione-summary .fc .fc-timegrid-event .fc-event-title,
  .cogestione-summary .fc .fc-timegrid-event .fc-event-title .fc-sticky {
    font-size: 0.84rem;
  }

  .cogestione-summary .fc .fc-event-location {
    font-size: 0.84rem;
  }

  .activity-slot-title {
    font-size: 0.84rem;
  }

  .activity-slot-meta {
    font-size: 0.68rem;
    letter-spacing: 0.05em;
  }
}

/* ============================================
   360px — Very small mobile (320–360px targets)
   ============================================ */
@media (max-width: 360px) {
  .cogestione-summary .fc .fc-toolbar {
    padding: 0.3rem;
  }

  .cogestione-summary .fc .fc-toolbar-title {
    font-size: 0.72rem;
  }

  .cogestione-summary .fc .fc-button {
    padding: 0.22rem 0.38rem;
    font-size: 0.56rem;
    letter-spacing: 0.04em;
  }

  .legend-item {
    font-size: 0.56rem;
    gap: 0.28rem;
  }

  .legend-dot {
    width: 8px;
    height: 8px;
  }

  .cogestione-summary .fc .fc-timegrid-event .fc-event-title,
  .cogestione-summary .fc .fc-timegrid-event .fc-event-title .fc-sticky {
    font-size: 0.78rem;
  }

  .cogestione-summary .fc .fc-event-location {
    font-size: 0.78rem;
  }

  .cogestione-summary .fc .fc-timegrid-event .fc-event-time {
    font-size: 0.6rem;
  }

  .cogestione-calendar {
    min-height: calc(100dvh - 320px);
  }
}

