/*
 * Vora PA — Bootstrap Italia Overrides
 *
 * Custom styles on top of Bootstrap Italia 2.x for the Vora civic
 * participation platform. Maintains BI design language while adding
 * platform-specific components (sidebar, voting, comments).
 *
 * Load AFTER bootstrap-italia.min.css
 */

/* ============================================
   1. MUNICIPALITY THEMING (CSS Custom Properties)
   Each municipality can override --bs-primary
   ============================================ */
:root {
  --vora-primary: #0066CC;  /* Italia Blue default, overridable per-tenant */
  --vora-primary-rgb: 0, 102, 204;
  --vora-dark: #17324D;
  --vora-sidebar-width: 260px;
  --vora-sidebar-collapsed: 72px;
  --vora-header-height: 56px;
}


/* ============================================
   2. APP SIDEBAR (not in BI — custom component)
   ============================================ */
.vora-sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--vora-sidebar-width);
  background: var(--vora-dark);
  color: #fff;
  z-index: 1040;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  transition: width 0.2s ease;
}

.vora-sidebar-header {
  padding: 20px 24px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.vora-sidebar-logo img {
  height: 32px;
  width: auto;
}

.vora-sidebar-nav {
  flex: 1;
  padding: 12px 0;
}

.vora-sidebar-nav .nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 24px;
  color: rgba(255,255,255,0.7);
  font-size: 0.9375rem;
  font-weight: 400;
  text-decoration: none;
  border-left: 3px solid transparent;
  transition: all 0.15s ease;
}

.vora-sidebar-nav .nav-link:hover {
  color: #fff;
  background: rgba(255,255,255,0.06);
}

.vora-sidebar-nav .nav-link.active {
  color: #fff;
  background: rgba(255,255,255,0.1);
  border-left-color: var(--vora-primary);
  font-weight: 600;
}

.vora-sidebar-nav .nav-link .icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  fill: currentColor;
}

/* Main content offset */
.vora-main {
  margin-left: var(--vora-sidebar-width);
  min-height: 100vh;
  background: #f2f7fc;  /* BI light background */
}

/* Top header bar */
.vora-topbar {
  height: var(--vora-header-height);
  background: #fff;
  border-bottom: 1px solid #d9dadb;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 1030;
}

/* Mobile sidebar */
@media (max-width: 991.98px) {
  .vora-sidebar {
    transform: translateX(-100%);
    transition: transform 0.3s ease;
  }
  .vora-sidebar.show {
    transform: translateX(0);
  }
  .vora-main {
    margin-left: 0;
  }
  .vora-sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1039;
  }
  .vora-sidebar-overlay.show {
    display: block;
  }
}


/* ============================================
   3. STAT CARDS (dashboard KPIs)
   ============================================ */
.vora-stat-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--vora-dark);
  line-height: 1.2;
}

.vora-stat-label {
  font-size: 0.8125rem;
  color: #5c6f82;
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.vora-stat-detail {
  font-size: 0.75rem;
  color: #768594;
  margin-top: 2px;
}


/* ============================================
   4. VOTING COMPONENTS (not in BI)
   ============================================ */
.vora-choice-item {
  cursor: pointer;
  transition: all 0.15s ease;
  border: 2px solid transparent;
}

.vora-choice-item:hover {
  border-color: var(--vora-primary);
  background: rgba(var(--vora-primary-rgb), 0.04);
}

.vora-choice-item.selected {
  border-color: var(--vora-primary);
  background: rgba(var(--vora-primary-rgb), 0.08);
}


/* ============================================
   5. COMMENT COMPONENTS
   ============================================ */
.vora-comment {
  border-bottom: 1px solid #d9dadb;
  padding: 16px 0;
}

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

.vora-comment-author {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--vora-dark);
}

.vora-comment-time {
  font-size: 0.75rem;
  color: #768594;
}

.vora-comment-body {
  font-size: 0.9375rem;
  line-height: 1.6;
  color: #333;
  margin: 8px 0;
}

