/*
 * UI dos tours Aldana Empire (Apartamentos / Áreas de Lazer).
 * Marca — cores de destaque:
 *   --panel  : fundo do painel lateral (creme)
 *   --accent : acento (botões ativos, toggle, ícones, botão voltar)
 *   --text   : texto/bordas sobre o painel creme
 */

:root {
	--panel: #F2E7DD;
	--accent: #7a4a2e;
	--accent-hover: #8f5a38;
	--text: #3a2a1e;
}

*,
*::before,
*::after {
	box-sizing: border-box;
	margin: 0;
	padding: 0;
}

html,
body {
	height: 100%;
	overflow: hidden;
	font-family: 'Segoe UI', Arial, Helvetica, sans-serif;
	background: #000;
	color: #fff;
}

/* ── Viewer krpano ── */
#pano {
	position: absolute;
	inset: 0;
	z-index: 0;
}

/* ── UI overlay ── */
#ui {
	position: absolute;
	inset: 0;
	z-index: 10;
	pointer-events: none;
}

/* ── Logo dentro da Sidebar ── */
#logo {
	position: absolute;
	/* desce/sobe o logo da sidebar (aumente p/ descer mais) */
	top: 112px;
	left: 24px;
	right: 24px;
	width: calc(100% - 48px);
	height: auto;
	pointer-events: none;
	display: block;
}

/* ── Logo mobile (visível apenas em telas pequenas) ── */
#logo-mobile {
	display: none;
}

/* ── Botão voltar ao menu ── */
#btn-back {
	position: absolute;
	top: 40px;
	right: 40px;
	width: 58px;
	height: 58px;
	border-radius: 50%;
	background: var(--accent);
	border: 1px solid rgba(255, 255, 255, 0.18);
	display: flex;
	align-items: center;
	justify-content: center;
	pointer-events: auto;
	text-decoration: none;
	transition: background 0.15s, transform 0.15s;
	z-index: 30;
}

#btn-back:hover {
	background: var(--accent-hover);
	transform: scale(1.05);
}

#btn-back svg {
	width: 26px;
	height: 26px;
	fill: none;
	stroke: #fff;
	stroke-width: 2;
	stroke-linecap: round;
	stroke-linejoin: round;
}

/* ── Botão VR (oculto no desktop, visível só no mobile) ── */
#btn-vr {
	display: none;
	flex-shrink: 0;
	width: 44px;
	height: 44px;
	border-radius: 50%;
	background: var(--accent);
	border: 1px solid rgba(255, 255, 255, 0.18);
	padding: 0;
	cursor: pointer;
	align-items: center;
	justify-content: center;
	transition: background 0.15s, transform 0.15s;
}

#btn-vr:hover {
	background: var(--accent-hover);
	transform: scale(1.05);
}

#btn-vr svg {
	width: 24px;
	height: 24px;
	fill: none;
	stroke: #fff;
	stroke-width: 2;
	stroke-linecap: round;
	stroke-linejoin: round;
}

/* ── Painel lateral ── */
#sidebar {
	position: absolute;
	left: 0;
	top: 0;
	bottom: 0;
	display: flex;
	align-items: center;
	pointer-events: auto;
	transition: transform 0.3s ease-in;
	z-index: 20;
	overflow: visible;
}

#sidebar:not(.open) {
	transform: translateX(-232px);
}

#sidebar-panel {
	width: 232px;
	height: 100%;
	background: var(--panel);
	border-radius: 0 40px 40px 0;
	display: flex;
	flex-direction: column;
	justify-content: center;
	align-items: center;
	padding: 150px 18px 100px;
	gap: 0;
	position: relative;
	overflow: visible;
	box-shadow: 4px 0 24px rgba(58, 34, 18, 0.18);
}

/* ── Botão de toggle (sai pela borda direita do painel) ── */
#sidebar-toggle {
	position: absolute;
	right: -34px;
	top: 50%;
	transform: translateY(-50%);
	width: 34px;
	height: 60px;
	background: var(--accent);
	border: none;
	border-radius: 0 8px 8px 0;
	color: #fff;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	pointer-events: auto;
	transition: background 0.15s;
}

#sidebar-toggle:hover {
	background: var(--accent-hover);
}

