/**
 * Piazza Tresca — Components (Mobile-first)
 * Bottom nav, card, button, form, alert, calendar
 */

/* ── Status Bar ──────────────────────────────────── */
.piazza-status {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 700;
  color: var(--primary);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.piazza-status .version {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  margin-left: 6px;
}

/* ── Page Wrapper ──────────────────────────────── */
.piazza-page {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: var(--space-md);
  padding-bottom: calc(var(--nav-height) + var(--space-md));
  min-height: calc(100vh - var(--switcher-height));
}

/* ── Bottom Navigation ─────────────────────────── */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--nav-height);
  background: var(--white);
  border-top: 1px solid var(--border-light);
  display: flex;
  align-items: stretch;
  z-index: 1000;
  padding-bottom: env(safe-area-inset-bottom, 0);
}

.nav-tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  background: transparent;
  border: none;
  padding: var(--space-xs) var(--space-sm);
  cursor: pointer;
  color: var(--text-muted);
  font-size: 0.7rem;
  font-family: inherit;
  transition: color 0.15s;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  min-height: var(--touch-min);
}

.nav-tab:hover { color: var(--text-light); }

.nav-tab.is-active {
  color: var(--primary);
  font-weight: 600;
}

.nav-icon {
  position: relative;
  font-size: 1.3rem;
  line-height: 1;
}

.nav-label {
  font-size: 0.65rem;
  line-height: 1;
}

/* ── Page Header ───────────────────────────────── */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-md);
}

.page-header h1 {
  font-size: 1.3rem;
  color: var(--primary);
}

.page-header-actions {
  display: flex;
  gap: var(--space-sm);
}

/* ── Buttons ───────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-xs);
  padding: 0.6rem 1.2rem;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 0.9rem;
  font-family: inherit;
  font-weight: 500;
  transition: background 0.15s, border-color 0.15s;
  touch-action: manipulation;
  min-height: var(--touch-min);
  white-space: nowrap;
}

.btn-primary {
  background: var(--primary);
  color: var(--white);
  border-color: var(--primary);
}

.btn-primary:hover { background: var(--primary-dark); }

.btn-secondary {
  background: var(--white);
  color: var(--text);
}

.btn-secondary:hover { background: var(--surface); }

.btn-danger {
  background: var(--danger);
  color: var(--white);
  border-color: var(--danger);
}

.btn-danger:hover { background: #b03030; }

.btn-sm {
  padding: 0.4rem 0.8rem;
  font-size: 0.8rem;
  min-height: var(--touch-min);
}

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

.btn-icon {
  width: var(--touch-min);
  height: var(--touch-min);
  padding: 0;
  border-radius: 50%;
}

.btn-group {
  display: flex;
  gap: var(--space-sm);
  margin-top: var(--space-md);
  flex-wrap: wrap;
}

/* ── Forms ─────────────────────────────────────── */
.form-group {
  margin-bottom: var(--space-md);
}

.form-group label {
  display: block;
  font-weight: 600;
  margin-bottom: var(--space-xs);
  font-size: 0.85rem;
  color: var(--text-light);
}

.form-group input,
.form-group textarea,
.form-group select {
  width: 100%;
  padding: 0.7rem 0.8rem;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--white);
  font-size: 1rem;
  font-family: inherit;
  color: var(--text);
  transition: border-color 0.15s;
  -webkit-appearance: none;
  appearance: none;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--primary);
}

.form-group textarea {
  min-height: 120px;
  resize: vertical;
}

.form-group select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%237a6a5a' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.8rem center;
  padding-right: 2rem;
}

.form-group .checkbox-label {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  cursor: pointer;
  font-weight: normal;
  min-height: var(--touch-min);
}

.form-group .checkbox-label input[type="checkbox"] {
  width: auto;
  width: 1.2rem;
  height: 1.2rem;
  -webkit-appearance: checkbox;
  appearance: auto;
}

/* ── Alerts ────────────────────────────────────── */
.alert {
  padding: 0.7rem 1rem;
  border-radius: var(--radius-sm);
  margin-bottom: var(--space-md);
  font-size: 0.85rem;
}

.alert-error {
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid #f5c0c0;
}

.alert-success {
  background: #e8f5e8;
  color: var(--green);
  border: 1px solid #c0e0c0;
}

