/* === RESET GLOBAL === */
*, *::before, *::after {
  box-sizing: border-box;
}

/* === VARIABLES (pedralcg.dev design tokens) === */
:root {
  --forest:      #1e5c2e;
  --forest-mid:  #2d7a3a;
  --earth:       #c9882a;
  --earth-dark:  #a87020;
  --earth-lt:    #f0d9b5;
  --sage:        #a8c8a0;
  --sage-lt:     #d4e8d0;
  --bg:          #f1f6f1;
  --surface:     #f9fbf9;
  --border:      #e2ede2;
  --text:        #1a2a1a;
  --text-muted:  #445044;

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 22px;

  --shadow-sm: 0 1px 4px rgba(10,26,15,0.2), 0 2px 8px rgba(10,26,15,0.1);
  --shadow-md: 0 4px 16px rgba(10,26,15,0.3), 0 8px 24px rgba(10,26,15,0.2);

  --t: 220ms;
  --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
}

/* === BASE === */
body, html {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
}

/* === LAYOUT === */
main {
  flex: 1;
  display: flex;
  min-height: 0;
}

/* === SIDEBAR === */
#sidebar {
  width: clamp(400px, 35%, 600px);
  background: var(--surface);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 1rem;
  box-shadow: var(--shadow-sm);
}
#sidebar h2 {
  margin-top: 0;
  font-size: 1.2rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--forest);
}
#sidebar ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

/* === INTRO === */
.sidebar-intro {
  font-size: 0.83rem;
  color: var(--text-muted);
  line-height: 1.55;
  margin: 0 0 1rem 0;
  padding: 0.65rem 0.85rem;
  background: var(--sage-lt);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

/* === CONTROLES === */
.panorama-controls {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}
.panorama-controls input,
.panorama-controls select {
  padding: 0.5rem 0.6rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-family: var(--font-sans);
  color: var(--text);
  background: var(--bg);
  transition: border-color var(--t) ease;
}
.panorama-controls input {
  flex: 1;
}
.panorama-controls input:focus,
.panorama-controls select:focus {
  outline: none;
  border-color: var(--forest-mid);
}

.results-count {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin: 0 0 0.5rem 0;
}

/* === LISTA PANORAMAS === */
#panoramaList li {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.75rem;
  margin-bottom: 0.75rem;
  box-shadow: var(--shadow-sm);
  transition: transform var(--t) ease, box-shadow var(--t) ease, border-color var(--t) ease;
}
#panoramaList li.active {
  border-color: var(--earth);
  box-shadow: 0 0 0 3px rgba(201, 136, 42, 0.25);
}
#panoramaList li:hover {
  transform: translateY(-1.5px);
  box-shadow: var(--shadow-md);
}
#panoramaList li img {
  width: 90px;
  height: 65px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}
#panoramaList li .thumb-placeholder {
  width: 90px;
  height: 65px;
  background: var(--sage-lt);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-size: 0.7rem;
  color: var(--text-muted);
  padding: 0.25rem;
  flex-shrink: 0;
  line-height: 1.2;
}
#panoramaList li .panorama-meta {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  min-width: 0;
}
#panoramaList li strong {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
}
#panoramaList li .panorama-desc {
  font-size: 0.82rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#panoramaList li small {
  font-size: 0.75rem;
  color: var(--text-muted);
}
#panoramaList li button {
  background: var(--earth);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--t) ease, transform var(--t) ease;
  padding: 0.5rem 0.75rem;
  font-size: 0.83rem;
  font-family: var(--font-sans);
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-width: 90px;
  flex-shrink: 0;
}
#panoramaList li button:hover {
  background: var(--earth-dark);
  transform: translateY(-1px);
}

/* === MAPA === */
#map { flex: 1; }

/* === MODAL VISOR 360 === */
#viewerModal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.88);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 10000;
}
#viewerWrap {
  position: relative;
  width: min(1100px, 95vw);
  height: min(640px, 85vh);
  background: #000;
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: 0 8px 32px rgba(0,0,0,0.6);
}
#viewerContainer { width: 100%; height: 100%; background: #000; }
#closeBtn {
  position: absolute;
  top: 10px;
  right: 15px;
  font-size: 2rem;
  color: white;
  cursor: pointer;
  background: none;
  border: none;
  transition: transform var(--t) ease;
  z-index: 10;
}
#closeBtn:hover { transform: scale(1.15); }

/* === VISOR — ESTADOS DE CARGA Y ERROR === */
.viewer-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  min-height: 400px;
  gap: 1rem;
  color: rgba(255,255,255,0.8);
  font-family: var(--font-sans);
  font-size: 0.9rem;
}
.viewer-loading .spinner {
  border-color: rgba(255,255,255,0.15);
  border-top-color: var(--earth);
}
.viewer-error {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  min-height: 400px;
  color: var(--earth-lt);
  font-family: var(--font-sans);
  font-size: 0.95rem;
  text-align: center;
  padding: 2rem;
}

/* === POPUPS LEAFLET === */
.leaflet-popup-content-wrapper {
  background: var(--surface);
  color: var(--text);
  font-family: var(--font-sans);
  border-radius: var(--radius-sm) !important;
  box-shadow: var(--shadow-md);
  padding: 12px 14px;
  max-width: 280px;
}
.leaflet-popup-content-wrapper .popup-360 strong {
  display: block;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--forest);
  margin-bottom: 4px;
}
.leaflet-popup-content-wrapper .popup-360 p.description {
  font-size: 0.83rem;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.leaflet-popup-content-wrapper .popup-360 button.open-360 {
  background: var(--earth);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  font-size: 0.875rem;
  font-family: var(--font-sans);
  font-weight: 600;
  cursor: pointer;
  transition: background var(--t) ease, transform var(--t) ease;
}
.leaflet-popup-content-wrapper .popup-360 button.open-360:hover {
  background: var(--earth-dark);
  transform: translateY(-1px);
}

/* === FOOTER === */
.footer {
  background: var(--forest);
  border-top: 3px solid var(--earth);
  color: #fff;
  font-family: var(--font-sans);
  font-size: 0.82rem;
  padding: 0.75rem 1.25rem;
}
.footer-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}
.footer-brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
  color: #fff;
}
.logo-footer { height: 28px; width: auto; }
.footer-name {
  font-weight: 700;
  font-size: 0.9rem;
}
.footer-copy {
  margin: 0;
  color: rgba(255,255,255,0.72);
  text-align: center;
  flex: 1;
}
.footer-links {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.footer-links a {
  color: rgba(255,255,255,0.8);
  text-decoration: none;
  font-weight: 500;
  transition: color var(--t) ease;
}
.footer-links a:hover { color: var(--earth); }

/* === SPINNER (lista) === */
.loading-spinner {
  display: none;
  text-align: center;
  margin: 1rem 0;
  color: var(--text-muted);
  font-size: 0.9rem;
}
.loading-spinner .spinner {
  width: 32px;
  height: 32px;
  margin: 0 auto 0.5rem;
  border: 4px solid var(--border);
  border-top-color: var(--earth);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* === FOCO VISIBLE (accesibilidad) === */
:focus-visible {
  outline: 2px solid var(--earth);
  outline-offset: 3px;
  border-radius: 4px;
}

/* === RESPONSIVO === */
@media (max-width: 768px) {
  #sidebar { width: 100%; max-height: 40vh; }
  main { flex-direction: column; }
  .footer-inner { flex-direction: column; align-items: center; text-align: center; }
  .footer-copy { flex: none; }
  .footer-links { justify-content: center; }
}
