/* ============================================================
   layout.css — Application shell: sidebar, topbar, main content
   ============================================================ */

.app-shell {
  display: flex;
  min-height: 100vh;
}

/* ============ 1. LEFT SIDEBAR ============ */
.sidebar {
  width: var(--sidebar-w);
  background: linear-gradient(180deg, var(--c-navy-900) 0%, var(--c-navy-950) 100%);
  color: #dce6f2;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  flex-shrink: 0;
  z-index: var(--z-sidebar);
  transition: width var(--t-med);
  overflow-x: hidden;
}

/* --- Brand row --- */
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-4) var(--sp-4) var(--sp-3);
  min-height: var(--header-h);
}

.brand-logo {
  width: 40px;
  height: 40px;
  border-radius: var(--r-md);
  object-fit: cover;
  flex-shrink: 0;
  background: #fff;
}

.brand-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.brand-name {
  font-size: var(--fs-16);
  font-weight: 700;
  color: #fff;
  letter-spacing: 0.01em;
  line-height: var(--lh-tight);
}

.brand-sub {
  font-size: var(--fs-11);
  color: #93a7c4;
  white-space: nowrap;
}

.collapse-btn {
  margin-left: auto;
  color: #93a7c4;
  padding: var(--sp-2);
  border-radius: var(--r-sm);
  display: inline-flex;
  transition: color var(--t-fast), background var(--t-fast), transform var(--t-med);
  flex-shrink: 0;
}

.collapse-btn:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
}

/* --- Program badge --- */
.side-badge {
  margin: 0 var(--sp-4) var(--sp-4);
  padding: var(--sp-3);
  border-radius: var(--r-md);
  background: rgba(21, 163, 102, 0.14);
  border: 1px solid rgba(21, 163, 102, 0.35);
}

.side-badge-title {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: var(--fs-11);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #7fd7ae;
}

.side-badge-days {
  font-size: var(--fs-12);
  color: #c8e9da;
  margin-top: var(--sp-1);
}

.side-badge .progress {
  margin-top: var(--sp-2);
  background: rgba(255, 255, 255, 0.15);
}

.side-badge .progress-fill {
  background: var(--c-green-600);
}

/* --- Navigation --- */
.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 0 var(--sp-3);
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.18) transparent;
}

.nav-section {
  font-size: var(--fs-11);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #6e84a4;
  padding: var(--sp-3) var(--sp-3) var(--sp-2);
}

.nav-list {
  list-style: none;
  padding: 0;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-3);
  margin-bottom: 2px;
  border-radius: var(--r-sm);
  color: #b9c8dd;
  font-size: var(--fs-14);
  font-weight: 500;
  position: relative;
  transition: background var(--t-fast), color var(--t-fast);
  min-height: 40px;
  text-decoration: none;
}

.nav-link:hover {
  background: rgba(255, 255, 255, 0.07);
  color: #fff;
  text-decoration: none;
}

.nav-link.active {
  background: rgba(22, 104, 220, 0.22);
  color: #fff;
  font-weight: 600;
}

.nav-link.active::before {
  content: "";
  position: absolute;
  left: -12px;
  top: 6px;
  bottom: 6px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--c-green-600);
}

.nav-link .icon {
  flex-shrink: 0;
}

/* --- Profile at bottom --- */
.sidebar-profile {
  padding: var(--sp-3);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.profile-card {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-2);
  border-radius: var(--r-md);
  width: 100%;
  text-align: left;
  transition: background var(--t-fast);
  color: inherit;
}

.profile-card:hover {
  background: rgba(255, 255, 255, 0.07);
}

.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--c-green-600);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: var(--fs-13);
  font-weight: 700;
  flex-shrink: 0;
  position: relative;
}

.avatar .status-dot {
  position: absolute;
  right: -1px;
  bottom: -1px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--c-green-600);
  border: 2px solid var(--c-navy-900);
}