.vora-comment-replies {
  margin-left: 32px;
  padding-left: 16px;
  border-left: 2px solid #d9dadb;
}


/* ============================================
   6. ACCESSIBILITY ENHANCEMENTS
   ============================================ */
.skip-nav {
  position: absolute;
  top: -100px;
  left: 16px;
  background: var(--vora-primary);
  color: #fff;
  padding: 8px 16px;
  border-radius: 0 0 4px 4px;
  z-index: 9999;
  font-weight: 600;
  text-decoration: none;
}

.skip-nav:focus {
  top: 0;
  color: #fff;
}


/* ============================================
   7. MODAL FIX: BI sets .modal { display:none }
   Our custom modals use .modal-backdrop > .modal pattern
   which conflicts with BI's Bootstrap 5 modal component.
   ============================================ */
.modal-backdrop .modal,
.modal-backdrop .vote-modal,
.modal-backdrop .proposal-modal,
.modal-backdrop .share-modal,
.modal-backdrop .confirm-modal {
  display: block !important;
  position: relative !important;
  z-index: auto !important;
  width: auto !important;
  height: auto !important;
  overflow: visible !important;
  top: auto !important;
  left: auto !important;
}

/* ============================================
   8. SLIM HEADER AUTH BUTTON
   user-menu.js dynamically replaces header-auth content.
   Ensure the Accedi button is properly styled inside BI slim header.
   ============================================ */
#header-auth .btn,
#header-auth .btn-primary,
.it-header-slim-wrapper .btn-primary,
.it-header-slim-right-zone .btn-primary {
  display: inline-flex !important;
  align-items: center !important;
  padding: 4px 16px !important;
  font-size: 0.875rem !important;
  font-weight: 600 !important;
  border-radius: 4px !important;
  background-color: #0066CC !important;
  border-color: #0066CC !important;
  color: #fff !important;
  text-decoration: none !important;
  white-space: nowrap !important;
  line-height: 1.5 !important;
  height: auto !important;
  min-height: 32px !important;
}

#header-auth .btn:hover,
#header-auth .btn-primary:hover,
.it-header-slim-wrapper .btn-primary:hover,
.it-header-slim-right-zone .btn-primary:hover {
  background-color: #004C99 !important;
  border-color: #004C99 !important;
}

/* ============================================
   9. USER MENU IN BI HEADER
   user-menu.js generates a dropdown that needs BI-compatible styling
   ============================================ */
/* These rules style the user-menu when it sits inside BI's dark slim
   header (.it-header-slim-right-zone). The previous version also matched
   #header-auth, which broke pages that put #header-auth inside a WHITE
   custom header (add-proposal, space, dashboard, etc.) — white text on
   white background, pill border invisible.

   Now scoped strictly to .it-header-slim-right-zone. On other pages,
   components.css defaults (.user-menu-trigger { border: 1px solid var(
   --pearl); ... }, .user-name { color: var(--charcoal) }) apply. */
.it-header-slim-right-zone .user-menu {
  display: inline-flex !important;
  align-items: center !important;
}

.it-header-slim-right-zone .user-menu-trigger {
  display: inline-flex !important;
  align-items: center !important;
  gap: 6px !important;
  background: none !important;
  border: 1px solid rgba(255,255,255,0.3) !important;
  border-radius: 4px !important;
  padding: 4px 12px !important;
  color: #fff !important;
  cursor: pointer !important;
  font-size: 0.8125rem !important;
  font-weight: 500 !important;
  white-space: nowrap !important;
}

.it-header-slim-right-zone .user-menu-trigger:hover {
  background: rgba(255,255,255,0.1) !important;
  border-color: rgba(255,255,255,0.5) !important;
}

.it-header-slim-right-zone .user-avatar {
  width: 24px !important;
  height: 24px !important;
  border-radius: 50% !important;
  background: #0066CC !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  font-size: 0.6875rem !important;
  font-weight: 700 !important;
  color: #fff !important;
}

.it-header-slim-right-zone .user-avatar img {
  width: 100% !important;
  height: 100% !important;
  border-radius: 50% !important;
  object-fit: cover !important;
}