/* ── Post Cards (Bacheca) ──────────────────────── */
.post-card {
  background: var(--white);
  border: 2px solid var(--border-light);
  border-radius: var(--radius);
  padding: var(--space-md);
  margin-bottom: var(--space-sm);
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.post-card:active {
  border-color: var(--primary);
  box-shadow: 0 1px 4px rgba(0,0,0,0.1);
}

.post-card.pinned {
  border-color: var(--yellow);
  background: #fff8e0;
}

.post-card h3 {
  font-size: 1rem;
  margin-bottom: var(--space-xs);
  color: var(--text);
  line-height: 1.3;
}

.post-card .post-preview {
  font-size: 0.85rem;
  color: var(--text-light);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.post-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: var(--space-sm);
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  flex-wrap: wrap;
}

.post-meta .badge {
  display: inline-block;
  background: var(--surface);
  padding: 0.15rem 0.5rem;
  border-radius: 3px;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-light);
}

/* ── Type Filter Tabs ──────────────────────────── */
.type-filter {
  display: flex;
  gap: var(--space-xs);
  margin-bottom: var(--space-md);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.type-filter::-webkit-scrollbar { display: none; }

.type-tab {
  flex-shrink: 0;
  padding: 0.4rem 0.8rem;
  border: 2px solid var(--border);
  border-radius: 20px;
  background: var(--white);
  font-size: 0.8rem;
  font-family: inherit;
  font-weight: 500;
  color: var(--text-light);
  cursor: pointer;
  transition: all 0.15s;
  min-height: var(--touch-min);
  touch-action: manipulation;
}

.type-tab.is-active {
  background: var(--primary);
  color: var(--white);
  border-color: var(--primary);
}

.type-tab:hover {
  border-color: var(--primary);
  color: var(--primary);
}

/* ── Badge per tipo post ──────────────────────── */
.badge-sondaggio {
  background: #e8f4fd !important;
  color: #1a73e8 !important;
}

.badge-evento {
  background: #fef3e2 !important;
  color: #e67e00 !important;
}

.post-type-badge {
  margin-bottom: var(--space-sm);
}

/* ── Event Info (in post detail) ──────────────── */
.post-event-info {
  display: flex;
  gap: var(--space-md);
  padding: var(--space-sm) var(--space-md);
  background: var(--surface);
  border-radius: var(--radius-sm);
  margin: var(--space-sm) 0;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text);
  align-items: center;
}

/* ── Poll Section (in post detail) ────────────── */
.poll-section {
  margin: var(--space-md) 0;
  padding: var(--space-md);
  background: var(--surface);
  border-radius: var(--radius);
  border: 2px solid var(--border-light);
}

.poll-section h3 {
  font-size: 1rem;
  margin-bottom: var(--space-sm);
  color: var(--text);
}

.poll-options {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.poll-option-row {
  display: flex;
}

.poll-vote-btn {
  width: 100%;
  padding: 0.7rem 1rem;
  border: 2px solid var(--primary);
  border-radius: var(--radius);
  background: var(--white);
  color: var(--primary);
  font-size: 0.9rem;
  font-family: inherit;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s, color 0.15s;
  min-height: var(--touch-min);
}

.poll-vote-btn:hover,
.poll-vote-btn:active {
  background: var(--primary);
  color: var(--white);
}

/* Poll option button (selectable, not direct vote) */
.poll-opt-btn {
  width: 100%;
  padding: 0.7rem 1rem;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--white);
  color: var(--text);
  font-size: 0.9rem;
  font-family: inherit;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  transition: all 0.15s;
  min-height: var(--touch-min);
  touch-action: manipulation;
}

.poll-opt-btn:hover,
.poll-opt-btn:active {
  border-color: var(--primary);
  background: #f0f7ff;
}

.poll-opt-btn.is-selected {
  border-color: var(--primary);
  background: var(--primary);
  color: var(--white);
  font-weight: 600;
}

