/* Layout responsivo — shell, sidebar, bottom nav, animacoes */

/* Projeto Alicerce — dashboard foto widget +60% altura apenas em desktop */
@media (min-width: 1024px) {
  #dashScenes {
    height: 333px !important;
  }
}

/* ─── Dashboard: grid responsivo ──────────────────────────── */
.dash-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: 1fr 1fr; /* 2×2 em mobile/tablet */
}
/* Desktop largo (≥960px): 4 colunas lado a lado */
@media (min-width: 960px) {
  .dash-grid { grid-template-columns: repeat(4, 1fr); gap: 14px; }
}

.glow-bubble {
  position: fixed;
  border-radius: 50%;
  pointer-events: none;
  z-index: 0
}

.bubble-1 {
  top: -80px;
  right: -60px;
  width: 300px;
  height: 300px;
  background: #4f46e5;
  filter: blur(120px);
  opacity: 0.4;
  animation: floatB1 20s ease-in-out infinite
}

.bubble-2 {
  top: 40%;
  left: -80px;
  width: 250px;
  height: 250px;
  background: #7c3aed;
  filter: blur(100px);
  opacity: 0.3;
  animation: floatB2 20s ease-in-out infinite
}

.bubble-3 {
  bottom: -60px;
  left: 30%;
  width: 350px;
  height: 350px;
  background: #1d4ed8;
  filter: blur(140px);
  opacity: 0.25;
  animation: floatB3 20s ease-in-out infinite
}

@keyframes floatB1 {

  0%,
  100% {
    transform: translate(0, 0)
  }

  50% {
    transform: translate(-30px, 30px)
  }
}

@keyframes floatB2 {

  0%,
  100% {
    transform: translate(0, 0)
  }

  50% {
    transform: translate(30px, -20px)
  }
}

@keyframes floatB3 {

  0%,
  100% {
    transform: translate(0, 0)
  }

  50% {
    transform: translate(-20px, -30px)
  }
}

/* Toast */
.toast-container {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
  max-width: 400px;
  width: calc(100% - 32px)
}

.toast {
  padding: 0.875rem 1.125rem;
  border-radius: var(--radius-lg);
  font-size: var(--text-sm);
  font-weight: 600;
  backdrop-filter: blur(24px);
  box-shadow: var(--shadow);
  pointer-events: auto;
  animation: toastIn 0.3s ease forwards;
  display: flex;
  align-items: center;
  gap: 10px
}

.toast.out {
  animation: toastOut 0.3s ease forwards
}

.toast-success {
  background: rgba(34, 197, 94, 0.15);
  border: 1px solid rgba(34, 197, 94, 0.3);
  color: #4ade80
}

.toast-error {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #fca5a5
}

.toast-info {
  background: rgba(99, 102, 241, 0.15);
  border: 1px solid rgba(99, 102, 241, 0.3);
  color: #818cf8
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateY(-20px)
  }

  to {
    opacity: 1;
    transform: translateY(0)
  }
}

@keyframes toastOut {
  from {
    opacity: 1;
    transform: translateY(0)
  }

  to {
    opacity: 0;
    transform: translateY(-20px)
  }
}

/* Fade animations */
.fade-in {
  opacity: 0;
  transform: translateY(16px);
  animation: fadeUp 0.4s ease forwards
}

@keyframes fadeUp {
  to {
    opacity: 1;
    transform: translateY(0)
  }
}

.d1 {
  animation-delay: 0.1s
}

.d2 {
  animation-delay: 0.2s
}

.d3 {
  animation-delay: 0.3s
}

.d4 {
  animation-delay: 0.4s
}

.d5 {
  animation-delay: 0.5s
}

.d6 {
  animation-delay: 0.6s
}

/* Main area needs position context for absolute screens */
.main-area {
  position: relative;
  flex: 1;
  overflow: hidden
}

/* Screen system */
.screen {
  display: none !important;
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  overflow-y: auto;
  z-index: 1
}

.screen.active {
  display: flex !important;
  flex-direction: column;
  z-index: 10;
  background: var(--bg)
}

.screen-center {
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: var(--bg)
}

.screen-header {
  position: sticky;
  top: 0;
  z-index: 20;
  /* respeita o tema (antes era azul-escuro fixo que deixava o titulo ilegivel no tema claro) */
  background: color-mix(in srgb, var(--t-bg) 88%, transparent);
  backdrop-filter: blur(24px);
  border-bottom: 1px solid var(--t-border);
  padding: var(--sp-3) var(--sp-4);
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: var(--touch-min)
}

/* Titulo do cabecalho — contraste forte em qualquer tema */
.screen-header > div:first-child,
.screen-header h1,
.screen-header h2 {
  color: var(--t-text);
  font-weight: 800;
}

