/* =============================================
   AppLayout — Header + Navigation + User Menu
   ============================================= */

/* --- Global Reset for App Pages --- */
*, *::before, *::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 0;
  font-family: 'Segoe UI', 'Noto Sans Thai', system-ui, -apple-system, sans-serif;
}

/* --- Header --- */
.app-header {
  position: fixed;
  top: 0;
  right: 0;
  left: 0;
  z-index: 100;
  background: rgba(255, 253, 248, 0.97);
  border-bottom: 1px solid rgba(7, 91, 56, 0.14);
  box-shadow: 0 3px 12px rgba(66, 52, 26, 0.05);
  backdrop-filter: blur(10px);
}

.header-inner {
  max-width: 1440px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.25rem;
  height: 56px;
}

/* --- Logo --- */
.header-logo {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  text-decoration: none;
  flex-shrink: 0;
}

.header-logo-img {
  height: 36px;
  width: auto;
  display: block;
}

/* --- Navigation --- */
.header-nav {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.5rem 0.85rem;
  border-radius: 8px;
  text-decoration: none;
  color: #405046;
  font-size: 0.88rem;
  transition: background 0.12s ease, color 0.12s ease;
}

.nav-link:hover {
  background: #edf6e9;
  color: #075b38;
}

.nav-link-active {
  background: #d7ead0;
  color: #075b38;
  font-weight: 700;
}

.nav-link-admin {
  color: #8f6326;
}

.nav-link-admin:hover {
  background: #fff6e6;
  color: #76501d;
}

.nav-link-admin.nav-link-active {
  background: #f4e4c7;
  color: #76501d;
}

.nav-link-bugs {
  color: #8f3f32;
}

.nav-link-bugs:hover,
.nav-link-bugs.nav-link-active {
  background: #fff0ed;
  color: #7a2f24;
}

.nav-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.15rem;
  height: 1.15rem;
  margin-left: 0.28rem;
  padding: 0 0.24rem;
  border-radius: 999px;
  background: #b42318;
  color: #fff;
  font-size: 0.68rem;
  font-weight: 700;
  line-height: 1;
}

.nav-icon {
  font-size: 1rem;
  line-height: 1;
}

.nav-label {
  line-height: 1;
}

/* --- User Menu --- */
.header-user {
  position: relative;
  cursor: pointer;
  user-select: none;
  flex-shrink: 0;
}

.user-menu-toggle {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.65rem;
  border-radius: 8px;
  transition: background 0.12s ease;
}

.header-user:hover .user-menu-toggle {
  background: #edf6e9;
}

.user-avatar {
  font-size: 1.1rem;
  line-height: 1;
}

.user-name {
  font-size: 0.88rem;
  color: #223026;
  font-weight: 500;
}

.demo-session-badge {
  display: inline-flex;
  align-items: center;
  height: 1.15rem;
  padding: 0 0.35rem;
  border: 1px solid #e6c98f;
  border-radius: 999px;
  background: #fff6e6;
  color: #76501d;
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  line-height: 1;
}

/* --- Dropdown --- */
.user-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  min-width: 140px;
  background: #fffdf8;
  border: 1px solid rgba(7, 91, 56, 0.14);
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
  z-index: 110;
  overflow: hidden;
}

.user-menu-open .user-dropdown {
  display: block;
}

.dropdown-logout {
  display: block;
  width: 100%;
  padding: 0.65rem 1rem;
  border: none;
  background: none;
  font-size: 0.88rem;
  color: #c44;
  text-align: left;
  cursor: pointer;
  transition: background 0.1s ease;
}

.dropdown-logout:hover {
  background: #fef2f2;
}

/* --- App Content Area --- */
.app-content {
  min-height: calc(100vh - 56px);
  padding-top: 56px;
  background: #fff8ec;
}

/* --- Settings Placeholder Page --- */
.settings-placeholder {
  max-width: 600px;
  margin: 4rem auto;
  padding: 2rem;
  text-align: center;
  color: #8a7a6a;
}

.settings-placeholder h2 {
  font-size: 1.2rem;
  color: #4a3728;
  margin: 0 0 0.5rem;
}

.settings-placeholder p {
  font-size: 0.9rem;
  line-height: 1.5;
  margin: 0;
}

/* --- Responsive --- */
@media (max-width: 640px) {
  .nav-label {
    display: none;
  }
  .header-nav {
    gap: 0;
  }
  .nav-link {
    padding: 0.5rem 0.6rem;
  }
}