/* Confirm vote area */
.poll-confirm-area {
  margin-top: var(--space-md);
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.poll-results {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.poll-result-row {
  padding: var(--space-xs) 0;
}

.poll-result-text {
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 2px;
  color: var(--text);
}

.poll-result-bar {
  height: 8px;
  background: var(--border-light);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 2px;
}

.poll-bar-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 4px;
  transition: width 0.3s ease;
}

.poll-result-count {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.poll-total {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: var(--space-sm);
  text-align: center;
}

.poll-note {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-style: italic;
  margin-top: var(--space-sm);
  text-align: center;
}

/* ── Poll Option Inputs (form) ────────────────── */
.poll-option-input-row {
  display: flex;
  gap: var(--space-xs);
  margin-bottom: var(--space-xs);
  align-items: center;
}

.poll-option-input {
  flex: 1;
  padding: 0.6rem 0.7rem;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-family: inherit;
}

.poll-option-input:focus {
  outline: none;
  border-color: var(--primary);
}

.poll-remove-btn {
  flex-shrink: 0;
}

/* ── Form Group Row (event date/time side-by-side) */
.form-group-row {
  display: flex;
  gap: var(--space-sm);
}

.form-group-half {
  flex: 1;
}

/* ── Category Filter Dropdown ──────────────────── */
.category-filter {
  margin-bottom: var(--space-md);
}

.category-select {
  width: 100%;
  padding: 0.7rem 0.8rem;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--white);
  font-size: 0.95rem;
  font-family: inherit;
  color: var(--text);
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%237a6a5a' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.8rem center;
  padding-right: 2.5rem;
  min-height: var(--touch-min);
  transition: border-color 0.15s;
}

.category-select:focus {
  outline: none;
  border-color: var(--primary);
}

.category-select option {
  padding: 0.5rem;
}

/* ── Post Detail ───────────────────────────────── */
.post-detail {
  background: var(--white);
  border: 2px solid var(--border-light);
  border-radius: var(--radius);
  padding: var(--space-md);
}

.post-detail h2 {
  font-size: 1.2rem;
  margin-bottom: var(--space-sm);
}

.post-detail .post-content {
  white-space: pre-wrap;
  font-size: 0.95rem;
  line-height: 1.6;
  margin: var(--space-md) 0;
  color: var(--text);
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--primary);
  font-size: 0.9rem;
  cursor: pointer;
  min-height: var(--touch-min);
  margin-top: var(--space-md);
}

/* ── Login ─────────────────────────────────────── */
.login-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - var(--switcher-height) - var(--nav-height) - var(--space-lg));
  padding: var(--space-lg) var(--space-md);
}

.login-box {
  width: 100%;
  max-width: 360px;
  background: var(--white);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-lg);
}

.login-box h2 {
  text-align: center;
  margin-bottom: var(--space-lg);
  color: var(--primary);
  font-size: 1.4rem;
}

/* ── Empty State ───────────────────────────────── */
.empty-state {
  text-align: center;
  padding: var(--space-xl) var(--space-md);
  color: var(--text-muted);
}

.empty-state p { font-size: 0.95rem; }

/* ════════════════════════════════════════════════
 * Calendar Grid + Bottom Sheet (M2)
 * ════════════════════════════════════════════════ */

/* ── Calendar Header ─────────────────────────── */
.calendar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-md);
  gap: var(--space-sm);
}

.calendar-header h3 {
  font-size: 1.15rem;
  font-weight: 700;
  flex-shrink: 0;
}

.calendar-nav-group {
  display: flex;
  gap: var(--space-xs);
}

.calendar-today-btn {
  font-size: 0.75rem;
  padding: 0.3rem 0.7rem;
  min-height: 36px;
}

/* ── Calendar Tip ────────────────────────────── */
.calendar-tip {
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: var(--space-sm);
}

/* ── Calendar Grid ───────────────────────────── */
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
  background: var(--white);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: var(--space-md);
}

.calendar-weekday {
  text-align: center;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-muted);
  padding: var(--space-sm) 0;
  background: var(--surface);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.calendar-weekday:first-child,
.calendar-weekday:last-child {
  color: var(--primary);
}

.calendar-cell {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 4px 2px;
  min-height: 52px;
  cursor: pointer;
  background: var(--white);
  transition: background 0.1s;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.calendar-cell:active {
  background: var(--surface);
}

.calendar-cell.other-month {
  background: #faf5f0;
}

.calendar-cell.other-month .calendar-day-number {
  color: var(--text-muted);
  opacity: 0.5;
}

.calendar-cell.today {
  background: #fff8e0;
  border: 1px solid var(--yellow);
}

.calendar-cell.today .calendar-day-number {
  font-weight: 700;
  color: var(--text);
}

.calendar-day-number {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text);
  line-height: 1.3;
}

/* ── Event Dots ──────────────────────────────── */
.calendar-dots {
  display: flex;
  gap: 2px;
  flex-wrap: wrap;
  justify-content: center;
  margin-top: 2px;
  min-height: 8px;
}

