/* ============================================================
   LUMOS — App Layout (Sidebar + Header + Main)
   ============================================================ */

/* ---- APP SHELL ---- */
.app-shell {
  display: flex;
  min-height: 100vh;
  overflow: visible;
  background: var(--bg-secondary);
  transition: background var(--transition-slow);
}

/* ---- SIDEBAR ---- */
.sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: var(--bg-secondary);
  border-right: none;
  display: flex;
  flex-direction: column;
  position: fixed;
  left: 0; top: 0;
  z-index: 100;
  transition: transform var(--transition-slow), background var(--transition-slow),
              border-color var(--transition-slow), width var(--transition);
}

.sidebar-header {
  padding: 1.25rem 1.25rem 1rem;
  border-bottom: 1.5px solid var(--border);
  background: var(--bg-secondary);
  display: none;
}

.brand {
  display: flex;
  align-items: center;
  gap: .625rem;
}
.brand-icon {
  font-size: 1.95rem;
  background: var(--primary-soft);
  border: 1.5px solid var(--primary);
  border-radius: var(--radius-sm);
  width: 54px; height: 54px;
  display: flex; align-items: center; justify-content: center;
}
.brand-text {
  font-size: 1.95rem;
  font-weight: 800;
  letter-spacing: -.02em;
  color: var(--primary);
}

/* Nav */
.sidebar-nav {
  flex: 1;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow: visible;
  align-items: center;
  justify-content: center;
}

.nav-item {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .75rem;
  padding: .75rem;
  border-radius: var(--radius-sm);
  font-size: .9rem;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition);
  border: none;
  background: none;
  text-align: left;
  width: calc(100% - 12px);
  position: relative;
  text-decoration: none;
}
.nav-item:hover {
  background: var(--surface-2);
  color: var(--text-primary);
}
.nav-item.active {
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 600;
  box-shadow: inset 0 0 0 1px var(--border-subtle);
}
/* Indicador lateral da página ativa */
.nav-item::before {
  content: '';
  position: absolute;
  left: -6px; top: 50%;
  width: 3px; height: 0;
  border-radius: 0 3px 3px 0;
  background: var(--primary);
  transform: translateY(-50%);
  transition: height .25s var(--ease-out);
}
.nav-item.active::before { height: 22px; box-shadow: 0 0 10px var(--primary-glow); }
.nav-item.active .nav-icon svg { stroke: var(--primary); }
.nav-icon {
  width: 22px; height: 22px;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
.nav-icon svg { width: 22px; height: 22px; }
.nav-text { display: none; }

/* Sidebar tooltip (shows name on hover since nav is icon-only) */
.nav-item[data-tooltip] { position: relative; }
.nav-item[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  left: calc(100% + 10px);
  top: 50%;
  transform: translateY(-50%);
  background: var(--surface-2);
  border: 1.5px solid var(--border-light);
  color: var(--text-primary);
  padding: 5px 13px;
  border-radius: var(--radius-sm);
  font-size: .8rem;
  font-weight: 600;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transform: translate(-4px, -50%);
  transition: opacity .15s ease, transform .2s var(--ease-out);
  z-index: 200;
  box-shadow: var(--shadow-md);
}
.nav-item[data-tooltip]:hover::after { opacity: 1; transform: translate(0, -50%); }

/* Nav badge */
.nav-badge {
  background: var(--danger);
  color: #fff;
  font-size: .6rem;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 99px;
  min-width: 16px;
  text-align: center;
  position: absolute;
  top: 4px;
  right: 4px;
}

/* Sidebar footer */
.sidebar-footer {
  padding: .75rem 0;
  border-top: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: var(--bg-secondary);
  align-items: center;
}
.logout-btn:hover { background: var(--danger-soft); color: var(--danger); }

/* Sidebar overlay (mobile) */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.6);
  z-index: 99;
  backdrop-filter: blur(2px);
}
.sidebar-overlay.show { display: block; }

/* ---- MAIN AREA ---- */
.main-area {
  flex: 1;
  margin-left: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  overflow: visible;
  transition: margin-left var(--transition);
}

/* ---- HEADER ---- */
.app-header {
  height: var(--header-h);
  background: var(--bg-secondary);
  border-bottom: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.25rem;
  position: sticky;
  top: 0;
  z-index: 50;
  flex-shrink: 0;
  transition: background var(--transition-slow), border-color var(--transition-slow);
  gap: 1rem;
}