.it-header-slim-right-zone .user-name {
  color: #fff !important;
  font-size: 0.8125rem !important;
}

.it-header-slim-right-zone .dropdown-arrow {
  width: 12px !important;
  height: 12px !important;
  color: rgba(255,255,255,0.7) !important;
}

/* Custom white-header pages (#header-auth NOT inside BI slim header):
   keep the avatar branded blue but force readable colors for the name
   and chevron and a visible pill border. */
#header-auth:not(.it-header-slim-right-zone *) .user-avatar {
  background: #0066CC !important;
  color: #fff !important;
}
#header-auth:not(.it-header-slim-right-zone *) .user-menu-trigger {
  color: #17324D !important;
  border: 1px solid #d9dadb !important;
  background: #fff !important;
}
#header-auth:not(.it-header-slim-right-zone *) .user-menu-trigger:hover {
  background: #f8f9fa !important;
  border-color: #b8c1ca !important;
}
#header-auth:not(.it-header-slim-right-zone *) .user-name {
  color: #17324D !important;
}
#header-auth:not(.it-header-slim-right-zone *) .dropdown-arrow {
  color: #5a6772 !important;
}

.it-header-slim-right-zone .user-dropdown,
#header-auth .user-dropdown {
  position: absolute !important;
  right: 0 !important;
  top: 100% !important;
  background: #fff !important;
  border: 1px solid #d9dadb !important;
  border-radius: 8px !important;
  box-shadow: 0 8px 24px rgba(0,0,0,0.12) !important;
  min-width: 200px !important;
  z-index: 1060 !important;
  display: none !important;
  padding: 8px 0 !important;
}

.it-header-slim-right-zone .user-dropdown.active,
#header-auth .user-dropdown.active {
  display: block !important;
}

.it-header-slim-right-zone .user-dropdown .dropdown-item,
#header-auth .user-dropdown .dropdown-item {
  display: block !important;
  padding: 8px 16px !important;
  color: #17324D !important;
  text-decoration: none !important;
  font-size: 0.875rem !important;
  background: none !important;
  border: none !important;
  width: 100% !important;
  text-align: left !important;
  cursor: pointer !important;
}

.it-header-slim-right-zone .user-dropdown .dropdown-item:hover,
#header-auth .user-dropdown .dropdown-item:hover {
  background: #f2f7fc !important;
}

.it-header-slim-right-zone .user-dropdown .dropdown-divider,
#header-auth .user-dropdown .dropdown-divider {
  border-top: 1px solid #d9dadb !important;
  margin: 4px 0 !important;
}

/* Visibility badge (Pubblica/Privata) in slim header */
.vora-visibility-badge {
  display: inline-flex !important;
  align-items: center !important;
  gap: 4px !important;
  padding: 3px 10px !important;
  border-radius: 4px !important;
  font-size: 0.6875rem !important;
  font-weight: 600 !important;
  text-decoration: none !important;
  text-transform: uppercase !important;
  letter-spacing: 0.5px !important;
  background: rgba(255,255,255,0.15) !important;
  color: rgba(255,255,255,0.9) !important;
  border: none !important;
  transition: all 0.15s ease !important;
}

.vora-visibility-badge:hover {
  background: rgba(255,255,255,0.25) !important;
  color: #fff !important;
}

.vora-visibility-badge svg {
  width: 14px !important;
  height: 14px !important;
}

/* Align "Nuova Proposta" button in slim header */
.it-header-slim-right-zone,
#header-auth {
  display: flex !important;
  align-items: center !important;
  gap: 8px !important;
}

/* Hide XP card in user menu (PA mode) */
.it-header-slim-right-zone .user-xp-card,
#header-auth .user-xp-card {
  display: none !important;
}

/* ============================================
   10. VOTE OPTIONS: standardize icons (circle=single, square=multiple)
   proposal.js generates SVGs with circle/line for choices.
   Override to show consistent radio (circle) or checkbox (square) icons.
   ============================================ */