.profile-meta {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.profile-name {
  font-size: var(--fs-13);
  font-weight: 600;
  color: #fff;
  line-height: var(--lh-tight);
}

.profile-role {
  font-size: var(--fs-11);
  color: #93a7c4;
}

/* --- Collapsed sidebar (desktop icon mode) --- */
body.sb-collapsed .sidebar {
  width: var(--sidebar-w-collapsed);
}

body.sb-collapsed .brand-text,
body.sb-collapsed .side-badge,
body.sb-collapsed .nav-section,
body.sb-collapsed .nav-label,
body.sb-collapsed .profile-meta {
  display: none;
}

body.sb-collapsed .nav-link,
body.sb-collapsed .profile-card {
  justify-content: center;
}

body.sb-collapsed .collapse-btn {
  margin-left: 0;
  transform: rotate(180deg);
}

body.sb-collapsed .sidebar-brand {
  flex-direction: column;
  gap: var(--sp-2);
  padding-bottom: var(--sp-4);
}

body.sb-collapsed .nav-link {
  padding: var(--sp-2);
}

.sidebar-overlay {
  display: none;
}

/* ============ 2. MAIN COLUMN ============ */
.main-col {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

/* --- Top header --- */
.topbar {
  height: var(--header-h);
  background: var(--c-surface);
  border-bottom: 1px solid var(--c-border);
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  padding: 0 var(--sp-6);
  position: sticky;
  top: 0;
  z-index: var(--z-header);
}

.menu-toggle {
  display: none;
  color: var(--c-text-2);
  padding: var(--sp-2);
  border-radius: var(--r-sm);
}

.menu-toggle:hover {
  background: var(--c-bg);
}

.topbar-title {
  min-width: 0;
}

.topbar-title h2 {
  font-size: var(--fs-16);
  font-weight: 700;
  color: var(--c-navy-900);
  line-height: var(--lh-tight);
  white-space: nowrap;
}

.topbar-title-meta {
  font-size: var(--fs-12);
  color: var(--c-text-3);
  white-space: nowrap;
}

.topbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}

.header-pill {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: var(--fs-12);
  color: var(--c-text-2);
  background: var(--c-bg);
  border: 1px solid var(--c-border);
  border-radius: var(--r-pill);
  padding: var(--sp-1) var(--sp-3);
  white-space: nowrap;
}

.header-pill .icon {
  color: var(--c-text-3);
}

/* Global search */
.header-search {
  position: relative;
  width: 320px;
}

.header-search .icon-search {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--c-text-3);
  pointer-events: none;
}

.header-search input {
  width: 100%;
  height: 36px;
  padding: 0 var(--sp-3) 0 34px;
  border: 1px solid var(--c-border);
  border-radius: var(--r-sm);
  background: var(--c-bg);
  font-size: var(--fs-13);
  transition: border-color var(--t-fast), background var(--t-fast), box-shadow var(--t-fast);
}

.header-search input::placeholder {
  color: var(--c-text-3);
}

.header-search input:focus {
  outline: none;
  background: var(--c-surface);
  border-color: var(--c-blue-600);
  box-shadow: var(--focus-ring);
}

.search-results {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  box-shadow: var(--sh-pop);
  overflow: hidden;
  z-index: var(--z-pop);
}

.search-result-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-3);
  text-align: left;
  transition: background var(--t-fast);
}

.search-result-item:hover {
  background: var(--c-blue-50);
}

.search-result-meta {
  min-width: 0;
  flex: 1;
}

.search-result-title {
  font-size: var(--fs-13);
  font-weight: 600;
  color: var(--c-text-1);
}

.search-result-sub {
  font-size: var(--fs-12);
  color: var(--c-text-3);
}

.search-empty {
  padding: var(--sp-4);
  font-size: var(--fs-13);
  color: var(--c-text-3);
  text-align: center;
}

/* Icon buttons in header */
.icon-btn {
  position: relative;
  width: 38px;
  height: 38px;
  border-radius: var(--r-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--c-text-2);
  transition: background var(--t-fast), color var(--t-fast);
}

.icon-btn:hover {
  background: var(--c-bg);
  color: var(--c-navy-900);
}

.icon-btn .badge-count {
  position: absolute;
  top: 3px;
  right: 3px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: var(--r-pill);
  background: var(--c-danger);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--c-surface);
}

.badge-count[hidden] {
  display: none;
}

.header-user {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-1) var(--sp-1) var(--sp-1) var(--sp-2);
  border-radius: var(--r-sm);
  transition: background var(--t-fast);
}

.header-user:hover {
  background: var(--c-bg);
}

.header-user-meta {
  text-align: right;
  line-height: var(--lh-tight);
}

.header-user-name {
  font-size: var(--fs-13);
  font-weight: 600;
  color: var(--c-text-1);
}

.header-user-role {
  font-size: var(--fs-11);
  color: var(--c-text-3);
}

.header-divider {
  width: 1px;
  height: 28px;
  background: var(--c-border);
}

/* ============ 3. MAIN CONTENT ============ */
.content {
  flex: 1;
  padding: var(--sp-6) var(--sp-8);
  width: 100%;
  max-width: var(--content-max);
  margin: 0 auto;
}

.breadcrumb {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: var(--fs-12);
  color: var(--c-text-3);
  margin-bottom: var(--sp-3);
}

.breadcrumb a {
  color: var(--c-text-3);
}

.breadcrumb a:hover {
  color: var(--c-blue-600);
}

.breadcrumb .sep {
  color: var(--c-border-md);
}

.breadcrumb [aria-current] {
  color: var(--c-text-1);
  font-weight: 600;
}

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--sp-4);
  margin-bottom: var(--sp-6);
}

.page-head h1 {
  font-size: var(--fs-24);
  font-weight: 700;
  color: var(--c-navy-900);
  letter-spacing: -0.01em;
  line-height: var(--lh-tight);
}

.page-desc {
  margin-top: var(--sp-1);
  color: var(--c-text-2);
  font-size: var(--fs-14);
  max-width: 780px;
}

.page-head-actions {
  display: flex;
  gap: var(--sp-2);
  flex-shrink: 0;
}

.page-body {
  display: flex;
  flex-direction: column;
  gap: var(--sp-5);
}