/* Brand centrado no header */
.header-center {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: .5rem;
  pointer-events: none;
}
.header-brand-icon {
  display: flex;
  align-items: center;
}
.header-brand-icon .brand-bulb {
  height: 42px;
  width: auto;
  overflow: visible;
}
.header-brand-name {
  font-size: 2rem;
  font-weight: 800;
  background: linear-gradient(135deg, #f5d56a 0%, #ffffff 65%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: 0.01em;
}

/* ---- BRAND BULB ANIMATION ---- */
.brand-bulb {
  animation: lms-bulb-glow 3s ease-in-out infinite;
  overflow: visible;
  flex-shrink: 0;
}
.brand-bulb .lms-aura {
  animation: lms-aura-pulse 3s ease-in-out infinite;
  transform-origin: 24px 22px;
}
.brand-bulb .lms-filament-halo {
  animation: lms-halo-pulse 3s ease-in-out infinite;
}
.brand-bulb .lms-filament {
  animation: lms-core-pulse 3s ease-in-out infinite;
}
@keyframes lms-bulb-glow {
  0%, 100% {
    filter: drop-shadow(0 0 3px rgba(255,193,7,0.38)) drop-shadow(0 0 7px rgba(255,140,0,0.18));
  }
  50% {
    filter: drop-shadow(0 0 7px rgba(255,215,0,0.85)) drop-shadow(0 0 16px rgba(255,160,0,0.52)) drop-shadow(0 0 28px rgba(255,100,0,0.22));
  }
}
@keyframes lms-aura-pulse {
  0%, 100% { opacity: 0.07; transform: scale(1); }
  50%       { opacity: 0.24; transform: scale(1.18); }
}
@keyframes lms-halo-pulse {
  0%, 100% { opacity: 0.38; }
  50%       { opacity: 0.75; }
}
@keyframes lms-core-pulse {
  0%, 100% { stroke: #fffde7; opacity: 0.88; }
  50%       { stroke: #ffffff; opacity: 1; }
}

.header-left {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.hamburger {
  display: none;
  width: 36px; height: 36px;
  align-items: center; justify-content: center;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1.5px solid var(--border);
  color: var(--text-secondary);
  cursor: pointer;
  flex-shrink: 0;
  transition: all var(--transition);
}
.hamburger:hover { color: var(--primary); border-color: var(--primary); }
.hamburger svg { width: 18px; height: 18px; }

.header-title {
  font-size: 1.125rem;
  font-weight: 700;
  line-height: 1.2;
}
.header-date {
  font-size: .75rem;
  color: var(--text-muted);
  line-height: 1;
}

.header-right {
  display: flex;
  align-items: center;
  gap: .5rem;
}

.header-btn {
  width: 38px; height: 38px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1.5px solid var(--border);
  color: var(--text-secondary);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
}
.header-btn:hover { background: var(--surface-hover); color: var(--primary); border-color: var(--primary); transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.header-btn svg { width: 18px; height: 18px; }

.notif-dot {
  position: absolute;
  top: 6px; right: 6px;
  width: 8px; height: 8px;
  background: var(--danger);
  border-radius: 50%;
  border: 2px solid var(--surface);
}

.notif-panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 340px;
  max-height: 420px;
  overflow-y: auto;
  background: var(--glass);
  backdrop-filter: blur(20px) saturate(140%);
  -webkit-backdrop-filter: blur(20px) saturate(140%);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl), var(--highlight);
  z-index: 200;
  animation: notif-appear .25s var(--ease-out);
  transform-origin: top right;
}
@keyframes notif-appear {
  from { opacity: 0; transform: translateY(-8px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.notif-panel-header {
  padding: 1rem 1.25rem .75rem;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.notif-panel-title { font-size: .9rem; font-weight: 700; color: var(--text-primary); }
.notif-empty { padding: 2rem 1.25rem; text-align: center; color: var(--text-muted); font-size: .875rem; }
.notif-item {
  padding: .875rem 1.25rem;
  border-bottom: 1px solid var(--border);
  display: flex; gap: .875rem; align-items: flex-start;
  cursor: pointer; transition: background var(--transition);
}
.notif-item:hover { background: var(--surface-hover); }
.notif-item:last-child { border-bottom: none; }
.notif-dot-icon { width: 10px; height: 10px; border-radius: 50%; margin-top: 4px; flex-shrink: 0; }
.notif-item-title { font-size: .875rem; font-weight: 600; color: var(--text-primary); }
.notif-item-sub { font-size: .78rem; color: var(--text-muted); margin-top: .15rem; }

.header-user {
  display: flex;
  align-items: center;
  gap: .625rem;
  padding: .375rem .75rem .375rem .375rem;
  background: var(--surface-2);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
}
.header-user:hover { border-color: var(--primary); transform: translateY(-1px); box-shadow: var(--shadow-sm); }

.user-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--primary);
  color: var(--text-inverse);
  display: flex; align-items: center; justify-content: center;
  font-size: .75rem;
  font-weight: 800;
  flex-shrink: 0;
  border: 1.5px solid var(--primary);
}

.user-name-text {
  font-size: .85rem;
  font-weight: 600;
  color: var(--text-primary);
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---- PAGE CONTENT ---- */
.page-content {
  flex: 1;
  padding: 1.75rem 2rem;
  overflow: visible;
  overflow-x: hidden;
  animation: pageIn .35s var(--ease-out);
  background: var(--bg-primary);
  border-top-left-radius: 22px;
}

/* ---- APP FOOTER ---- */
.app-footer {
  background: var(--bg-primary);
  padding: .625rem 2rem;
  text-align: center;
  font-size: .75rem;
  color: var(--text-muted);
  letter-spacing: .03em;
}
.app-footer strong {
  color: var(--text-secondary);
  font-weight: 600;
}

/* Chat ocupa a area inteira e sem scroll da pagina */
.app-shell.route-chat {
  height: 100vh;
  min-height: 100vh;
  overflow: hidden;
}

.app-shell.route-chat .main-area {
  height: 100vh;
  min-height: 0;
  overflow: hidden;
}

.app-shell.route-chat .page-content {
  padding: 0;
  overflow: hidden;
  border-top-left-radius: 0;
  background: var(--surface);
  display: flex;
  flex-direction: column;
}

.app-shell.route-chat .app-footer {
  display: none;
}

.app-shell.route-chat .chat-shell {
  flex: 1;
  width: 100%;
  height: 100%;
  min-height: 0;
  border-radius: 0;
  border-left: none;
  border-right: none;
  border-bottom: none;
}

.app-shell.route-chat .chat-content-area {
  min-height: 0;
}

.user-avatar.has-image {
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  color: transparent;
  box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.35) inset;
}
.page-content.page-enter { animation: pageIn .35s var(--ease-out); }
@keyframes pageIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ---- VIEW TRANSITIONS (troca de página e de tema) ---- */
.page-content { view-transition-name: page; }
.app-header  { view-transition-name: app-header; }
.sidebar     { view-transition-name: app-sidebar; }

/* Header e sidebar ficam parados; só o conteúdo anima */
::view-transition-old(root),
::view-transition-new(root),
::view-transition-group(app-header),
::view-transition-group(app-sidebar),
::view-transition-old(app-header),
::view-transition-new(app-header),
::view-transition-old(app-sidebar),
::view-transition-new(app-sidebar) { animation: none; mix-blend-mode: normal; }

::view-transition-group(page) { animation-duration: .32s; animation-timing-function: cubic-bezier(.22, 1, .36, 1); }
::view-transition-old(page) { animation: vtPageOut .16s ease-in both; }
::view-transition-new(page) { animation: vtPageIn .32s cubic-bezier(.22, 1, .36, 1) both; }
html[data-nav-dir="back"]::view-transition-old(page) { animation-name: vtPageOutBack; }
html[data-nav-dir="back"]::view-transition-new(page) { animation-name: vtPageInBack; }

@keyframes vtPageOut     { to   { opacity: 0; transform: translateY(-8px); filter: blur(2px); } }
@keyframes vtPageOutBack { to   { opacity: 0; transform: translateY(8px);  filter: blur(2px); } }
@keyframes vtPageIn      { from { opacity: 0; transform: translateY(12px); } }
@keyframes vtPageInBack  { from { opacity: 0; transform: translateY(-12px); } }

/* Troca de tema: a tela inteira é revelada num círculo (animado via JS) */
html.theme-transition .page-content,
html.theme-transition .app-header,
html.theme-transition .sidebar { view-transition-name: none; }
html.theme-transition *,
html.theme-transition *::before,
html.theme-transition *::after { transition: none !important; }
::view-transition-new(root) { z-index: 1; }

/* ---- RESPONSIVE ---- */
@media (max-width: 900px) {
  .sidebar {
    transform: translateX(calc(-1 * var(--sidebar-w)));
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: var(--shadow-lg);
  }
  .main-area { margin-left: 0; }
  .hamburger { display: flex; }
  .user-name-text { display: none; }
  .page-content { padding: 1.25rem 1rem; }
}