.calendar-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--primary);
  flex-shrink: 0;
}

.calendar-dot.multiple {
  background: var(--secondary);
}

.calendar-dot-rsvp-yes {
  background: var(--green);
}

.calendar-dot-rsvp-maybe {
  background: var(--yellow);
}

/* ── Bottom Sheet Overlay ────────────────────── */
.bottom-sheet-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 900;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.bottom-sheet-overlay.is-visible {
  opacity: 1;
  pointer-events: auto;
}

/* ── Bottom Sheet ────────────────────────────── */
.bottom-sheet {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 1001;
  background: var(--white);
  border-radius: 16px 16px 0 0;
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.12);
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1);
  max-height: 70vh;
  display: flex;
  flex-direction: column;
  padding-bottom: calc(env(safe-area-inset-bottom, 0px) + var(--nav-height));
}

.bottom-sheet.is-open {
  transform: translateY(0);
}

.bottom-sheet-handle {
  width: 36px;
  height: 4px;
  border-radius: 2px;
  background: var(--border-light);
  margin: var(--space-sm) auto 0;
  flex-shrink: 0;
}

.bottom-sheet-header {
  padding: var(--space-md) var(--space-md) var(--space-sm);
  border-bottom: 1px solid var(--border-light);
  flex-shrink: 0;
}

.bottom-sheet-header h3 {
  font-size: 1rem;
  font-weight: 700;
}

.bottom-sheet-body {
  padding: var(--space-sm) var(--space-md);
  overflow-y: auto;
  flex: 1;
}

.bottom-sheet-footer {
  padding: var(--space-sm) var(--space-md) var(--space-md);
  border-top: 1px solid var(--border-light);
  flex-shrink: 0;
}

/* ── Event Cards (in bottom sheet) ───────────── */
.event-card {
  display: flex;
  align-items: flex-start;
  gap: var(--space-sm);
  padding: var(--space-sm) 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  border-bottom: 1px solid var(--border-light);
  min-height: var(--touch-min);
}

.event-card:last-child {
  border-bottom: none;
}

.event-card:active {
  background: var(--surface);
  margin: 0 calc(-1 * var(--space-md));
  padding-left: var(--space-md);
  padding-right: var(--space-md);
}

.event-card-time {
  flex-shrink: 0;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--primary);
  min-width: 48px;
  padding-top: 2px;
}

.event-card-rsvp {
  display: inline-block;
  margin-left: 4px;
  font-size: 0.7rem;
  color: var(--text-muted);
  font-weight: 400;
}

.event-card-info {
  flex: 1;
  min-width: 0;
}

.event-card-title {
  display: block;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
}

.event-card-author {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 1px;
}

.event-card-empty {
  text-align: center;
  padding: var(--space-lg) var(--space-md);
  color: var(--text-muted);
  font-size: 0.9rem;
}

.event-card-hint,
.calendar-empty-hint {
  margin-top: var(--space-sm);
  font-size: 0.8rem;
  color: var(--primary);
  font-weight: 500;
}

/* ── Event Detail Page ───────────────────────── */
.event-detail {
  background: var(--white);
  border: 2px solid var(--border-light);
  border-radius: var(--radius);
  padding: var(--space-md);
}

.event-detail h2 {
  font-size: 1.2rem;
  margin-bottom: var(--space-sm);
}

.event-detail-meta {
  margin: var(--space-md) 0;
}

.event-detail-meta .meta-row {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-xs) 0;
  font-size: 0.9rem;
  color: var(--text);
  min-height: 36px;
}

.event-detail-meta .meta-label {
  flex-shrink: 0;
  width: 24px;
  text-align: center;
}

.event-detail-description {
  white-space: pre-wrap;
  font-size: 0.95rem;
  line-height: 1.6;
  margin: var(--space-md) 0;
  padding: var(--space-md);
  background: var(--bg);
  border-radius: var(--radius-sm);
  color: var(--text);
}

/* ── RSVP Section (Event Detail) ─────────────── */
.rsvp-section {
  margin: var(--space-md) 0;
}

.rsvp-group {
  display: flex;
  gap: var(--space-sm);
  width: 100%;
}

.rsvp-btn {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-xs);
  padding: 0.5rem 0.6rem;
  border: 2px solid var(--border);
  border-radius: 20px;
  background: var(--white);
  color: var(--text);
  font-size: 0.8rem;
  font-family: inherit;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  min-height: var(--touch-min);
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  white-space: nowrap;
}

