/* ==========================================
   ATLANTE ILLUSTRATO DEI PROMESSI SPOSI
   Main Stylesheet
   ========================================== */

/* Base Styles */
body, html {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: 'Segoe UI', sans-serif;
  background-color: #1d2b2f;
  color: #eee;
  overflow: hidden;
}

#map {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
}

/* Timeline Styles */
#timeline {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 0;
  overflow: hidden;
  background: linear-gradient(180deg, #1d2b2f 0%, #243339 100%);
  border-top: 2px solid #333;
  padding: 0;
  z-index: 1000;
  transition: height 0.4s ease, padding 0.4s ease;
  box-shadow: 0 -4px 20px rgba(0,0,0,0.3);
}

#timeline.active {
  height: 280px;
  padding: 20px;
  overflow-y: auto;
  overflow-x: hidden;
}

.timeline-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 20px;
  max-height: 240px;
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 10px;
}

.chapter-group {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 12px;
  padding: 12px;
  transition: all 0.3s ease;
  border: 1px solid transparent;
}

.chapter-group:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 165, 0, 0.3);
}

.chapter-group.hidden {
  display: none;
}

.chapter-label {
  font-weight: bold;
  color: #a0d4f3;
  font-size: 0.75em;
  text-align: center;
  margin-bottom: 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: color 0.3s ease;
}

.chapter-group-points {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
  align-items: center;
  min-height: 40px;
}