/* ===== Scrollbar global — fina, neutra, sem setas ===== */
* { scrollbar-width: thin; scrollbar-color: rgba(255,255,255,0.12) transparent; }
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.15); border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.28); }
::-webkit-scrollbar-button { display: none; width: 0; height: 0; }
::-webkit-scrollbar-corner { background: transparent; }

/* Sidebar nav: scrollbar invisível (oculta a barra azul vertical) */
#sideExpanded { scrollbar-width: none; }
#sideExpanded::-webkit-scrollbar { display: none; }

/* Sidebar logo: shrinkable — não extravasa o header em nenhum tema */
#sideLogoText { min-width: 0; overflow: hidden; text-overflow: ellipsis; flex: 1; }

.screen-body {
  flex: 1;
  overflow-y: auto;
  padding: var(--sp-4);
  padding-bottom: 6.25rem
}

/* Bottom nav (mobile) */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 20;
  background: rgba(7, 11, 26, 0.85);
  backdrop-filter: blur(24px);
  border-top: 1px solid var(--glass-border);
  padding: 8px 0 calc(8px + env(safe-area-inset-bottom, 0));
  display: flex;
  justify-content: center
}

.bnav-inner {
  max-width: 500px;
  width: 100%;
  display: flex;
  justify-content: space-around;
  align-items: center
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px 12px;
  cursor: pointer;
  border-radius: var(--radius-md);
  transition: var(--transition);
  min-width: 44px;
  min-height: 44px;
  justify-content: center
}

.nav-item.active {
  background: rgba(99, 102, 241, 0.15)
}

.nav-item .ni {
  font-size: var(--text-lg);
  line-height: 1
}

.nav-item .nl {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--text3)
}

.nav-item.active .nl {
  color: var(--primary-light)
}

/* Sidebar (desktop) */
.sidebar {
  display: none
}

/* Drawer overlay (mobile) */
.drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 50;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px)
}

.drawer-overlay.open {
  opacity: 1;
  pointer-events: auto
}

/* Drawer sidebar (mobile) */
.sidebar.drawer-open {
  position: fixed;
  top: 0;
  left: 0;
  height: 100dvh;
  z-index: 51;
  display: flex;
  flex-direction: column;
  width: 280px;
  transform: translateX(0);
  background: rgba(15, 20, 40, 0.98);
  box-shadow: 8px 0 32px rgba(0, 0, 0, 0.5);
  transition: transform 0.3s ease;
  overflow: hidden
}

.sidebar.drawer-closing {
  transform: translateX(-100%);
  transition: transform 0.3s ease
}

/* Responsive */
@media(min-width:768px) {
  .mobile-only {
    display: none !important
  }

  .app-shell {
    display: flex;
    height: 100dvh
  }

  .sidebar {
    display: flex;
    flex-direction: column;
    width: 248px;
    flex-shrink: 0;
    border-right: 1px solid var(--glass-border);
    overflow-y: auto;
    background: rgba(15, 20, 40, 0.95)
  }

  .main-area {
    flex: 1;
    overflow: hidden;
    position: relative
  }

  .screen-body {
    width: 100%;
    padding: var(--sp-6);
    max-width: 56.25rem;
    margin: 0 auto
  }

  .fab {
    bottom: 24px;
    right: 24px
  }

  .bottom-nav {
    display: none !important
  }

  .drawer-overlay {
    display: none !important
  }
}

@media(max-width:767px) {
  .desktop-only {
    display: none !important
  }

  .app-shell {
    display: flex;
    flex-direction: column;
    height: 100dvh
  }

  .main-area {
    flex: 1;
    position: relative;
    overflow: hidden
  }

  .bottom-nav {
    flex-shrink: 0
  }
}

/* Respeitar preferência de movimento reduzido (acessibilidade) */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .glow-bubble { display: none }
}

/* Utilitários de aspecto para evitar CLS em mídia */
.aspect-video { aspect-ratio: 16 / 9; overflow: hidden }
.aspect-square { aspect-ratio: 1 / 1; overflow: hidden }
.aspect-photo  { aspect-ratio: 4 / 3; overflow: hidden }
.aspect-video img,
.aspect-square img,
.aspect-photo img { width: 100%; height: 100%; object-fit: cover; display: block }

/* Lazy-load: reserva espaço antes de carregar */
img[loading="lazy"] { background: var(--glass-bg) }

/* Orientação portrait forçada via CSS para prevenir layout quebrado em landscape em mobile */
@media (max-width: 767px) and (orientation: landscape) {
  .screen-body { padding-bottom: 4rem }
}