/* ==========================================================================
   global.css — Base, tipografia, estrutura de layout e utilitários
   Moreno Home Conciergeries
   ========================================================================== */

html {
  font-size: 16px;
}

body {
  font-family: var(--font-sans);
  font-size: var(--fs-base);
  line-height: var(--lh-base);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overscroll-behavior-y: none;
}

/* --------------------------------------------------------------------------
   Tipografia
   -------------------------------------------------------------------------- */

h1, h2, h3, h4 {
  line-height: var(--lh-tight);
  font-weight: 600;
  letter-spacing: -0.01em;
}

h1 { font-size: var(--fs-2xl); }
h2 { font-size: var(--fs-xl); }
h3 { font-size: var(--fs-md); }
h4 { font-size: var(--fs-base); }

p { color: var(--text-muted); }

small { font-size: var(--fs-sm); }

strong { font-weight: 600; }

.display {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: 0.01em;
}

.eyebrow {
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: var(--tracking-wider);
  text-transform: uppercase;
  color: var(--gold);
}

.section-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--sp-3);
  margin: var(--sp-8) 0 var(--sp-4);
}
.section-title:first-child { margin-top: 0; }
.section-title h2 { font-size: var(--fs-lg); }
.section-title .link {
  font-size: var(--fs-sm);
  color: var(--gold);
  font-weight: 600;
  white-space: nowrap;
}

.muted  { color: var(--text-muted); }
.faint  { color: var(--text-faint); }
.gold   { color: var(--gold); }
.center { text-align: center; }

/* --------------------------------------------------------------------------
   Marca
   -------------------------------------------------------------------------- */

.brand {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  min-width: 0;
}

.brand__mark {
  width: 34px;
  height: 34px;
  flex: none;
  color: var(--gold);
}