/* Vote option icons: standardize to circle (single) / square (multiple)
   Hide JS-generated SVG icons and replace with CSS pseudo-elements */
.vote-btn-icon svg {
  display: none !important;
}

.vote-btn-icon::before {
  content: '';
  display: block;
  width: 22px;
  height: 22px;
  border: 3px solid #17324D;
  border-radius: 50%; /* circle = radio (single choice) */
  transition: all 0.15s ease;
}

/* Multiple choice → square checkbox icon */
.approval-voting-container .vote-btn-icon::before,
[data-voting-type="multiple_choice"] .vote-btn-icon::before,
[data-voting-type="approval_voting"] .vote-btn-icon::before {
  border-radius: 3px; /* square = checkbox */
}

/* Selected state */
.vote-btn.selected .vote-btn-icon::before,
.vote-btn:hover .vote-btn-icon::before {
  border-color: #0066CC;
  background: #0066CC;
  box-shadow: inset 0 0 0 3px #fff;
}

/* Timeline card: proper BI-compatible styling */
.timeline-card {
  background: #fff !important;
  border: 1px solid #d9dadb !important;
  border-radius: 8px !important;
  padding: 20px !important;
  margin-top: 16px !important;
}

.timeline-item {
  display: flex !important;
  gap: 14px !important;
  padding-bottom: 20px !important;
  position: relative !important;
}

.timeline-item:not(:last-child)::before {
  content: '' !important;
  position: absolute !important;
  left: 5px !important;
  top: 14px !important;
  bottom: 0 !important;
  width: 2px !important;
  background: #d9dadb !important;
}

.timeline-item:last-child {
  padding-bottom: 0 !important;
}

.timeline-dot {
  width: 12px !important;
  height: 12px !important;
  border-radius: 50% !important;
  background: #d9dadb !important;
  flex-shrink: 0 !important;
  margin-top: 3px !important;
  position: relative !important;
  z-index: 1 !important;
}

.timeline-dot.active {
  background: #0066CC !important;
}

.timeline-content {
  flex: 1 !important;
}

.timeline-label {
  font-size: 0.75rem !important;
  font-weight: 600 !important;
  color: #768594 !important;
  text-transform: uppercase !important;
  letter-spacing: 0.3px !important;
  margin-bottom: 4px !important;
}

.timeline-value {
  font-size: 0.9375rem !important;
  color: #17324D !important;
  font-weight: 500 !important;
  line-height: 1.5 !important;
  margin-bottom: 4px !important;
}

.timeline-remaining {
  font-size: 0.75rem !important;
  color: #0066CC !important;
  font-weight: 600 !important;
  margin-top: 2px !important;
}

/* Results stats: force horizontal layout */
.results-stats {
  display: flex !important;
  flex-direction: row !important;
  gap: 16px !important;
  align-items: center !important;
  flex-wrap: wrap !important;
}

.results-stat {
  display: inline-flex !important;
  align-items: center !important;
  gap: 4px !important;
  white-space: nowrap !important;
}

.results-stat-divider {
  display: inline !important;
}

/* Results card header: horizontal alignment */
.results-card .card-header {
  display: flex !important;
  flex-direction: column !important;
  gap: 8px !important;
}

.results-card .card-header .results-stats {
  display: flex !important;
  flex-direction: row !important;
  gap: 12px !important;
}

/* ============================================
   9. EXPLORE PAGE CARDS (generated by explore.js)
   ============================================ */
.explore-space-card {
  display: flex;
  flex-direction: column;
  background: #fff;
  border: 1px solid #d9dadb;
  border-radius: 8px;
  overflow: hidden;
  text-decoration: none;
  color: inherit;
  transition: box-shadow 0.2s ease, transform 0.15s ease;
}

.explore-space-card:hover {
  box-shadow: 0 8px 24px rgba(0,0,0,0.08);
  transform: translateY(-2px);
  color: inherit;
  text-decoration: none;
}

.explore-space-card-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 16px 12px;
}