#sidebar-toggle svg {
	width: 18px;
	height: 18px;
	fill: none;
	stroke: #fff;
	stroke-width: 2.5;
	stroke-linecap: round;
	stroke-linejoin: round;
	transition: transform 0.35s;
}

#sidebar:not(.open) #sidebar-toggle svg {
	transform: rotate(180deg);
}

/* ── Rótulo ── */
.sidebar-label {
	font-size: 13px;
	font-weight: 700;
	color: var(--text);
	letter-spacing: 0.1em;
	text-transform: uppercase;
	text-align: center;
	line-height: 22px;
	margin-bottom: 14px;
}

/* ── Grade de andares ──
   column-reverse deixa os andares mais altos no topo da lista. */
/* Desktop: grid de 3 colunas (as fileiras viram display:contents e o grid
   re-agrupa em 3), scaleY(-1) mantém os andares altos no topo. */
#floor-grid {
	display: grid;
	grid-template-columns: repeat(3, auto);   /* colunas do tamanho do botão, não 1/3 do painel */
	justify-content: center;                  /* centraliza o bloco de 3 colunas */
	justify-items: center;
	row-gap: 8px;        /* vertical */
	column-gap: 8px;     /* horizontal — só isto controla o espaço agora */
	width: 100%;
	overflow-y: auto;
	max-height: calc(100vh - 300px);
	padding-right: 2px;
	scrollbar-width: thin;
	scrollbar-color: rgba(122, 74, 46, 0.4) transparent;
	transform: scaleY(-1);
}

/* 27 (último botão) fica sozinho na fileira do topo, na coluna do MEIO */
#floor-grid .floor-row:last-child .floor-btn:last-child {
	grid-column: 2;
}

#floor-grid::-webkit-scrollbar {
	width: 4px;
}

#floor-grid::-webkit-scrollbar-thumb {
	background: rgba(122, 74, 46, 0.4);
	border-radius: 2px;
}

.floor-row {
	display: contents;
}

/* ── Botão de andar (círculo) ── */
.floor-btn {
	width: 45px;
	height: 45px;
	border-radius: 50%;
	background: transparent;
	border: 1.5px solid var(--accent);
	color: #74441E;
	transform: scaleY(-1);
	font-size: 15px;
	font-weight: 600;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: background 0.2s, border-color 0.2s, color 0.2s;
	flex-shrink: 0;
}

.floor-btn:hover {
	background: rgba(122, 74, 46, 0.12);
}

.floor-btn.active {
	background: var(--accent);
	border-color: var(--accent);
	color: #fff;
}

/* ── Footer da Sidebar (Ícones) ── */
#sidebar-footer {
	position: absolute;
	bottom: 40px;
	left: 20px;
	right: 20px;
	display: flex;
	justify-content: center;
	gap: 12px;
}

.icon-btn {
	flex-shrink: 0;
	width: 58px;
	height: 58px;
	border-radius: 50%;
	background: var(--accent);
	border: 1px solid rgba(255, 255, 255, 0.18);
	color: #fff;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: background 0.15s, transform 0.15s;
}

.icon-btn:hover {
	background: var(--accent-hover);
	transform: scale(1.05);
}

.icon-btn svg {
	width: 26px;
	height: 33px;
	fill: none;
	stroke: #fff;
	stroke-width: 2;
	stroke-linecap: round;
	stroke-linejoin: round;
}

/* Toggle de ícones no fullscreen */
.icon-btn .icon-exit {
	display: none;
}

.icon-btn.is-fullscreen .icon-enter {
	display: none;
}

.icon-btn.is-fullscreen .icon-exit {
	display: block;
}

/* ── HUD de configuração da câmera (hlookat / vlookat / fov) ── */
#view-hud {
	position: absolute;
	bottom: 20px;
	right: 20px;
	z-index: 40;
	width: 210px;
	background: rgba(0, 0, 0, 0.72);
	border: 1px solid rgba(255, 255, 255, 0.18);
	border-radius: 10px;
	padding: 10px 12px;
	pointer-events: auto;
	font-family: 'Consolas', 'Courier New', monospace;
	backdrop-filter: blur(4px);
	user-select: none;
}

#view-hud.hidden {
	display: none;
}