.brand__text {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

/* `display: block` é essencial: sem ele os dois spans ficam lado a lado
   e a marca deixa de encolher, empurrando a largura da barra superior. */
.brand__name {
  display: block;
  font-family: var(--font-display);
  font-size: var(--fs-md);
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: 0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.brand__sub {
  display: block;
  font-size: 0.5625rem;
  letter-spacing: var(--tracking-wider);
  text-transform: uppercase;
  color: var(--gold);
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.brand--on-dark .brand__name { color: var(--cream); }

/* --------------------------------------------------------------------------
   Estrutura de layout
   -------------------------------------------------------------------------- */

.layout {
  display: flex;
  min-height: 100vh;
  min-height: 100dvh;
}

.main {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.content {
  flex: 1 1 auto;
  width: 100%;
  max-width: var(--content-max);
  margin: 0 auto;
  padding: var(--sp-5) var(--sp-4)
           calc(var(--bottomnav-h) + var(--safe-bottom) + var(--sp-8));
}

.content--flush { padding-left: 0; padding-right: 0; }
.content--narrow { max-width: 720px; }

/* --------------------------------------------------------------------------
   Barra superior
   -------------------------------------------------------------------------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  min-height: calc(var(--topbar-h) + var(--safe-top));
  padding: var(--safe-top) var(--sp-4) 0;
  background: var(--black);
  color: var(--text-on-dark);
  border-bottom: 1px solid var(--border-dark);
}

.topbar__title {
  flex: 1 1 auto;
  min-width: 0;
  font-size: var(--fs-md);
  font-weight: 600;
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar__title--left { text-align: left; }

/* Só aparece a partir de 1024px, quando a marca passa para a barra lateral. */
.topbar__title--desktop { display: none; text-align: left; }

.topbar__actions {
  display: flex;
  align-items: center;
  gap: var(--sp-1);
}

.topbar .brand { flex: 1 1 auto; }

/* Botão redondo de barra (voltar, menu, notificações…) */
.icon-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  flex: none;
  border-radius: var(--r-full);
  color: inherit;
  transition: background var(--t-fast) var(--ease);
}
.icon-btn:hover { background: rgba(255, 255, 255, 0.08); }
.icon-btn:active { transform: scale(0.94); }
.icon-btn--light:hover { background: var(--gray-100); }

.icon-btn__badge {
  position: absolute;
  top: 4px;
  right: 4px;
  min-width: 17px;
  height: 17px;
  padding: 0 4px;
  border-radius: var(--r-full);
  background: var(--gold);
  color: var(--black);
  font-size: 10px;
  font-weight: 700;
  line-height: 17px;
  text-align: center;
}
.icon-btn__badge[hidden] { display: none; }

/* --------------------------------------------------------------------------
   Barra lateral (desktop)
   -------------------------------------------------------------------------- */

.sidebar {
  display: none;
  flex: none;
  width: var(--sidebar-w);
  background: var(--black);
  color: var(--text-on-dark);
  border-right: 1px solid var(--border-dark);
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100dvh;
  overflow-y: auto;
}

.sidebar__head {
  padding: var(--sp-6) var(--sp-5) var(--sp-5);
  border-bottom: 1px solid var(--border-dark);
}

.sidebar__nav {
  padding: var(--sp-4) var(--sp-3);
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1 1 auto;
}

.sidebar__foot {
  padding: var(--sp-3) var(--sp-3) var(--sp-6);
  border-top: 1px solid var(--border-dark);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-3);
  border-radius: var(--r-md);
  font-size: var(--fs-base);
  color: var(--text-on-dark-muted);
  transition: background var(--t-fast) var(--ease),
              color var(--t-fast) var(--ease);
  width: 100%;
  text-align: left;
}
.nav-item .icon { flex: none; }
.nav-item:hover { background: rgba(255, 255, 255, 0.06); color: var(--cream); }
.nav-item.is-active {
  background: var(--gold-dim);
  color: var(--cream);
  box-shadow: inset 2px 0 0 var(--gold);
}
.nav-item.is-active .icon { color: var(--gold); }
.nav-item__count {
  margin-left: auto;
  font-size: var(--fs-xs);
  font-weight: 700;
  color: var(--black);
  background: var(--gold);
  border-radius: var(--r-full);
  padding: 1px 7px;
}

/* --------------------------------------------------------------------------
   Navegação inferior (mobile)
   -------------------------------------------------------------------------- */

.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: var(--z-nav);
  display: flex;
  align-items: stretch;
  background: var(--black);
  border-top: 1px solid var(--border-dark);
  padding-bottom: var(--safe-bottom);
}

.bottom-nav__item {
  position: relative;
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-height: var(--bottomnav-h);
  padding: var(--sp-2) 2px;
  color: var(--text-on-dark-muted);
  font-size: 10px;
  letter-spacing: 0.02em;
  transition: color var(--t-fast) var(--ease);
}
.bottom-nav__item.is-active { color: var(--gold); }
.bottom-nav__item.is-active::before {
  content: "";
  position: absolute;
  top: 0;
  width: 26px;
  height: 2px;
  border-radius: 0 0 2px 2px;
  background: var(--gold);
}
.bottom-nav__item:active { transform: scale(0.96); }

.bottom-nav__dot {
  position: absolute;
  top: 8px;
  left: 50%;
  margin-left: 6px;
  width: 7px;
  height: 7px;
  border-radius: var(--r-full);
  background: var(--gold);
}

/* --------------------------------------------------------------------------
   Gaveta lateral (menu mobile)
   -------------------------------------------------------------------------- */

.drawer {
  position: fixed;
  inset: 0;
  z-index: var(--z-overlay);
  display: none;
}
.drawer.is-open { display: block; }

.drawer__scrim {
  position: absolute;
  inset: 0;
  background: rgba(10, 10, 10, 0.55);
  animation: fade-in var(--t-base) var(--ease);
}

.drawer__panel {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: min(84vw, var(--sidebar-w));
  background: var(--black);
  color: var(--text-on-dark);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  animation: slide-in-left var(--t-base) var(--ease);
}

/* --------------------------------------------------------------------------
   Utilitários
   -------------------------------------------------------------------------- */

.stack   { display: flex; flex-direction: column; gap: var(--sp-4); }
.stack-2 { display: flex; flex-direction: column; gap: var(--sp-2); }
.stack-3 { display: flex; flex-direction: column; gap: var(--sp-3); }
.row     { display: flex; align-items: center; gap: var(--sp-3); }
.row--between { justify-content: space-between; }
.row--wrap { flex-wrap: wrap; }
.grow    { flex: 1 1 auto; min-width: 0; }
.hidden  { display: none !important; }
.nowrap  { white-space: nowrap; }

.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.divider {
  height: 1px;
  background: var(--border);
  border: 0;
  margin: var(--sp-4) 0;
}

/* Escondido visualmente mas legível por leitores de ecrã */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* Link "saltar para o conteúdo" */
.skip-link {
  position: absolute;
  left: var(--sp-4);
  top: -60px;
  z-index: var(--z-toast);
  background: var(--gold);
  color: var(--black);
  padding: var(--sp-2) var(--sp-4);
  border-radius: var(--r-sm);
  font-weight: 600;
  transition: top var(--t-fast) var(--ease);
}
.skip-link:focus { top: var(--sp-3); }

/* --------------------------------------------------------------------------
   Animações
   -------------------------------------------------------------------------- */

@keyframes fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: none; }
}

@keyframes slide-in-left {
  from { transform: translateX(-100%); }
  to   { transform: none; }
}

@keyframes slide-up {
  from { transform: translateY(16px); opacity: 0; }
  to   { transform: none; opacity: 1; }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes shimmer {
  100% { transform: translateX(100%); }
}

@keyframes pop {
  0%   { transform: scale(0.7); opacity: 0; }
  60%  { transform: scale(1.06); opacity: 1; }
  100% { transform: scale(1); }
}

.animate-in { animation: rise var(--t-slow) var(--ease) both; }

/* --------------------------------------------------------------------------
   Ícones
   -------------------------------------------------------------------------- */

.icon {
  width: 20px;
  height: 20px;
  stroke-width: 1.6;
  flex: none;
}
.icon--sm { width: 16px; height: 16px; }
.icon--lg { width: 26px; height: 26px; }
.icon--xl { width: 34px; height: 34px; }

/* --------------------------------------------------------------------------
   Impressão (relatórios do back-office)
   -------------------------------------------------------------------------- */

@media print {
  .sidebar, .topbar, .bottom-nav, .no-print { display: none !important; }
  .content { padding: 0; max-width: none; }
  body { background: #fff; }
}
