/* mapa.css — Estilos para la Vista Mapa del Edificio */

.mapa-wrap {
  display: flex;
  flex-direction: column;
  height: calc(100vh - var(--header-h) - var(--nav-h));
}

.mapa-frente-badge {
  align-self: center;
  background: var(--primary-light);
  color: var(--primary);
  font-size: 0.75rem;
  font-weight: 700;
  padding: 6px 16px;
  border-radius: 20px;
  margin: 12px 0;
  box-shadow: var(--shadow);
}
[data-theme="dark"] .mapa-frente-badge {
  background: rgba(43, 108, 176, 0.2);
}

.mapa-container {
  flex: 1;
  overflow: auto;
  padding: 0 12px 12px;
  touch-action: pan-x pan-y;
  position: relative;
  -webkit-overflow-scrolling: touch;
}

.mapa-grid {
  display: inline-grid;
  gap: 2px;
  background: var(--surface);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  padding-bottom: 12px;
  padding-right: 12px;
}

.mapa-header-row {
  display: contents;
}

.mapa-cell-header-depto, .mapa-cell-header-shaft {
  position: sticky;
  background: var(--surface-alt);
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  border-bottom: 1px solid var(--border);
  border-right: 1px solid var(--border);
}

.mapa-cell-header-depto {
  top: 0;
  height: 30px;
  font-size: 0.8rem;
  z-index: 11;
}

.mapa-cell-header-shaft {
  top: 30px;
  height: 24px;
  font-size: 0.65rem;
  color: var(--text-secondary);
  border-bottom: 2px solid var(--border);
}

.mapa-cell-piso {
  position: sticky;
  left: 0;
  background: var(--surface-alt);
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 700;
  width: 50px;
  border-right: 2px solid var(--border);
  border-bottom: 1px solid var(--border);
}

/* Corner area spanning 2 rows / 1 col */
.mapa-corner {
  position: sticky;
  top: 0;
  left: 0;
  z-index: 15;
  background: var(--surface-alt);
  border-right: 2px solid var(--border);
  border-bottom: 2px solid var(--border);
}

.mapa-celda {
  width: 40px;
  height: 44px;
  background: #F5F5F5;
  border: 1px solid #E0E0E0;
  border-radius: 3px;
  position: relative;
  overflow: hidden;
  cursor: pointer;
}

[data-theme="dark"] .mapa-celda {
  background: #1a2332;
  border-color: #2D3748;
}

.mapa-celda-texto {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 0.55rem;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 0 2px rgba(0,0,0,0.8);
  pointer-events: none;
  z-index: 2;
}

.mapa-celda-relleno {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  background: #2E7D32;
  transition: height 0.4s ease, opacity 0.4s ease;
}

[data-theme="dark"] .mapa-celda-relleno {
  background: #48BB78;
}

.mapa-celda.no-aplica {
  background: repeating-linear-gradient(
    45deg,
    #E0E0E0,
    #E0E0E0 3px,
    #F5F5F5 3px,
    #F5F5F5 8px
  );
  cursor: default;
}

[data-theme="dark"] .mapa-celda.no-aplica {
  background: repeating-linear-gradient(
    45deg,
    #2D3748,
    #2D3748 3px,
    #1E2A3A 3px,
    #1E2A3A 8px
  );
}

.mapa-group-divider {
  margin-right: 8px; /* Used to create visual gap between departments */
}

/* Tooltip / Popup */
.mapa-popup-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
  backdrop-filter: blur(2px);
}
.mapa-popup-overlay.show {
  opacity: 1;
  pointer-events: auto;
}
.mapa-popup {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 20px;
  width: 90%;
  max-width: 320px;
  box-shadow: var(--shadow-lg);
  transform: translateY(20px);
  transition: transform 0.2s;
}
.mapa-popup-overlay.show .mapa-popup {
  transform: translateY(0);
}
.mapa-popup-header {
  font-weight: 700;
  font-size: 1.1rem;
  margin-bottom: 12px;
  text-align: center;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}
.mapa-popup-sub {
  font-size: 0.8rem;
  color: var(--text-secondary);
  display: block;
  font-weight: 500;
  margin-top: 4px;
}
.mapa-popup-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 10px;
  font-size: 0.85rem;
}
.mapa-popup-row-title {
  font-weight: 600;
  width: 60px;
  flex-shrink: 0;
}
.mapa-popup-items {
  flex: 1;
  color: var(--text-secondary);
}
.mapa-popup-divider {
  height: 1px;
  background: var(--border);
  margin: 14px 0;
}
.mapa-popup-vert {
  font-size: 0.85rem;
  display: flex;
  justify-content: space-between;
  margin-bottom: 6px;
}
.mapa-popup-vert span:last-child {
  font-weight: 600;
}

/* Leyenda */
.mapa-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 0.72rem;
  justify-content: center;
  padding: 12px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-secondary);
}
.legend-box {
  width: 14px;
  height: 14px;
  border-radius: 2px;
  border: 1px solid var(--border);
}
.legend-box.no-aplica {
  background: repeating-linear-gradient(45deg, #E0E0E0, #E0E0E0 2px, #F5F5F5 2px, #F5F5F5 4px);
}
[data-theme="dark"] .legend-box.no-aplica {
  background: repeating-linear-gradient(45deg, #4A5568, #4A5568 2px, #2D3748 2px, #2D3748 4px);
}
