/* ==========================================================================
   BASE STYLES & LAYOUT STRUCTURE
   ========================================================================== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
  color-scheme: light;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-page);
  color: var(--text-main);
  line-height: 1.5;
  min-height: 100vh;
  overflow-x: hidden;
  position: relative;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  color-scheme: light;
  -webkit-tap-highlight-color: transparent;
  background-image:
    radial-gradient(circle at 10% 20%, rgba(212, 175, 55, 0.05) 0%, transparent 40%),
    radial-gradient(circle at 90% 80%, rgba(224, 122, 95, 0.05) 0%, transparent 40%);
  background-attachment: fixed;
}

/* Typography elements - Chuẩn hóa Sans-serif hiện đại, tỷ lệ scale sắc nét */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  font-weight: 600;
  color: var(--text-heading);
  letter-spacing: -0.015em;
  text-transform: none;
  font-variant: normal;
}

h1 { font-size: 21px; line-height: 1.3; font-weight: 700; }
h2 { font-size: 18px; line-height: 1.35; font-weight: 700; }
h3 { font-size: 16px; line-height: 1.4; font-weight: 600; }
h4 { font-size: 14px; line-height: 1.4; font-weight: 600; }

p { margin-bottom: 0.5rem; }

a {
  color: var(--rose-gold-dark);
  text-decoration: none;
  transition: color var(--transition-fast);
}
a:hover { color: var(--burgundy); }

/* Main App Shell Layout */
#app {
  display: flex;
  min-height: 100vh;
  width: 100%;
  max-width: 100vw;
  overflow-x: hidden;
}

/* Sidebar Navigation */
.sidebar {
  width: 280px;
  background: var(--bg-surface);
  border-right: 1px solid var(--border-light);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
  transition: transform var(--transition-normal);
}

.sidebar-header {
  padding: 1.75rem 1.5rem 1.25rem;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.brand-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--primary-gold), var(--rose-gold));
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 1.5rem;
  box-shadow: var(--shadow-gold);
}

.brand-info h2 {
  font-size: 1.15rem;
  font-weight: 700;
  font-family: var(--font-heading);
  letter-spacing: -0.01em;
  background: linear-gradient(135deg, var(--burgundy), var(--rose-gold-dark));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-info span {
  font-size: 0.72rem;
  text-transform: none;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  font-weight: 500;
}

.sidebar-nav {
  padding: 1.25rem 0.85rem;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  overflow-y: auto;
}

/* Sidebar Semantic Section Subheaders */
.nav-group-header {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #94A3B8;
  padding: 0.95rem 0.95rem 0.3rem;
  pointer-events: none;
  user-select: none;
}

.nav-group-header:first-of-type {
  padding-top: 0.15rem;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.7rem 0.95rem;
  border-radius: var(--radius-md);
  color: var(--text-muted);
  font-weight: 500;
  font-size: 13.5px;
  cursor: pointer;
  transition: all var(--transition-fast);
  border: 1px solid transparent;
}

.nav-item .icon {
  font-size: 1.25rem;
  width: 24px;
  text-align: center;
}

.nav-item:hover {
  background: var(--bg-surface-alt);
  color: var(--text-main);
  transform: translateX(4px);
}

.nav-item.active {
  background: linear-gradient(135deg, var(--rose-gold-light), var(--primary-gold-light));
  color: var(--burgundy);
  font-weight: 600;
  border-color: var(--border-light);
  box-shadow: var(--shadow-sm);
}

.nav-item.special-studio {
  margin-top: 0.5rem;
  background: linear-gradient(135deg, #FFF5F2, #FFFDF8);
  border: 1px dashed var(--rose-gold);
  color: var(--rose-gold-dark);
}
.nav-item.special-studio.active {
  background: linear-gradient(135deg, var(--rose-gold), var(--primary-gold));
  color: #fff;
  border: 1px solid transparent;
  box-shadow: var(--shadow-rose);
}

.sidebar-footer {
  padding: 1.25rem 1rem;
  border-top: 1px solid var(--border-subtle);
  background: var(--bg-surface-alt);
}

.user-snippet {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.user-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--rose-gold), var(--primary-gold));
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.95rem;
}

.user-details {
  flex: 1;
  min-width: 0;
}