.rsvp-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.rsvp-btn.rsvp-active {
  background: var(--primary);
  color: var(--white);
  border-color: var(--primary);
  font-weight: 600;
}

.rsvp-counts {
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: var(--space-sm);
}

/* ── Empty State ─────────────────────────────── */
.calendar-empty {
  text-align: center;
  padding: var(--space-xl) var(--space-md);
  color: var(--text-muted);
}

/* ── Post Actions Bar (Like) ─────────────────── */
.post-actions-bar {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-sm) 0;
  margin: var(--space-sm) 0;
  border-top: 1px solid var(--border-light);
  border-bottom: 1px solid var(--border-light);
}

.like-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 1rem;
  padding: var(--space-xs) var(--space-sm);
  border-radius: var(--radius);
  min-height: var(--touch-min);
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.15s;
}

.like-btn:hover {
  background: var(--surface);
}

.like-btn .like-count {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
}

/* ── Comments Section ────────────────────────── */
.comments-section {
  margin-top: var(--space-lg);
}

.comments-title {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: var(--space-md);
  color: var(--text);
}

.comment-item {
  padding: var(--space-sm) 0;
  border-bottom: 1px solid var(--border-light);
}

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

.comment-header {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  margin-bottom: var(--space-xs);
}

.comment-author {
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--text);
}

.comment-time {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.comment-content {
  font-size: 0.9rem;
  line-height: 1.5;
  color: var(--text);
  white-space: pre-wrap;
}

.comment-actions {
  display: flex;
  gap: var(--space-sm);
  margin-top: var(--space-xs);
}

.comment-actions button {
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 0.75rem;
  color: var(--text-muted);
  padding: 2px var(--space-xs);
  min-height: var(--touch-min);
  touch-action: manipulation;
}

.comment-actions button:hover {
  color: var(--text);
}

.comment-edit-textarea {
  width: 100%;
  padding: var(--space-sm);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-family: inherit;
  color: var(--text);
  resize: vertical;
  min-height: 60px;
  margin-bottom: var(--space-xs);
}

.comment-edit-textarea:focus {
  outline: none;
  border-color: var(--primary);
}

.comment-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  margin-top: var(--space-md);
  padding: var(--space-md);
  background: var(--surface);
  border-radius: var(--radius);
}

.comment-input {
  width: 100%;
  padding: 0.7rem 0.8rem;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-family: inherit;
  color: var(--text);
  resize: vertical;
  min-height: 60px;
  background: var(--white);
}

.comment-input:focus {
  outline: none;
  border-color: var(--primary);
}

.login-to-comment {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: var(--space-md);
  text-align: center;
}

.login-to-comment a {
  color: var(--primary);
  font-weight: 600;
}

/* ── Post social stats (bacheca cards) ───────── */
.post-social-stats {
  display: flex;
  gap: var(--space-md);
  margin-top: var(--space-sm);
  font-size: 0.8rem;
  color: var(--text-muted);
}

.post-social-stats span {
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

/* ── Responsive: tablet+ ───────────────────────── */
@media (min-width: 481px) {
  .piazza-page {
    padding: var(--space-lg);
    padding-bottom: calc(var(--nav-height) + var(--space-lg));
  }

  .post-card:hover {
    border-color: var(--border);
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  }

  .post-card:active {
    transform: none;
  }

  .calendar-cell {
    min-height: 64px;
    padding: 6px 4px;
  }

  .calendar-day-number {
    font-size: 0.95rem;
  }

  .calendar-dot {
    width: 7px;
    height: 7px;
  }
}

@media (min-width: 769px) {
  .bottom-nav {
    max-width: var(--content-max);
    left: 50%;
    transform: translateX(-50%);
    border-radius: var(--radius) var(--radius) 0 0;
  }
}

/* ════════════════════════════════════════════════
 * Changelog View
 * ════════════════════════════════════════════════ */

.changelog-page {
  padding-bottom: calc(var(--nav-height) + var(--space-lg));
}

.changelog-version {
  background: var(--white);
  border: 2px solid var(--border-light);
  border-radius: var(--radius);
  padding: var(--space-md);
  margin-bottom: var(--space-md);
}

.changelog-header {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin-bottom: var(--space-sm);
  padding-bottom: var(--space-sm);
  border-bottom: 1px solid var(--border-light);
}

.changelog-badge {
  display: inline-block;
  background: var(--primary);
  color: var(--white);
  font-size: 0.8rem;
  font-weight: 700;
  padding: 0.15rem 0.6rem;
  border-radius: 4px;
  font-family: monospace;
}

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

.changelog-section {
  margin-top: var(--space-sm);
}

.changelog-section-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: var(--space-xs);
}

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

