/* ===========================================================
   APP SHELL — collapsible sidebar (left) + main content (right)
   Style theo pancake-dashboard: white sidebar, indigo active
   =========================================================== */
:root {
  --sidebar-w-expanded: 240px;
  --sidebar-w-collapsed: 64px;
  --sidebar-w: var(--sidebar-w-expanded);
  --sidebar-bg: #ffffff;
  --sidebar-border: #e5e7eb;
  --sidebar-fg: #6b7280;        /* gray-500 cho text inactive */
  --sidebar-fg-strong: #111827; /* gray-900 cho brand title */
  --sidebar-fg-dim: #9ca3af;    /* gray-400 */
  --sidebar-active: #6366f1;    /* indigo-600 — pancake style */
  --sidebar-active-text: #ffffff;
  --sidebar-hover: #f3f4f6;     /* gray-100 */
}

.app-shell.collapsed {
  --sidebar-w: var(--sidebar-w-collapsed);
}

.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
  transition: grid-template-columns 0.25s ease;
  background: #f9fafb;
}

.app-sidebar {
  background: var(--sidebar-bg);
  color: var(--sidebar-fg);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-x: hidden;
  overflow-y: auto;
  border-right: 1px solid var(--sidebar-border);
  transition: width 0.25s ease;
}

/* ===== HEAD: brand + collapse toggle ===== */
.app-sidebar-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px;
  border-bottom: 1px solid #f3f4f6;
  flex-shrink: 0;
}

.app-sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
}

.app-sidebar-brand-mark {
  background: var(--sidebar-active);
  color: #fff;
  font-weight: 800;
  font-size: 12px;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.app-sidebar-brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.app-sidebar-brand-title {
  font-weight: 700;
  font-size: 13px;
  color: var(--sidebar-fg-strong);
  white-space: nowrap;
}

.app-sidebar-brand-subtitle {
  font-size: 11px;
  color: var(--sidebar-fg-dim);
  white-space: nowrap;
  margin-top: 1px;
}

.app-shell.collapsed .app-sidebar-brand-text {
  display: none;
}

.app-sidebar-toggle {
  background: transparent;
  border: 1px solid #e5e7eb;
  color: var(--sidebar-fg);
  width: 26px;
  height: 26px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  transition: all 0.15s;
  flex-shrink: 0;
}

.app-sidebar-toggle:hover {
  background: var(--sidebar-hover);
  border-color: #d1d5db;
  color: var(--sidebar-fg-strong);
}

.app-shell.collapsed .app-sidebar-head {
  flex-direction: column;
  padding: 14px 8px;
  gap: 10px;
  border-bottom: 1px solid #f3f4f6;
}

.app-shell.collapsed .app-sidebar-brand {
  flex: 0;
  justify-content: center;
}

.app-shell.collapsed .app-sidebar-brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  font-size: 13px;
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.25);
}

.app-shell.collapsed .app-sidebar-toggle {
  width: 28px;
  height: 28px;
  border-radius: 50%;
}

/* ===== NAV ===== */
.app-sidebar-nav {
  flex: 1;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.app-sidebar-section-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--sidebar-fg-dim);
  padding: 12px 12px 6px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
}

.app-shell.collapsed .app-sidebar-section-label {
  font-size: 0;
  padding: 0;
  height: 1px;
  background: #e5e7eb;
  margin: 14px 14px 6px;
  overflow: hidden;
}

.app-sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  color: var(--sidebar-fg);
  text-decoration: none;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  transition: all 0.15s;
  cursor: pointer;
}

.app-sidebar-link:hover {
  background: var(--sidebar-hover);
  color: var(--sidebar-fg-strong);
}

.app-sidebar-link.active {
  background: var(--sidebar-active);
  color: var(--sidebar-active-text);
}

/* (legacy emoji rule — không còn dùng vì đã chuyển SVG) */

.app-sidebar-link-icon {
  font-size: 16px;
  width: 18px;
  text-align: center;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--sidebar-fg);
}
.app-sidebar-link-icon svg {
  width: 18px;
  height: 18px;
  display: block;
  stroke: currentColor;
}
.app-sidebar-link.active .app-sidebar-link-icon {
  color: var(--sidebar-active-text);
}
.app-sidebar-link:not(.active):hover .app-sidebar-link-icon {
  color: var(--sidebar-fg-strong);
}
/* Bỏ filter brightness cho SVG (chỉ áp emoji nếu có) */
.app-sidebar-link.active .app-sidebar-link-icon svg {
  filter: none;
}