.user-name {
  font-size: 0.88rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-days {
  font-size: 0.76rem;
  color: var(--rose-gold-dark);
  font-weight: 500;
}

/* Main Content Area */
.main-content {
  flex: 1 1 auto;
  margin-left: 280px;
  width: calc(100% - 280px);
  max-width: calc(100% - 280px);
  min-width: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

.top-navbar {
  height: 64px;
  background: var(--bg-glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.75rem;
  position: sticky;
  top: 0;
  z-index: 90;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

.page-title h1,
#page-main-title {
  font-size: 21px; /* 20px - 22px chuẩn SaaS */
  font-family: var(--font-heading);
  font-weight: 700;
  color: #1E293B; /* slate-800 */
  letter-spacing: -0.02em;
  line-height: 1.3;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

/* Top Navbar Icon Button (Help / Notifications) */
.top-icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--border-light);
  background: var(--bg-surface);
  color: var(--text-main);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  cursor: pointer;
  transition: all var(--transition-fast);
}
.top-icon-btn:hover {
  background: var(--bg-surface-alt);
  border-color: var(--primary-gold);
  transform: translateY(-1px);
}

/* Profile Avatar & Account Dropdown */
.user-menu-wrapper {
  position: relative;
  z-index: 100;
}

.user-profile-btn {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.32rem 0.75rem 0.32rem 0.38rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: all var(--transition-fast);
  color: var(--text-main);
  user-select: none;
}
.user-profile-btn:hover {
  border-color: var(--primary-gold);
  background: var(--bg-surface-alt);
  box-shadow: var(--shadow-sm);
}

.user-profile-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--rose-gold), var(--primary-gold));
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.8rem;
  pointer-events: none;
}

.user-profile-name {
  font-size: 13px;
  font-weight: 600;
  max-width: 140px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
}

.dropdown-chevron {
  font-size: 10px;
  color: var(--text-muted);
  transition: transform var(--transition-fast);
  pointer-events: none;
}
.user-menu-wrapper.active .dropdown-chevron {
  transform: rotate(180deg);
}

/* ==================== USER PROFILE DROPDOWN UNFOLD ANIMATION ==================== */
@keyframes userDropdownUnfold {
  0% {
    opacity: 0;
    transform: translateY(-20px) scaleY(0.82) scaleX(0.92);
    clip-path: inset(0 0 100% 0 round var(--radius-md));
  }
  70% {
    clip-path: inset(0 0 0 0 round var(--radius-md));
  }
  100% {
    opacity: 1;
    transform: translateY(0) scaleY(1) scaleX(1);
    clip-path: inset(0 0 0 0 round var(--radius-md));
  }
}

.user-dropdown-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 240px;
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 0.45rem;
  z-index: 9999 !important;
  display: none;
  flex-direction: column;
  transform-origin: top right;
  overflow: hidden;
  will-change: opacity, transform, clip-path;
}

.user-dropdown-menu.active {
  display: flex !important;
  opacity: 1 !important;
  visibility: visible !important;
  animation: userDropdownUnfold 1.2s cubic-bezier(0.16, 1, 0.3, 1) forwards !important;
}

.dropdown-header {
  padding: 0.6rem 0.75rem 0.4rem;
}

.dropdown-user-name {
  font-size: 13.5px;
  font-weight: 700;
  color: #1E293B;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dropdown-user-status {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 0.15rem;
}

.dropdown-divider {
  height: 1px;
  background: var(--border-subtle);
  margin: 0.35rem 0;
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.55rem 0.75rem;
  border-radius: var(--radius-sm);
  background: none;
  border: none;
  color: #1E293B;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  width: 100%;
  transition: all var(--transition-fast);
  font-family: var(--font-sans);
}
.dropdown-item:hover {
  background: var(--bg-surface-alt);
  color: var(--burgundy);
}
.dropdown-item-danger {
  color: var(--color-danger);
}
.dropdown-item-danger:hover {
  background: var(--color-danger-bg);
  color: var(--color-danger);
}

.content-container {
  padding: 2rem 2rem 7rem;
  flex: 1;
  max-width: 1400px;
  width: 100%;
  min-width: 0;
  margin: 0 auto;
  box-sizing: border-box;
}

/* Responsive navigation toggle */
.mobile-menu-btn {
  display: none;
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--text-main);
}

@media (max-width: 992px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .main-content {
    margin-left: 0;
    width: 100%;
    max-width: 100%;
  }
  .mobile-menu-btn {
    display: block;
  }
  .content-container {
    padding: 1.25rem 1rem 6.5rem;
  }
}
