/**
 * Client layout: light sidebar + main shell (friendly, accessible).
 */
:root {
  --client-sb-width: 270px;
  --client-sb-width-narrow: 78px;
  --client-sb-bg: #ffffff;
  --client-sb-text: #475569;
  --client-sb-text-muted: #64748b;
  --client-sb-text-active: #0f172a;
  --client-sb-accent: #0ea5e9;
  --client-sb-accent-soft: #e0f2fe;
  --client-sb-border: #e2e8f0;
  --client-sb-shadow: 2px 0 20px rgba(15, 23, 42, 0.06);
  --client-sb-radius: 12px;
}

.client-app {
  display: flex;
  min-height: 100vh;
  position: relative;
}

.client-sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.25);
  backdrop-filter: blur(3px);
  z-index: 1090;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease;
}

.client-sidebar-overlay.is-visible {
  opacity: 1;
  pointer-events: auto;
}

.client-sidebar {
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  width: var(--client-sb-width);
  background: var(--client-sb-bg);
  border-right: 1px solid var(--client-sb-border);
  z-index: 1100;
  display: flex;
  flex-direction: column;
  transition: width 0.25s cubic-bezier(0.4, 0, 0.2, 1), transform 0.25s ease;
  box-shadow: var(--client-sb-shadow);
}

body.client-sb-narrow .client-sidebar {
  width: var(--client-sb-width-narrow);
}

body.client-sb-resizing .client-sidebar {
  transition: none;
}

.client-sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 1rem 0.9rem;
  border-bottom: 1px solid var(--client-sb-border);
  min-height: 64px;
  background: linear-gradient(180deg, #fafbfc 0%, #ffffff 100%);
}

/* Thu gọn: xếp dọc gọn để nút mở rộng luôn thấy được */
body.client-sb-narrow .client-sidebar-head {
  flex-direction: column;
  justify-content: center;
  padding: 0.75rem 0.45rem;
  gap: 0.65rem;
}

.client-sidebar-logo {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  text-decoration: none;
  color: var(--client-sb-text-active);
  font-weight: 800;
  font-size: 1.02rem;
  letter-spacing: -0.02em;
  white-space: nowrap;
  overflow: hidden;
  border-radius: 10px;
  padding: 4px 2px;
  transition: background 0.2s, color 0.2s;
}

.client-sidebar-logo:hover {
  color: var(--client-sb-accent);
  background: var(--client-sb-accent-soft);
}

.client-sidebar-logo:focus-visible {
  outline: 2px solid var(--client-sb-accent);
  outline-offset: 2px;
}

.client-sidebar-logo i {
  color: var(--client-sb-accent);
  font-size: 1.3rem;
  flex-shrink: 0;
}

body.client-sb-narrow .client-sidebar-logo span {
  display: none;
}

body.client-sb-narrow .client-sidebar-logo {
  justify-content: center;
  padding: 6px;
}

.client-sidebar-tools {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  flex-shrink: 0;
}

body.client-sb-narrow .client-sidebar-tools {
  width: 100%;
  justify-content: center;
}

.client-sidebar-collapse {
  width: 40px;
  height: 40px;
  border: 1px solid var(--client-sb-border);
  border-radius: var(--client-sb-radius);
  background: #f8fafc;
  color: var(--client-sb-accent);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, border-color 0.2s, color 0.2s, transform 0.2s;
}

.client-sidebar-collapse:hover {
  background: var(--client-sb-accent-soft);
  border-color: #bae6fd;
  color: #0284c7;
}

.client-sidebar-collapse:focus-visible {
  outline: 2px solid var(--client-sb-accent);
  outline-offset: 2px;
}

/* Thu gọn: icon quay → gợi ý “mở rộng” (mũi tên phải) */
body.client-sb-narrow .client-sidebar-collapse i {
  transform: rotate(180deg);
}

body.client-sb-narrow .client-sidebar-collapse {
  width: 100%;
  max-width: 48px;
}