#view-hud .hud-title {
	display: flex;
	align-items: center;
	justify-content: space-between;
	font-size: 11px;
	font-weight: 700;
	letter-spacing: 0.12em;
	text-transform: uppercase;
	color: rgba(255, 255, 255, 0.7);
	margin-bottom: 8px;
}

#hud-close {
	width: 18px;
	height: 18px;
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.12);
	border: none;
	color: #fff;
	font-size: 11px;
	line-height: 1;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
}

#hud-close:hover {
	background: rgba(255, 255, 255, 0.25);
}

#view-hud .hud-row {
	display: flex;
	align-items: center;
	justify-content: space-between;
	font-size: 13px;
	line-height: 1.7;
	color: #fff;
	gap: 8px;
}

#view-hud .hud-row span {
	color: rgba(255, 255, 255, 0.6);
}

#view-hud .hud-row b {
	font-weight: 700;
	color: #e0a878;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

#hud-copy {
	width: 100%;
	margin-top: 10px;
	padding: 6px 8px;
	background: var(--accent);
	border: 1px solid rgba(255, 255, 255, 0.2);
	border-radius: 6px;
	color: #fff;
	font-size: 11px;
	font-weight: 600;
	letter-spacing: 0.04em;
	cursor: pointer;
	transition: background 0.15s;
}

#hud-copy:hover {
	background: var(--accent-hover);
}

/* No mobile o HUD fica menor e não atrapalha o toque */
@media (max-width: 600px) {
	#view-hud {
		bottom: 12px;
		right: 12px;
		width: 160px;
		padding: 8px 10px;
	}
}

/* ── Modal Google Maps ── */
#maps-modal {
	position: fixed;
	inset: 0;
	z-index: 100;
	background: rgba(0, 0, 0, 0.72);
	display: none;
	align-items: center;
	justify-content: center;
	pointer-events: auto;
}

#maps-modal.open {
	display: flex;
}

#maps-modal-box {
	position: relative;
	width: min(720px, 92vw);
	height: min(500px, 75vh);
	border-radius: 10px;
	overflow: hidden;
	box-shadow: 0 24px 64px rgba(0, 0, 0, 0.7);
}

#maps-iframe {
	width: 100%;
	height: 100%;
	border: none;
	display: block;
}

#maps-close {
	position: absolute;
	top: 10px;
	right: 10px;
	width: 32px;
	height: 32px;
	border-radius: 50%;
	background: rgba(0, 0, 0, 0.65);
	border: 1px solid rgba(255, 255, 255, 0.25);
	color: #fff;
	font-size: 16px;
	line-height: 1;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: background 0.15s;
	z-index: 1;
}

#maps-close:hover {
	background: rgba(0, 0, 0, 0.9);
}

/* ────────────────────────────────
   Responsivo — Tablet (≤ 900px)
──────────────────────────────── */
@media (max-width: 900px) {
	#btn-back {
		right: 20px;
	}

	#sidebar-panel {
		width: 200px;
		padding: 120px 14px 60px;
	}

	#sidebar:not(.open) {
		transform: translateX(-200px);
	}

	#logo {
		top: 36px;
		left: 18px;
		right: 18px;
		width: calc(100% - 36px);
	}

	#sidebar-footer {
		bottom: 30px;
		left: 15px;
		right: 15px;
	}

	#floor-grid {
		max-height: calc(100vh - 240px);
	}
}

/* ────────────────────────────────
   Responsivo — Altura curta (≤ 800px, desktop largo)
──────────────────────────────── */
@media (max-height: 800px) and (min-width: 901px) {
	#logo {
		top: 40px;
		width: calc(100% - 60px);
		left: 30px;
		right: 30px;
	}

	#sidebar-panel {
		padding: 120px 18px 55px;
	}

	#sidebar-footer {
		bottom: 16px;
	}

	.icon-btn {
		width: 42px;
		height: 42px;
	}

	.icon-btn svg {
		width: 22px;
		height: 22px;
	}

	.sidebar-label {
		font-size: 12px;
		line-height: 1.4;
		margin-bottom: 8px;
	}

	#floor-grid {
		max-height: calc(100vh - 210px);
		gap: 6px;
	}

	.floor-row {
		gap: 6px;
	}

	.floor-btn {
		width: 36px;
		height: 36px;
		font-size: 13px;
	}
}

