/* ─── App Layout Grid ───────────────────────────────────────────────────────── */
.app-layout {
  display: block;
  min-height: 100vh;
}

/* ─── Sidebar ───────────────────────────────────────────────────────────────── */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: 240px;
  height: 100vh;
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 100;
  transition: width 0.25s ease;
}

.sidebar--collapsed {
  width: 60px;
}

.sidebar--collapsed .sidebar-label,
.sidebar--collapsed .sidebar-section-title,
.sidebar--collapsed .sidebar-logo-text {
  opacity: 0;
  pointer-events: none;
  width: 0;
  overflow: hidden;
  white-space: nowrap;
}

/* Sidebar Logo */
.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  height: 60px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  overflow: hidden;
}

.sidebar-logo-icon {
  width: 32px;
  height: 32px;
  background: var(--accent);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 16px;
  color: white;
  font-weight: 700;
  font-family: var(--font-primary);
}

.sidebar-logo-text {
  font-family: var(--font-primary);
  font-weight: 700;
  font-size: 16px;
  color: var(--text-primary);
  white-space: nowrap;
  transition: opacity 0.2s ease, width 0.25s ease;
}

/* Sidebar Nav */
.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 12px 8px;
}

.sidebar-section-title {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  padding: 8px 8px 4px;
  white-space: nowrap;
  transition: opacity 0.2s ease;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 8px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  transition: background 0.15s ease, color 0.15s ease;
  overflow: hidden;
  text-decoration: none;
}

.sidebar-nav a:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
}

.sidebar-nav a.active {
  background: rgba(88, 101, 242, 0.15);
  color: var(--accent);
}

.sidebar-nav a .nav-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
}

.sidebar-label {
  transition: opacity 0.2s ease;
  white-space: nowrap;
}

/* Sidebar Footer / Toggle */
.sidebar-footer {
  padding: 12px 8px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.sidebar-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 8px;
  background: none;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.sidebar-toggle:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
}

.sidebar-toggle svg {
  width: 18px;
  height: 18px;
  transition: transform 0.25s ease;
}

.sidebar--collapsed .sidebar-toggle svg {
  transform: rotate(180deg);
}

/* ─── Navbar ────────────────────────────────────────────────────────────────── */
.navbar {
  position: fixed;
  top: 0;
  left: 240px;
  right: 0;
  height: 60px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  z-index: 90;
  transition: left 0.25s ease;
}

.sidebar--collapsed ~ * .navbar,
.app-layout.sidebar-collapsed .navbar {
  left: 60px;
}

.navbar-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.navbar-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.hamburger-btn {
  display: none;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius-sm);
  transition: background 0.15s ease, color 0.15s ease;
}

.hamburger-btn:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
}

.hamburger-btn svg {
  width: 20px;
  height: 20px;
  display: block;
}

.navbar-title {
  font-family: var(--font-primary);
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
}

.navbar-user {
  display: flex;
  align-items: center;
  gap: 10px;
}

.navbar-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--border);
}

.navbar-username {
  font-weight: 500;
  color: var(--text-primary);
  font-size: 14px;
}

.navbar-coins {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(254, 231, 92, 0.1);
  border: 1px solid rgba(254, 231, 92, 0.2);
  border-radius: 20px;
  padding: 4px 12px;
  font-weight: 600;
  color: var(--warning);
  font-size: 13px;
}

.navbar-logout {
  color: var(--text-muted);
  font-size: 13px;
  transition: color 0.15s ease;
}

.navbar-logout:hover {
  color: var(--danger);
}

/* ─── Main Content ──────────────────────────────────────────────────────────── */
.main-content {
  margin-left: 240px;
  margin-top: 60px;
  padding: 24px;
  min-height: calc(100vh - 60px);
  transition: margin-left 0.25s ease;
  overflow-x: hidden;
  box-sizing: border-box;
}

.app-layout.sidebar-collapsed .main-content {
  margin-left: 60px;
}

/* ─── Auth Layout ───────────────────────────────────────────────────────────── */
.auth-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--bg-primary);
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 40px;
}

/* ─── Page Header ───────────────────────────────────────────────────────────── */
.page-header {
  margin-bottom: 24px;
}

.page-header h1 {
  font-size: 24px;
  font-weight: 700;
}

.page-header p {
  margin-top: 4px;
  font-size: 14px;
}

/* ─── Overlay (mobile sidebar) ──────────────────────────────────────────────── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 99;
}

/* ─── Responsive ────────────────────────────────────────────────────────────── */
@media (max-width: 1024px) {
  .sidebar { width: 200px; }
  .navbar  { left: 200px; }
  .main-content { margin-left: 200px; }
  .app-layout.sidebar-collapsed .navbar { left: 60px; }
  .app-layout.sidebar-collapsed .main-content { margin-left: 60px; }
}

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.25s ease, width 0.25s ease;
    width: 260px;
  }
  .sidebar.mobile-open { transform: translateX(0); width: 260px; }
  .sidebar--collapsed  { width: 260px; }
  .sidebar--collapsed .sidebar-label,
  .sidebar--collapsed .sidebar-section-title,
  .sidebar--collapsed .sidebar-logo-text {
    opacity: 1; pointer-events: auto; width: auto; overflow: visible;
  }

  .sidebar-overlay.active { display: block; }
  .navbar { left: 0 !important; }
  .main-content { margin-left: 0 !important; }
  .hamburger-btn { display: flex; }
  .sidebar-toggle { display: none; }
}

@media (max-width: 480px) {
  .main-content { padding: 14px; }
  .auth-card    { padding: 22px; }
  .navbar       { padding: 0 14px; }
  .navbar-username { display: none; }
  .navbar-title { font-size: 14px; }
  .page-header h1 { font-size: 20px; }
}

@media (max-width: 360px) {
  .main-content { padding: 10px; }
  .navbar-coins { display: none; }
}