.client-sidebar-close-mobile {
  display: none;
  width: 40px;
  height: 40px;
  border: 1px solid var(--client-sb-border);
  border-radius: var(--client-sb-radius);
  background: #f8fafc;
  color: var(--client-sb-text-active);
  cursor: pointer;
  font-size: 1.35rem;
  line-height: 1;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.client-sidebar-close-mobile:hover {
  background: var(--client-sb-accent-soft);
}

.client-sidebar-nav {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0.65rem 0.55rem;
  -webkit-overflow-scrolling: touch;
}

.client-sidebar-nav ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.client-sidebar-nav li {
  margin-bottom: 3px;
}

.client-sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0.68rem 0.85rem;
  border-radius: var(--client-sb-radius);
  color: var(--client-sb-text);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.9rem;
  transition: background 0.18s, color 0.18s;
}

.client-sidebar-nav a i {
  width: 22px;
  text-align: center;
  font-size: 1.05rem;
  color: var(--client-sb-accent);
  flex-shrink: 0;
  opacity: 0.95;
}

.client-sidebar-nav a:hover {
  background: #f1f5f9;
  color: var(--client-sb-text-active);
}

.client-sidebar-nav a:focus-visible {
  outline: 2px solid var(--client-sb-accent);
  outline-offset: 1px;
}