.explore-space-card-avatar {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  background: #e8f0fe;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  font-weight: 700;
  color: #0066CC;
  flex-shrink: 0;
  overflow: hidden;
}

.explore-space-card-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

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

.explore-space-card-name {
  font-size: 1rem;
  font-weight: 600;
  color: #17324D;
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.explore-space-card-arrow {
  color: #5c6f82;
}

.explore-space-card-description {
  padding: 0 16px;
  font-size: 0.875rem;
  color: #5c6f82;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.explore-space-card-tags {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  padding: 8px 16px;
}

.explore-space-card-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.6875rem;
  font-weight: 500;
  background: #e8f0fe;
  color: #0066CC;
}

.explore-space-card-tag--location {
  background: #e8f5e9;
  color: #1b5e20;
}

.explore-space-card-tag--idea {
  background: #fff3e0;
  color: #e65100;
}

.explore-space-card-footer {
  margin-top: auto;
  border-top: 1px solid #e8e8e8;
  padding: 12px 16px;
}

.explore-space-card-stats {
  display: flex;
  gap: 16px;
}

.explore-space-card-stat {
  text-align: center;
}

.explore-space-card-stat-value {
  display: block;
  font-size: 1rem;
  font-weight: 700;
  color: #17324D;
}

.explore-space-card-stat-label {
  font-size: 0.6875rem;
  color: #768594;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.explore-empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 48px 24px;
  color: #5c6f82;
}

.verified-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.6875rem;
  font-weight: 600;
}

/* ============================================
   8. LEGACY CLASS COMPATIBILITY
   JS modules reference old class names — map to BI equivalents
   ============================================ */
.form-input-error,
.form-control.form-input-error {
  border-color: var(--bs-danger) !important;
  box-shadow: 0 0 0 0.25rem rgba(var(--bs-danger-rgb), 0.15);
}

.form-input-disabled,
.form-control.form-input-disabled {
  opacity: 0.5;
  pointer-events: none;
}

/* auth-message classes used by login.js */
.auth-message-error {
  /* handled by .alert.alert-danger */
}
.auth-message-success {
  /* handled by .alert.alert-success */
}

/* ============================================
   8. UTILITY OVERRIDES
   ============================================ */
.hidden {
  display: none !important;
}

/* Page content padding */
.vora-page-content {
  padding: 24px;
  max-width: 1200px;
}

@media (max-width: 767.98px) {
  .vora-page-content {
    padding: 16px;
  }
}

/* ============================================
   STATIC LABEL OVERRIDE (Vora form pattern)
   ============================================
   Bootstrap Italia 2.x positions every `.form-group label` absolutely
   so it floats inside the input (BI floating-label pattern). Our pages
   (add-proposal, edit-proposal, settings, login, signup, etc.) use a
   classic static label ABOVE the input via `.form-label`. Without this
   override, BI's position:absolute on labels makes them sit on top of
   the input/select content, producing the "labels overlapping values"
   bug visible on add-proposal.html.

   Scope: any label classed .form-label is forced static. Labels inside
   `.form-floating` (BI floating-label container) are not targeted and
   keep working as intended. */

.form-group > .form-label,
.form-group > label.form-label,
label.form-label {
  position: static !important;
  background-color: transparent !important;
  transform: none !important;
  padding: 0 !important;
  pointer-events: auto !important;
  display: block;
  margin-bottom: 0.5rem;
}

/* Catch-all: every label inside .form-group is forced static so the
   BI floating-label rule cannot collide with our pattern. The exclusion
   `:not(.form-floating *)` keeps BI's intentional floating-label
   container working for any future page that uses it. */
.form-group label:not(.form-floating *) {
  position: static !important;
  background-color: transparent !important;
  transform: none !important;
}

/* Do NOT force visibility on the native radio/checkbox inputs: pages
   like add-proposal.html intentionally hide the native input
   (`.visibility-option input { position: absolute; opacity: 0 }` in
   add-proposal.css) and render the selected state via a styled card.
   The previous override that forced opacity:1 broke that pattern. */