/* ────────────────────────────────
   Responsivo — Mobile (≤ 600px)
 ──────────────────────────────── */
@media (max-width: 600px) {
	/* Logo desktop oculto; logo mobile aparece fixo no topo */
	#logo {
		display: none;
	}

	#logo-mobile {
		display: block;
		position: fixed;
		top: 0;
		left: 0;
		transform: none;
		width: auto;
		max-width: 150px;
		pointer-events: none;
		z-index: 30;
	}

	/* Botão voltar: menor no mobile */
	#btn-back {
		right: 12px;
		top: 12px;
		width: 44px;
		height: 44px;
	}

	#btn-back svg {
		width: 20px;
		height: 20px;
	}

	/* Botão VR sempre visível no mobile — usa o "fake VR"/cardboard do krpano
	   (o showVRButton do JS só o mostra quando há WebXR immersive-vr, que os
	   celulares comuns não têm; por isso forçamos a exibição aqui). */
	#btn-vr {
		display: flex;
	}

	/* Sidebar vira drawer que sobe do fundo */
	#sidebar {
		top: auto;
		left: 0;
		right: 0;
		bottom: 0;
		flex-direction: column;
		align-items: stretch;
		overflow: visible;
		transition: transform 0.3s ease-in;
	}

	/* Fechado: painel some; sobram o toggle e os ícones acima dele */
	#sidebar:not(.open) {
		transform: none;
	}

	#sidebar:not(.open) #sidebar-panel {
		display: none;
	}

	/* Aberto: os ícones somem (só o conteúdo do painel aparece) */
	#sidebar.open #sidebar-footer {
		display: none;
	}

	/* Toggle: tab retangular centralizada acima do painel */
	#sidebar-toggle {
		order: 0;
		position: relative;
		top: auto;
		right: auto;
		align-self: center;
		width: 60px;
		height: 34px;
		border-radius: 8px 8px 0 0;
		transform: none;
		margin-bottom: 0;
	}

	/* Seta aponta para cima quando aberto */
	#sidebar-toggle svg {
		transform: rotate(-90deg);
	}

	/* Seta aponta para baixo quando fechado */
	#sidebar:not(.open) #sidebar-toggle svg {
		transform: rotate(90deg);
	}

	/* Painel ocupa largura total, altura automática */
	#sidebar-panel {
		order: 1;
		width: 100%;
		height: auto;
		/* altura da barra: ~3 fileiras de botões e rola o resto.
		   Fixo em px porque max-height em vh só corta quando o conteúdo é maior
		   que o limite — e as fileiras cabiam em 34vh, por isso não mudava.
		   Aumente/diminua p/ mostrar mais/menos fileiras (~46px por fileira). */
		max-height: 195px;
		overflow-y: auto;
		border-radius: 20px 20px 0 0;
		padding: 16px 18px 17px;   /* 17px de margem abaixo dos botões */
		justify-content: flex-start;
		align-items: stretch;
		gap: 12px;
	}

	/* Ícones flutuam acima do toggle (visíveis só com o menu fechado) */
	#sidebar-footer {
		order: -1;
		position: relative;
		bottom: auto;
		left: auto;
		right: auto;
		justify-content: center;
		gap: 16px;
		margin: 0 0 14px;
	}

	/* "Selecione o andar" oculto no mobile */
	.sidebar-label {
		display: none;
	}

	/* Grade de andares no mobile — fileiras reais (5/7/7/6) centralizadas,
	   empilhadas com column-reverse: 23–27 no topo, 3–8 embaixo. */
	#floor-grid {
		display: flex;
		flex-direction: column-reverse;
		gap: 8px;
		max-height: none;
		overflow-y: visible;
		transform: none;
		padding: 4px 18px 0;   /* margem nas laterais; a inferior vem do painel (17px) */
	}

	.floor-row {
		display: flex;
		justify-content: center;
		gap: 8px;
	}

	.floor-btn {
		width: 34px;         /* botões menores */
		height: 34px;
		aspect-ratio: auto;
		font-size: 12px;
		border-width: 1px;
		transform: none;
		flex: 0 0 auto;
	}

	.icon-btn {
		width: 44px;
		height: 44px;
	}

	.icon-btn svg {
		width: 20px;
		height: 20px;
	}
}