.changelog-list li {
  font-size: 0.85rem;
  color: var(--text-light);
  line-height: 1.5;
  padding: 0.2rem 0;
  padding-left: 1rem;
  position: relative;
}

.changelog-list li::before {
  content: '•';
  position: absolute;
  left: 0;
  color: var(--text-muted);
}

/* ════════════════════════════════════════════════
 * Badge "Nuovo" su tab navigazione
 * ════════════════════════════════════════════════ */

.badge-new {
  position: absolute;
  top: -6px;
  right: -14px;
  font-size: 0.55rem;
  font-weight: 700;
  background: var(--danger);
  color: var(--white);
  padding: 1px 5px;
  border-radius: 8px;
  line-height: 1.3;
  white-space: nowrap;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

/* ════════════════════════════════════════════════
 * Toast nuova versione
 * ════════════════════════════════════════════════ */

.toast-version {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-xs);
  padding: 0.6rem 1rem;
  margin: 0 0 var(--space-md);
  background: var(--primary);
  color: var(--white);
  font-size: 0.85rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  min-height: var(--touch-min);
  text-align: center;
}

.toast-version:active {
  background: var(--primary-dark);
}

/* ════════════════════════════════════════════════
 * Event Reference — Badge (form chip)
 * ════════════════════════════════════════════════ */

.event-ref-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  padding: 0.35rem 0.8rem;
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: 20px;
  font-size: 0.8rem;
  color: var(--text);
  font-weight: 500;
  line-height: 1.3;
  white-space: nowrap;
  animation: fadeIn 0.2s ease;
}

.event-ref-badge .event-ref-title {
  color: var(--primary);
  font-weight: 600;
}

.btn-remove-ref {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: var(--danger);
  color: var(--white);
  font-size: 0.75rem;
  font-weight: 700;
  cursor: pointer;
  line-height: 1;
  transition: background 0.15s;
  flex-shrink: 0;
}

.btn-remove-ref:hover {
  background: #b03030;
}

/* ════════════════════════════════════════════════
 * Post Referenced Event (post detail)
 * ════════════════════════════════════════════════ */

.post-ref-event {
  margin: var(--space-md) 0;
  padding: var(--space-sm) var(--space-md);
  background: var(--surface);
  border-left: 3px solid var(--primary);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.post-ref-event .ref-event-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--primary);
  text-decoration: none;
  line-height: 1.3;
  margin-bottom: 2px;
  min-height: var(--touch-min);
  display: flex;
  align-items: center;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.post-ref-event .ref-event-title:active {
  opacity: 0.7;
}

.post-ref-event .ref-event-date {
  font-size: 0.8rem;
  color: var(--text);
  font-weight: 500;
}

.post-ref-event .ref-event-time {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-left: var(--space-xs);
}

.post-ref-event .ref-event-meta {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  flex-wrap: wrap;
  margin-top: var(--space-xs);
}

/* ════════════════════════════════════════════════
 * RSVP Inline (post detail referenced event)
 * ════════════════════════════════════════════════ */

.rsvp-inline {
  display: flex;
  gap: var(--space-xs);
  margin-top: var(--space-sm);
}

.rsvp-inline-btn {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 0.35rem 0.4rem;
  border: 2px solid var(--border-light);
  border-radius: 20px;
  background: var(--white);
  color: var(--text-light);
  font-size: 0.75rem;
  font-family: inherit;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  min-height: var(--touch-min);
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  white-space: nowrap;
}

.rsvp-inline-btn:hover {
  border-color: var(--border);
  color: var(--text);
}

.rsvp-inline-btn.is-yes {
  background: var(--green);
  color: var(--white);
  border-color: var(--green);
  font-weight: 600;
}

.rsvp-inline-btn.is-maybe {
  background: var(--yellow);
  color: var(--text);
  border-color: var(--yellow);
  font-weight: 600;
}

.rsvp-inline-btn.is-no {
  background: var(--danger);
  color: var(--white);
  border-color: var(--danger);
  font-weight: 600;
}