.timeline-point {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background-color: #eee;
  cursor: pointer;
  transition: all 0.3s ease;
  position: relative;
  border: 2px solid transparent;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.timeline-point:hover {
  transform: scale(1.4);
  border-color: rgba(255, 255, 255, 0.6);
  box-shadow: 0 4px 12px rgba(255, 255, 255, 0.3);
  z-index: 10;
}

.timeline-point.active {
  transform: scale(1.3);
  border-color: #ffd700;
  box-shadow: 0 0 20px rgba(255, 215, 0, 0.6);
}

.timeline-point.hidden {
  display: none;
}

.timeline-point.highlighted {
  animation: pulseGlow 1.5s infinite;
  border-color: #ffa500;
  transform: scale(1.2);
  z-index: 5;
}

@keyframes pulseGlow {
  0%, 100% {
    box-shadow: 0 0 15px rgba(255, 165, 0, 0.8);
  }
  50% {
    box-shadow: 0 0 25px rgba(255, 165, 0, 0.4);
  }
}

@keyframes bounceIn {
  0% { transform: scale(0); }
  50% { transform: scale(1.2); }
  100% { transform: scale(1); }
}

.chapter-label.active {
  color: #ffd700;
}

/* Place Indicator */
.place-indicator {
  position: fixed;
  top: 50%;
  right: 30px;
  background: linear-gradient(135deg, #ffa500, #ff8c00);
  color: #1d2b2f;
  padding: 12px 20px;
  border-radius: 25px;
  font-weight: bold;
  font-size: 16px;
  white-space: nowrap;
  box-shadow: 0 4px 16px rgba(255, 165, 0, 0.4);
  transform: translateY(-50%) translateX(200%);
  transition: transform 0.4s ease;
  z-index: 1050;
  backdrop-filter: blur(10px);
}

.place-indicator.visible {
  transform: translateY(-50%) translateX(0);
}

.place-indicator::before {
  content: '';
  position: absolute;
  left: -8px;
  top: 50%;
  width: 0;
  height: 0;
  border-top: 8px solid transparent;
  border-bottom: 8px solid transparent;
  border-right: 8px solid #ffa500;
  transform: translateY(-50%);
}

/* Breadcrumb Filter Area */
.breadcrumb-container {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(43, 59, 69, 0.95);
  backdrop-filter: blur(10px);
  border-radius: 25px;
  padding: 10px 20px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.3);
  z-index: 1200;
  display: none;
  flex-wrap: wrap;
  gap: 8px;
  max-width: calc(80vw - 160px);
  align-items: center;
  transition: all 0.3s ease;
}

.breadcrumb-container.visible {
  display: flex;
}

/* Breadcrumb responsive positioning */
@media (max-width: 768px) {
  .breadcrumb-container {
    top: 90px;
    max-width: calc(100vw - 40px);
    left: 20px;
    transform: none;
  }
  
  .breadcrumb-container.logo-minimized {
    top: 70px;
  }
}

.filter-chip {
  background: linear-gradient(135deg, #ffa500, #ff8c00);
  color: #1d2b2f;
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: bold;
  display: flex;
  align-items: center;
  gap: 6px;
  animation: slideIn 0.3s ease;
  box-shadow: 0 2px 8px rgba(255, 165, 0, 0.3);
}

.filter-chip-remove {
  background: rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  width: 16px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 12px;
  font-weight: bold;
  transition: all 0.3s ease;
}

.filter-chip-remove:hover {
  background: rgba(255, 255, 255, 0.5);
  transform: scale(1.1);
}

.breadcrumb-label {
  color: #a0d4f3;
  font-size: 11px;
  font-weight: bold;
  margin-right: 5px;
}

/* FAB Menu */
.fab-container {
  position: fixed;
  bottom: 20px;
  left: 20px;
  z-index: 1100;
  transition: all 0.4s ease;
}

.fab-container.minimized {
  bottom: 10px;
  left: 10px;
}

@media (max-width: 768px) {
  .fab-container.minimized {
    bottom: 20px;
    left: 20px;
    transform: scale(0.8);
  }
}

.fab-main {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 15px;
}

.fab-sphere {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: bold;
  position: relative;
}

#fab-toggle {
  background: linear-gradient(135deg, #ffa500, #ff8c00);
  color: #1d2b2f;
}

#fab-timeline {
  background: linear-gradient(135deg, #4d88ff, #3366ff);
  color: white;
}

#fab-filters {
  background: linear-gradient(135deg, #66a3ff, #4d88ff);
  color: white;
}

.fab-sphere:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 16px rgba(0,0,0,0.4);
}

.fab-sphere.active {
  background: linear-gradient(135deg, #ffd700, #ffcc00);
  color: #1d2b2f;
}

/* Side panels */
.fab-panel {
  position: absolute;
  left: 60px;
  bottom: 0;
  background: rgba(43, 59, 69, 0.95);
  backdrop-filter: blur(10px);
  padding: 15px;
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
  display: none;
  flex-direction: column;
  gap: 10px;
  min-width: 220px;
  animation: slideIn 0.3s ease;
}

.fab-panel.visible {
  display: flex;
}

/* Responsive panel positioning */
@media (max-width: 768px) {
  .fab-panel {
    position: absolute;
    left: 60px;
    bottom: 0;
    right: auto;
    max-width: calc(100vw - 120px);
    min-width: 200px;
    width: auto;
  }
  
  #filters-panel {
    max-height: 60vh;
    overflow-y: auto;
    max-width: calc(100vw - 120px);
  }
  
  /* Ensure panels don't go off-screen on very small devices */
  .fab-main > div:nth-child(2) .fab-panel,
  .fab-main > div:nth-child(3) .fab-panel {
    left: 60px;
    right: auto;
    transform: none;
  }
  
  /* Adjust if panel would go off right edge */
  @media (max-width: 480px) {
    .fab-panel {
      left: 50px;
      max-width: calc(100vw - 90px);
      min-width: 180px;
    }
  }
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateX(-20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.fab-panel-btn {
  background: linear-gradient(135deg, #ffa500, #ff8c00);
  color: #1d2b2f;
  border: none;
  border-radius: 8px;
  padding: 10px 15px;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.3s ease;
  white-space: nowrap;
}

.fab-panel-btn:hover {
  background: linear-gradient(135deg, #ffb933, #ffa500);
  transform: translateY(-2px);
}

.fab-panel-btn.active {
  background: linear-gradient(135deg, #ffd700, #ffcc00);
  box-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
}

.fab-panel-btn.reset {
  background: linear-gradient(135deg, #6b7785, #5a6670);
  color: white;
  padding: 8px 12px;
  font-size: 12px;
  width: auto;
  align-self: flex-start;
  min-width: auto;
  height: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.fab-panel-btn.reset:hover {
  background: linear-gradient(135deg, #7a8691, #6b7785);
}

.fab-dropdown {
  background: #eee;
  color: #1d2b2f;
  border-radius: 6px;
  border: none;
  padding: 8px 12px;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.fab-dropdown:hover {
  background: #f5f5f5;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

/* Page Range Slider */
.page-slider-container {
  margin: 10px 0;
}

.page-slider-label {
  color: #a0d4f3;
  font-size: 12px;
  font-weight: bold;
  margin-bottom: 8px;
  display: block;
}

.page-slider {
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: #333;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
  margin: 5px 0;
}

.page-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #ffa500;
  cursor: pointer;
  box-shadow: 0 2px 4px rgba(0,0,0,0.3);
  transition: all 0.3s ease;
}

.page-slider::-webkit-slider-thumb:hover {
  background: #ffb933;
  transform: scale(1.2);
}

.page-slider::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #ffa500;
  cursor: pointer;
  border: none;
  box-shadow: 0 2px 4px rgba(0,0,0,0.3);
  transition: all 0.3s ease;
}

.page-range-display {
  color: #ffa500;
  font-size: 11px;
  font-weight: bold;
  text-align: center;
  margin-top: 5px;
}

/* Timeline stats */
.timeline-stats {
  position: absolute;
  top: 10px;
  right: 20px;
  background: rgba(0,0,0,0.6);
  padding: 8px 12px;
  border-radius: 20px;
  font-size: 12px;
  color: #a0d4f3;
  backdrop-filter: blur(5px);
}

.leaflet-control-zoom {
  bottom: 30px !important;
  right: 20px !important;
  transition: bottom 0.4s ease !important;
  z-index: 1001 !important;
}

/* City area styles */
.city-area {
  fill-opacity: 0.7;
  stroke-width: 2;
  stroke-opacity: 0.9;
  cursor: pointer;
  transition: all 0.3s ease;
}

.city-area:hover {
  fill-opacity: 0.9;
  stroke-width: 3;
}

.city-label {
  font-family: 'Segoe UI', sans-serif;
  font-weight: bold;
  font-size: 12px;
  fill: #1d2b2f;
  text-anchor: middle;
  dominant-baseline: central;
  pointer-events: none;
  text-shadow: 1px 1px 2px rgba(255,255,255,0.8);
}

.city-count {
  font-family: 'Segoe UI', sans-serif;
  font-weight: bold;
  font-size: 10px;
  fill: #1d2b2f;
  text-anchor: middle;
  dominant-baseline: central;
  pointer-events: none;
  text-shadow: 1px 1px 2px rgba(255,255,255,0.8);
}

/* Item card popup */
.item-card {
  position: absolute;
  background: rgba(0, 0, 0, 0.95);
  color: #eee;
  border: 2px solid #66a3ff;
  border-radius: 12px;
  padding: 15px;
  max-width: 300px;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
  z-index: 1500;
  font-size: 14px;
  line-height: 1.4;
  backdrop-filter: blur(10px);
  transition: all 0.3s ease;
}

@media (max-width: 768px) {
  .item-card {
    position: fixed;
    top: 140px !important;
    left: 20px !important;
    right: 20px !important;
    max-width: none !important;
    width: auto !important;
    max-height: calc(100vh - 160px);
  }
  
  .item-card.logo-minimized {
    top: 100px !important;
  }
}

.item-card img {
  width: 100%;
  max-height: 40vh;
  object-fit: contain;
  border-radius: 8px;
  margin: 10px 0;
}

.item-card h3 {
  margin: 0 0 10px 0;
  color: #66a3ff;
  font-size: 16px;
  padding-right: 35px;
}

.item-card .meta {
  margin: 5px 0;
  color: #a0d4f3;
}

.item-card .link {
  display: inline-block;
  margin-top: 10px;
  padding: 8px 15px;
  background: linear-gradient(135deg, #66a3ff, #4d88ff);
  color: white;
  text-decoration: none;
  border-radius: 6px;
  font-weight: bold;
  transition: all 0.3s ease;
}

.item-card .link:hover {
  background: linear-gradient(135deg, #80bfff, #66a3ff);
  transform: translateY(-2px);
}

.card-close {
  position: absolute;
  top: 10px;
  right: 15px;
  width: 25px;
  height: 25px;
  background: rgba(255, 0, 0, 0.7);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 16px;
  font-weight: bold;
  transition: all 0.3s ease;
}

.card-close:hover {
  background: rgba(255, 0, 0, 0.9);
  transform: scale(1.1);
}

.connection-line {
  opacity: 0.7;
  transition: all 0.3s ease;
}

/* Quick tooltip */
.quick-tooltip {
  pointer-events: none;
  font-family: 'Segoe UI', sans-serif;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

/* Spider graph elements */
.spider-node {
  cursor: pointer;
  transition: all 0.3s ease;
}

.spider-node-center {
  stroke: #ffa500;
  stroke-width: 3px;
}

.spider-node-item {
  stroke: #fff;
  stroke-width: 2px;
}

.spider-node:hover {
  stroke-width: 4px;
}

.spider-link {
  stroke: #66a3ff;
  stroke-opacity: 0.6;
  stroke-width: 2px;
}

.spider-label {
  font-family: 'Segoe UI', sans-serif;
  font-size: 10px;
  fill: #eee;
  text-anchor: middle;
  dominant-baseline: central;
  pointer-events: none;
  text-shadow: 1px 1px 2px rgba(0,0,0,0.8);
}

/* Error message */
.error-message {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(255, 0, 0, 0.9);
  color: white;
  padding: 20px;
  border-radius: 10px;
  text-align: center;
  z-index: 2000;
  max-width: 400px;
}

/* Scrollbar styling */
.timeline-grid::-webkit-scrollbar {
  width: 8px;
}

.timeline-grid::-webkit-scrollbar-track {
  background: rgba(255,255,255,0.1);
  border-radius: 4px;
}

.timeline-grid::-webkit-scrollbar-thumb {
  background: rgba(255,165,0,0.6);
  border-radius: 4px;
}

.timeline-grid::-webkit-scrollbar-thumb:hover {
  background: rgba(255,165,0,0.8);
}

/* Logo styling */
.project-logo {
  position: fixed;
  top: 20px;
  left: 20px;
  height: 120px;
  width: auto;
  border-radius: 12px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.3);
  z-index: 1150;
  transition: all 0.4s ease;
  cursor: pointer;
  overflow: hidden;
}

.project-logo:hover {
  transform: scale(1.05);
  box-shadow: 0 6px 20px rgba(255, 165, 0, 0.4);
}

.project-logo img {
  height: 100%;
  width: auto;
  border-radius: 8px;
  object-fit: contain;
  display: block;
  transition: all 0.4s ease;
}

/* Minimized logo state */
.project-logo.minimized {
  height: 60px;
  width: 60px;
  border-radius: 30px;
  padding: 0;
}

.project-logo.minimized img {
  height: 100%;
  width: 100%;
  object-fit: cover;
  transform: scale(1.6);
}

@media (max-width: 768px) {
  .project-logo {
    height: 80px;
  }
  
  .project-logo.minimized {
    height: 50px;
    width: 50px;
    padding: 0;
  }
}

/* Viewport state management */
.viewport-busy .project-logo {
  height: 60px;
  width: 60px;
  border-radius: 30px;
  padding: 0;
}

.viewport-busy .project-logo img {
  height: 100%;
  width: 100%;
  object-fit: cover;
  transform: scale(1.6);
}.project-logo.minimized img

.viewport-busy .fab-container {
  bottom: 10px;
  left: 10px;
}

@media (max-width: 768px) {
  .viewport-busy .fab-container {
    transform: scale(0.8);
  }
}
