/* ============================================================
   PRR — Layout
   Sidebar + Topbar + Content Grid
   ============================================================ */

/* ─── App Shell ───────────────────────────────────────────── */
#app {
  display: flex;
  min-height: 100vh;
  position: relative;
}

/* ─── Sidebar ─────────────────────────────────────────────── */
#sidebar {
  width: var(--sidebar-w);
  height: 100vh;
  position: fixed;
  top: 0; left: 0;
  background: var(--bg-surface);
  border-right: 1px solid var(--border-light);
  display: flex;
  flex-direction: column;
  z-index: 100;
  overflow: hidden;
}

/* Logo */
.sidebar-logo {
  padding: var(--space-6) var(--space-5);
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-shrink: 0;
}

.logo-mark {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, var(--accent) 0%, #1D4ED8 100%);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 800;
  color: #fff;
  letter-spacing: -0.5px;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(59,130,246,0.4);
}

.logo-text {
  display: flex;
  flex-direction: column;
}

.logo-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: 0.02em;
}

.logo-sub {
  font-size: 10px;
  font-weight: 500;
  color: var(--text-muted);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

/* Nav */
.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-4) 0;
}

.nav-section-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding: var(--space-3) var(--space-5) var(--space-2);
  margin-top: var(--space-2);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 10px var(--space-5);
  color: var(--text-secondary);
  font-size: var(--text-sm);
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
  border-left: 3px solid transparent;
  user-select: none;
}

.nav-item:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}

.nav-item.active {
  color: var(--accent);
  background: var(--accent-glow);
  border-left-color: var(--accent);
}

.nav-item svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  opacity: 0.8;
}

.nav-item.active svg { opacity: 1; }

.nav-badge {
  margin-left: auto;
  font-size: 10px;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-glow);
  padding: 2px 7px;
  border-radius: var(--radius-full);
}

/* XP Panel no Sidebar */
.sidebar-xp {
  padding: var(--space-4) var(--space-5);
  border-top: 1px solid var(--border-light);
  flex-shrink: 0;
}

.xp-level-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-2);
}

.xp-level-name {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-primary);
}

.xp-points {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--accent);
  font-family: var(--font-mono);
}

.xp-bar-track {
  width: 100%;
  height: 5px;
  background: var(--bg-elevated);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.xp-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #818CF8);
  border-radius: var(--radius-full);
  transition: width 800ms cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
}

.xp-bar-fill::after {
  content: '';
  position: absolute;
  top: 0; right: 0;
  width: 20px; height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3));
  animation: xpShine 2s ease-in-out infinite;
}

@keyframes xpShine {
  0%, 100% { opacity: 0; }
  50%       { opacity: 1; }
}

.xp-next {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: var(--space-1);
}

/* ─── Main Wrapper ────────────────────────────────────────── */
#main-wrapper {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ─── Topbar ──────────────────────────────────────────────── */
#topbar {
  height: var(--topbar-h);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-8);
  position: sticky;
  top: 0;
  z-index: 90;
  flex-shrink: 0;
}

.topbar-left {
  display: flex;
  flex-direction: column;
}

.topbar-title {
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1;
}

.topbar-breadcrumb {
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-top: 2px;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: var(--space-4);
}

.topbar-stat {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 6px var(--space-3);
}

.topbar-stat svg {
  width: 14px;
  height: 14px;
  opacity: 0.7;
}

.topbar-stat-val {
  font-size: var(--text-sm);
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--text-primary);
}

.topbar-stat-label {
  font-size: 10px;
  color: var(--text-muted);
}

.streak-stat .topbar-stat-val { color: var(--warning); }
.xp-stat .topbar-stat-val     { color: var(--accent); }

/* ─── Content Area ────────────────────────────────────────── */
#content {
  flex: 1;
  padding: var(--space-8);
  max-width: 1200px;
  width: 100%;
}

/* ─── Page Header ─────────────────────────────────────────── */
.page-header {
  margin-bottom: var(--space-8);
}

.page-header-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
}

.page-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent);
  background: var(--accent-glow);
  border: 1px solid var(--accent-line);
  padding: 4px 10px;
  border-radius: var(--radius-full);
  margin-bottom: var(--space-3);
}

.page-title {
  font-size: var(--text-2xl);
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1.2;
}

.page-title span {
  color: var(--accent);
}

.page-desc {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  margin-top: var(--space-2);
  max-width: 600px;
  line-height: 1.7;
}

/* ─── Section ─────────────────────────────────────────────── */
.section {
  margin-bottom: var(--space-8);
}

.section-title {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: var(--space-4);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.section-title::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border-light);
}

/* ─── Responsive ──────────────────────────────────────────── */
@media (max-width: 1024px) {
  :root { --sidebar-w: 220px; }
}

@media (max-width: 768px) {
  #sidebar {
    display: flex !important;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: 260px;
    height: 100vh;
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1001;
    box-shadow: 8px 0 24px rgba(0,0,0,0.5);
  }
  #sidebar.open {
    transform: translateX(0);
  }
  #btn-toggle-sidebar {
    display: flex !important;
  }
  #main-wrapper {
    margin-left: 0;
    padding-bottom: 0; /* Remove padding inferior do mobile */
    width: 100%;
    min-width: 0;
    overflow-x: hidden;
  }
  #app {
    width: 100%;
    max-width: 100vw;
    overflow-x: hidden;
  }
  .card {
    padding: var(--space-4) !important;
  }
  #content {
    padding: var(--space-4);
    overflow-x: hidden;
  }
  .grid-2, .grid-3, .grid-4 {
    grid-template-columns: 1fr;
    gap: var(--space-4);
  }
  #topbar {
    height: 52px;
    padding: 0 var(--space-3);
    gap: var(--space-2);
  }
  .topbar-breadcrumb {
    display: none;
  }
  .topbar-title {
    font-size: var(--text-sm);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 130px;
  }
  .topbar-stat {
    padding: 4px var(--space-2);
    gap: 4px;
  }
  .topbar-stat-val {
    font-size: 12px;
  }
  .topbar-stat-label {
    display: none;
  }
  .topbar-right {
    gap: var(--space-2);
  }
  
  /* Ajustar tipografia e descrições no mobile */
  .page-title {
    font-size: var(--text-lg) !important;
  }
  .page-desc {
    font-size: var(--text-xs) !important;
  }
  
  /* Ajustar chat no mobile para evitar overflow */
  .chat-bubble {
    max-width: 85% !important;
    padding: var(--space-2) var(--space-3) !important;
    font-size: 12px !important;
  }
  .chat-container {
    max-height: 300px !important;
    padding: var(--space-2) !important;
  }
  .chat-avatar {
    width: 28px !important;
    height: 28px !important;
    font-size: 10px !important;
  }
}