.rsvp-counts-inline {
  display: flex;
  gap: var(--space-sm);
  flex-wrap: wrap;
  margin-top: var(--space-xs);
  font-size: 0.75rem;
  color: var(--text-muted);
}

.rsvp-counts-inline span {
  display: inline-flex;
  align-items: center;
  gap: 2px;
}

/* ════════════════════════════════════════════════
 * Event Reference — Form Section
 * ════════════════════════════════════════════════ */

.event-ref-section {
  margin-bottom: var(--space-md);
}

.event-ref-section .event-ref-label {
  display: block;
  font-weight: 600;
  margin-bottom: var(--space-xs);
  font-size: 0.85rem;
  color: var(--text-light);
}

.event-ref-section .event-ref-selected {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  flex-wrap: wrap;
  margin-bottom: var(--space-sm);
}

.event-ref-selector {
  max-height: 260px;
  overflow-y: auto;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--white);
  -webkit-overflow-scrolling: touch;
}

.event-ref-option {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  cursor: pointer;
  border-bottom: 1px solid var(--border-light);
  min-height: var(--touch-min);
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.1s;
}

.event-ref-option:last-child {
  border-bottom: none;
}

.event-ref-option:active {
  background: var(--surface);
}

.event-ref-option .ref-opt-title {
  flex: 1;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
}

.event-ref-option .ref-opt-date {
  font-size: 0.75rem;
  color: var(--text-muted);
  flex-shrink: 0;
  text-align: right;
}

.event-ref-empty {
  text-align: center;
  padding: var(--space-lg) var(--space-md);
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* ════════════════════════════════════════════════
 * Event Reference — Search Modal
 * ════════════════════════════════════════════════ */

.event-ref-modal {
  position: fixed;
  inset: 0;
  z-index: 1002;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-md);
  background: rgba(0, 0, 0, 0.4);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.event-ref-modal.is-open {
  opacity: 1;
  pointer-events: auto;
}

.event-ref-modal-content {
  width: 100%;
  max-width: 440px;
  max-height: 80vh;
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.15);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: modalSlideIn 0.25s ease;
}

@keyframes modalSlideIn {
  from {
    opacity: 0;
    transform: translateY(16px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.event-ref-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-md);
  border-bottom: 1px solid var(--border-light);
  flex-shrink: 0;
}

.event-ref-modal-header h3 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
}

.event-ref-modal-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--touch-min);
  height: var(--touch-min);
  padding: 0;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--text-muted);
  font-size: 1.2rem;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  flex-shrink: 0;
}

.event-ref-modal-close:hover {
  background: var(--surface);
  color: var(--text);
}

.event-ref-modal-body {
  padding: var(--space-xs) 0;
  overflow-y: auto;
  flex: 1;
  -webkit-overflow-scrolling: touch;
}

.event-ref-modal-body .event-ref-option {
  padding: var(--space-sm) var(--space-md);
}

.event-ref-modal-body .event-ref-option:active {
  background: var(--surface);
  margin: 0;
  padding-left: var(--space-md);
  padding-right: var(--space-md);
}

/* ── Search input inside modal ────────────────── */

.event-ref-modal-search {
  padding: var(--space-sm) var(--space-md);
  border-bottom: 1px solid var(--border-light);
  flex-shrink: 0;
}

.event-ref-modal-search input {
  width: 100%;
  padding: 0.6rem 0.8rem;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  font-size: 0.9rem;
  font-family: inherit;
  color: var(--text);
  transition: border-color 0.15s;
  -webkit-appearance: none;
  appearance: none;
}

.event-ref-modal-search input:focus {
  outline: none;
  border-color: var(--primary);
}

@media (min-width: 481px) {
  .event-ref-modal-content {
    max-width: 480px;
  }
}

/* ════════════════════════════════════════════════
 * Changelog Admin — section form
 * ════════════════════════════════════════════════ */

.changelog-section {
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: var(--space-sm) var(--space-md);
  margin-bottom: var(--space-md);
  background: var(--white);
}

.changelog-section > label {
  font-weight: 600;
  color: var(--primary);
  font-size: 0.85rem;
  display: block;
  margin-bottom: var(--space-xs);
}

.changelog-items {
  margin-bottom: var(--space-xs);
}

.changelog-item-add {
  margin-top: var(--space-xs);
}