.app-sidebar-link-text {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Badge phải link (HOT, Pro, Mới...) */
.app-sidebar-link-badge {
  margin-left: auto;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 10px;
  flex-shrink: 0;
}

.app-shell.collapsed .app-sidebar-link-text,
.app-shell.collapsed .app-sidebar-link-badge {
  display: none;
}

.app-shell.collapsed .app-sidebar-nav {
  padding: 10px 0;
  align-items: center;
  gap: 4px;
}

.app-shell.collapsed .app-sidebar-link {
  justify-content: center;
  padding: 0;
  width: 44px;
  height: 44px;
  border-radius: 12px;
}

.app-shell.collapsed .app-sidebar-link-icon {
  font-size: 19px;
  width: auto;
}
.app-shell.collapsed .app-sidebar-link-icon svg {
  width: 20px;
  height: 20px;
}

.app-shell.collapsed .app-sidebar-link:hover {
  background: #eef2ff;
  color: #4338ca;
  transform: translateY(-1px);
}

.app-shell.collapsed .app-sidebar-link.active {
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
}

.app-shell.collapsed .app-sidebar-divider {
  margin: 8px 14px;
}

/* Badge color variants */
.badge-hot { background: linear-gradient(to right, #f97316, #ec4899); color: #fff; }
.badge-pro { background: linear-gradient(to right, #a855f7, #6366f1); color: #fff; }
.badge-new { background: #fed7aa; color: #c2410c; }
.badge-multi { background: #dbeafe; color: #1d4ed8; }
.badge-capi { background: #dbeafe; color: #1d4ed8; }
.badge-info { background: #e0e7ff; color: #4338ca; }
.badge-success { background: #d1fae5; color: #047857; }

/* Section divider */
.app-sidebar-divider {
  height: 1px;
  background: #f3f4f6;
  margin: 8px 4px;
}

/* ===== FOOT: user info + status ===== */
.app-sidebar-foot {
  padding: 12px 16px;
  border-top: 1px solid #f3f4f6;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.app-sidebar-foot-avatar {
  width: 28px;
  height: 28px;
  background: #e0e7ff;
  color: #4f46e5;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
}

.app-sidebar-foot-info {
  flex: 1;
  overflow: hidden;
  white-space: nowrap;
}

.app-sidebar-foot-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--sidebar-fg-strong);
}

.app-sidebar-foot-status {
  font-size: 11px;
  color: #10b981;
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 1px;
}

.app-sidebar-foot-status::before {
  content: '';
  width: 6px;
  height: 6px;
  background: #10b981;
  border-radius: 50%;
}

.app-shell.collapsed .app-sidebar-foot {
  padding: 12px 0;
  justify-content: center;
  border-top: 1px solid #f3f4f6;
}

.app-shell.collapsed .app-sidebar-foot-info {
  display: none;
}

.app-shell.collapsed .app-sidebar-foot-avatar {
  width: 32px;
  height: 32px;
  font-size: 12px;
  position: relative;
}

/* Status dot xanh cạnh avatar khi collapsed */
.app-shell.collapsed .app-sidebar-foot-avatar::after {
  content: '';
  position: absolute;
  bottom: -1px;
  right: -1px;
  width: 9px;
  height: 9px;
  background: #10b981;
  border: 2px solid #fff;
  border-radius: 50%;
}

/* Smooth transition cho icon mode */
.app-sidebar-link {
  transition: all 0.15s ease;
}

/* ===== MAIN content area ===== */
.app-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: #f9fafb;
}

.app-main .container {
  max-width: 100%;
  padding: 16px 20px;
}

@media (min-width: 1600px) {
  .app-main .container {
    padding: 16px 24px;
  }
}

.app-main .topbar {
  border-bottom: 1px solid #e5e7eb;
  background: #fff;
  padding: 12px 20px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.app-main .topbar .topbar-left .link-back,
.app-main .topbar .topbar-left .brand {
  display: none;
}

.app-main .topbar-title {
  font-size: 16px;
  font-weight: 600;
  color: #111827;
  margin: 0;
}

/* Mobile responsive */
@media (max-width: 768px) {
  .app-shell {
    grid-template-columns: 0 1fr;
  }
  .app-sidebar {
    position: fixed;
    z-index: 200;
    width: var(--sidebar-w-expanded);
    transform: translateX(-100%);
    transition: transform 0.25s ease;
  }
  .app-shell.mobile-open .app-sidebar {
    transform: translateX(0);
  }
  .app-shell.mobile-open::after {
    content: '';
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 150;
  }
}