.client-sidebar-nav a.active {
  background: linear-gradient(90deg, var(--client-sb-accent-soft), #f0f9ff);
  color: #0369a1;
  box-shadow: inset 3px 0 0 var(--client-sb-accent);
  font-weight: 700;
}

.client-sidebar-nav a.active i {
  color: #0284c7;
}

body.client-sb-narrow .client-sidebar-label {
  display: none;
}

body.client-sb-narrow .client-sidebar-nav a {
  justify-content: center;
  padding: 0.72rem 0.5rem;
}

.client-sidebar-foot {
  padding: 0.75rem;
  border-top: 1px solid var(--client-sb-border);
  background: #fafbfc;
}

.client-sidebar-usercard {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: #ffffff;
  border: 1px solid var(--client-sb-border);
  border-radius: var(--client-sb-radius);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.client-sidebar-usercard img {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--client-sb-accent-soft);
  flex-shrink: 0;
}

.client-sidebar-usercard-meta {
  min-width: 0;
  flex: 1;
}

.client-sidebar-usercard-meta .sn {
  display: block;
  font-weight: 700;
  font-size: 0.84rem;
  color: var(--client-sb-text-active);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.client-sidebar-usercard-meta .sb {
  font-size: 0.74rem;
  color: var(--client-sb-accent);
  font-weight: 700;
}

body.client-sb-narrow .client-sidebar-usercard-meta {
  display: none;
}

body.client-sb-narrow .client-sidebar-usercard {
  justify-content: center;
  padding: 8px;
  border: none;
  box-shadow: none;
  background: transparent;
}

/* Nút mở rộng trên topbar (desktop, khi sidebar thu gọn) — luôn có 2 cách mở lại */
.client-topbar-sb-expand {
  display: none;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  margin-right: 4px;
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 10px;
  background: var(--bg-soft, #f8fafc);
  color: var(--primary, #0ea5e9);
  cursor: pointer;
  font-size: 1rem;
  transition: background 0.2s, border-color 0.2s;
}

.client-topbar-sb-expand:hover {
  background: #e0f2fe;
  border-color: #7dd3fc;
}

.client-topbar-sb-expand:focus-visible {
  outline: 2px solid var(--primary, #0ea5e9);
  outline-offset: 2px;
}

@media (min-width: 993px) {
  body.client-sb-narrow .client-topbar-sb-expand {
    display: inline-flex;
  }
}

/* Main column */
.client-shell {
  flex: 1;
  min-width: 0;
  margin-left: var(--client-sb-width);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: margin-left 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  background: var(--bg-main, #ffffff);
}

body.client-sb-narrow .client-shell {
  margin-left: var(--client-sb-width-narrow);
}

.client-topbar {
  flex-shrink: 0;
  border-bottom: 1px solid var(--border, #e2e8f0);
  background: rgba(255, 255, 255, 0.97);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 800;
  box-shadow: 0 1px 0 rgba(15, 23, 42, 0.04);
}

.client-topbar-inner {
  max-width: 1440px;
  margin: 0 auto;
  padding: 0.65rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.client-topbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.client-topbar-menu-btn {
  display: none;
  width: 44px;
  height: 44px;
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 10px;
  background: var(--bg-soft, #f8fafc);
  color: var(--primary, #0ea5e9);
  cursor: pointer;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
  transition: background 0.2s, border-color 0.2s;
}

.client-topbar-menu-btn:hover {
  border-color: var(--primary, #0ea5e9);
  background: #ffffff;
}

.client-topbar-menu-btn:focus-visible {
  outline: 2px solid var(--primary, #0ea5e9);
  outline-offset: 2px;
}

.client-topbar-mark {
  font-weight: 800;
  font-size: 1.02rem;
  color: var(--primary-dark, #0284c7);
  letter-spacing: -0.02em;
}

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

.client-shell > main {
  flex: 1;
  width: 100%;
  max-width: 1440px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 2.5rem;
  box-sizing: border-box;
}

.client-shell > .notification-area {
  flex-shrink: 0;
}

.client-shell > .notification-area .header-container {
  max-width: 1440px;
  margin: 0 auto;
  padding: 0 1.25rem;
}

.client-shell > footer {
  margin-top: auto;
}

@media (max-width: 992px) {
  .client-sidebar {
    transform: translateX(-102%);
    width: min(300px, 90vw);
    box-shadow: 8px 0 32px rgba(15, 23, 42, 0.12);
  }

  body.client-sb-narrow .client-sidebar {
    width: min(300px, 90vw);
  }

  .client-sidebar.is-open {
    transform: translateX(0);
  }

  body.client-sb-narrow .client-shell {
    margin-left: 0;
  }

  .client-shell {
    margin-left: 0;
  }

  .client-topbar-menu-btn {
    display: inline-flex;
  }

  /* Mobile: ẩn nút thu gọn desktop, chỉ đóng bằng X / overlay */
  .client-sidebar-collapse {
    display: none !important;
  }

  body.client-sb-narrow .client-sidebar-head {
    flex-direction: row;
    padding: 1rem 0.9rem;
  }

  body.client-sb-narrow .client-sidebar-tools {
    width: auto;
    justify-content: flex-end;
  }

  .client-sidebar-close-mobile {
    display: inline-flex;
  }

  body.client-sb-narrow .client-sidebar-logo span {
    display: inline;
  }

  body.client-sb-narrow .client-sidebar-label {
    display: inline;
  }

  body.client-sb-narrow .client-sidebar-usercard-meta {
    display: block;
  }

  body.client-sb-narrow .client-sidebar-nav a {
    justify-content: flex-start;
    padding: 0.68rem 0.85rem;
  }

  body.client-sb-narrow .client-sidebar-usercard {
    justify-content: flex-start;
    border: 1px solid var(--client-sb-border);
    background: #ffffff;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
  }
}

@media (max-width: 768px) {
  .client-shell > main {
    padding: 1.25rem 1rem 2rem;
  }

  .client-topbar-inner {
    padding: 0.55rem 1rem;
  }
}

/* Sidebar Dropdown CSS */
.sidebar-user-dropdown {
  position: absolute;
  bottom: 100%;
  left: 0.5rem;
  right: 0.5rem;
  background: white;
  border: 1px solid var(--client-sb-border);
  border-radius: var(--client-sb-radius);
  padding: 0.5rem;
  margin-bottom: 0.5rem;
  box-shadow: 0 -4px 15px rgba(0,0,0,0.06);
  z-index: 100;
  opacity: 0;
  visibility: hidden;
  transform: translateY(10px);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-user-dropdown.show {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.sidebar-dropdown-item {
  display: flex;
  padding: 0.65rem 0.75rem;
  color: var(--client-sb-text);
  text-decoration: none;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 500;
  align-items: center;
  gap: 0.75rem;
  transition: background 0.15s, color 0.15s;
}

.sidebar-dropdown-item i {
  width: 18px;
  text-align: center;
  color: var(--client-sb-accent);
}

.sidebar-dropdown-item:hover {
  background: var(--client-sb-accent-soft);
  color: #0284c7;
}

.sidebar-dropdown-item.danger-link {
  color: #ef4444;
}

.sidebar-dropdown-item.danger-link i {
  color: #ef4444;
}

.sidebar-dropdown-item.danger-link:hover {
  background: #fef2f2;
}

.sidebar-dropdown-divider {
  border-top: 1px solid var(--client-sb-border);
  margin: 0.35rem 0;
}
