/* Shell chung cho các trang Figma — đồng bộ theme với Chat (crewai_web_ui_prefs.theme) */
:root {
  --f-bg: #0e0e0e;
  --f-panel: #131313;
  --f-panel-2: #1a1919;
  --f-border: rgba(72, 72, 71, 0.12);
  --f-text: rgba(255, 255, 255, 0.92);
  --f-muted: #adaaaa;
  --f-muted-2: #737373;
  --f-accent: #fb9270;
  --f-accent-2: #eb8564;
  --f-accent-ink: #5a1701;
  --f-nav: #a3a3a3;
  --f-nav-hover-bg: rgba(255, 255, 255, 0.04);
  --f-brand-wordmark: #d97757;
  --f-ambient: rgba(251, 146, 112, 0.05);
  --f-toggle-track: #333;
  --f-toggle-knob: #fff;
  /* Khớp stack trang Chat (index.html) để wordmark / tiêu đề serif đồng nhất */
  --f-serif: "Newsreader", Georgia, "Times New Roman", serif;
  --f-sans: "Inter", ui-sans-serif, system-ui, sans-serif;
  --f-sb-w: 288px;
  /* Mặc định = panel; theme sáng ghi đè để đồng bộ với chat index. */
  --f-sb-bg: var(--f-panel);
}
html[data-theme="light"] {
  --f-bg: #faf9f7;
  --f-panel: #ffffff;
  --f-panel-2: #f4f4f5;
  --f-border: rgba(15, 23, 42, 0.08);
  --f-text: #0f172a;
  --f-muted: #64748b;
  --f-muted-2: #94a3b8;
  --f-accent: #ea580c;
  --f-accent-2: #c2410c;
  --f-accent-ink: #ffffff;
  --f-nav: #64748b;
  --f-nav-hover-bg: rgba(15, 23, 42, 0.04);
  --f-brand-wordmark: var(--f-accent);
  --f-ambient: rgba(234, 88, 12, 0.06);
  --f-toggle-track: #cbd5e1;
  --f-toggle-knob: #fff;
  /* Cột trái cùng nền với --f-bg, tránh sidebar trắng + khối upgrade xám lệch tông. */
  --f-sb-bg: #faf9f7;
  color-scheme: light;
}
html {
  color-scheme: dark;
  background: var(--f-bg);
}
html[data-theme="light"] {
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--f-sans);
  background: var(--f-bg);
  color: var(--f-text);
  -webkit-font-smoothing: antialiased;
}
.f-shell {
  display: flex;
  height: 100dvh;
  overflow: hidden;
}
.f-sb {
  width: var(--f-sb-w);
  min-width: var(--f-sb-w);
  height: 100dvh;
  min-height: 0;
  background: var(--f-sb-bg);
  border-right: 1px solid var(--f-border);
  display: flex;
  flex-direction: column;
  padding: 1.5rem 1rem 1rem;
  position: sticky;
  top: 0;
  overflow-x: hidden;
  overflow-y: hidden;
}
.f-sb-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0 0.5rem;
  text-decoration: none;
  color: inherit;
}
.f-sb-brand img {
  width: 32px;
  height: 32px;
  border-radius: 0;
  object-fit: contain;
}
.f-sb-brand span {
  font-family: var(--f-serif);
  font-style: italic;
  font-weight: 400;
  font-size: 1.25rem;
  line-height: 1.4;
  letter-spacing: -0.02em;
  color: var(--f-brand-wordmark);
}
.sb-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  /* Khoảng cách tới nav — trước nằm trong padding-bottom của .f-sb-brand (làm lệch nút thu gọn so với chữ CrewAI) */
  margin-bottom: 1.25rem;
}
.sb-collapse-btn {
  width: 28px;
  height: 28px;
  border: 1px solid var(--f-border);
  border-radius: 6px;
  background: transparent;
  color: var(--f-muted);
  display: grid;
  place-items: center;
  cursor: pointer;
  flex-shrink: 0;
}
.sb-collapse-btn:hover {
  color: var(--f-text);
  background: var(--f-nav-hover-bg);
}
.sb-collapse-btn svg {
  width: 15px;
  height: 15px;
}
.sb-collapse-btn img {
  width: 18px;
  height: 18px;
  border-radius: 6px;
  object-fit: contain;
  display: block;
}
.f-sb-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.f-sb-nav a,
.f-sb-nav button {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 10px 16px;
  border-radius: 4px;
  border: none;
  background: transparent;
  color: var(--f-nav);
  font: inherit;
  font-size: 0.875rem;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}
/* Nút New Chat: CTA nổi bật, khác các link điều hướng phẳng (Chat, Workspace, …) */
.f-sb-nav .nav-new-chat,
.f-sb-nav #btn-new-chat {
  margin-bottom: 6px;
  font-weight: 600;
  font-size: 0.8125rem;
  letter-spacing: 0.01em;
  border-radius: 10px;
  padding: 10px 14px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: linear-gradient(135deg, var(--f-accent) 0%, var(--f-accent-2) 100%);
  color: var(--f-accent-ink);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.22);
}
.f-sb-nav .nav-new-chat svg,
.f-sb-nav #btn-new-chat svg {
  opacity: 1;
  stroke: currentColor;
}
.f-sb-nav .nav-new-chat:hover,
.f-sb-nav #btn-new-chat:hover {
  color: var(--f-accent-ink);
  background: linear-gradient(135deg, var(--f-accent) 0%, var(--f-accent-2) 100%);
  filter: brightness(1.07);
}
html[data-theme="light"] .f-sb-nav .nav-new-chat,
html[data-theme="light"] .f-sb-nav #btn-new-chat {
  border-color: rgba(15, 23, 42, 0.08);
  color: #fff;
  box-shadow: 0 2px 10px rgba(234, 88, 12, 0.28);
}
html[data-theme="light"] .f-sb-nav .nav-new-chat:hover,
html[data-theme="light"] .f-sb-nav #btn-new-chat:hover {
  color: #fff;
  filter: brightness(1.05);
}
.f-sb-nav #btn-new-chat[data-active="true"] {
  outline: 2px solid rgba(251, 146, 112, 0.45);
  outline-offset: 2px;
}
html[data-theme="light"] .f-sb-nav #btn-new-chat[data-active="true"] {
  outline-color: rgba(234, 88, 12, 0.4);
}
.f-sb-nav a:hover,
.f-sb-nav button:not(.nav-new-chat):not(#btn-new-chat):hover {
  color: var(--f-text);
  background: var(--f-nav-hover-bg);
}
.f-sb-nav a[aria-current="page"],
.f-sb-nav button[aria-current="page"] {
  background: var(--f-panel-2);
  color: var(--f-accent);
}
.f-sb-nav svg { width: 16px; height: 16px; flex-shrink: 0; opacity: 0.9; }
.f-sb-recent {
  margin-top: 1.25rem;
  padding: 0 0.5rem;
  flex: 1 1 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.f-sb-recent h3 {
  margin: 0 0 0.5rem;
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--f-muted-2);
}
.f-sb-recent ul {
  margin: 0;
  padding: 0;
  list-style: none;
}
.f-sb-recent li {
  font-size: 0.78rem;
  color: var(--f-muted);
  padding: 0.35rem 0;
  border-bottom: 1px solid var(--f-border);
}
.f-sb-recent li a {
  color: inherit;
  text-decoration: none;
  display: block;
}
.f-sb-recent li a:hover {
  color: var(--f-text);
}
.sidebar-session-tools {
  display: flex;
  justify-content: flex-end;
  margin: 0 0 6px;
  padding: 0 8px;
}
/* Vùng cuộn “Gần đây”: thanh cuộn ẩn, vẫn cuộn được (wheel / kéo) */
.sidebar-session-scroll {
  flex: 1;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  padding-right: 2px;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.sidebar-session-scroll::-webkit-scrollbar {
  width: 0;
  height: 0;
  display: none;
}
.sidebar-session-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow: visible;
  padding-right: 0;
}
.sidebar-session-view-all {
  display: block;
  margin-top: 0.5rem;
  padding: 0.45rem 0.35rem 0.15rem;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--f-muted);
  text-decoration: none;
  text-align: center;
  border-radius: 8px;
  flex-shrink: 0;
}
.sidebar-session-view-all:hover {
  color: var(--f-accent);
  background: var(--f-nav-hover-bg);
}
.sidebar-session-item {
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 8px;
  background: transparent;
  color: var(--f-muted);
  text-align: left;
  cursor: pointer;
  text-decoration: none;
  display: block;
}
.sidebar-session-item-wrap {
  position: relative;
}
.sidebar-session-item-wrap .sidebar-session-item {
  padding-right: 34px;
}
.sidebar-session-del {
  position: absolute;
  top: 7px;
  right: 6px;
  width: 22px;
  height: 22px;
  border: 1px solid var(--f-border);
  border-radius: 999px;
  background: transparent;
  color: var(--f-muted);
  display: grid;
  place-items: center;
  cursor: pointer;
  opacity: 0;
  transition: opacity .12s ease;
}
.sidebar-session-item-wrap:hover .sidebar-session-del {
  opacity: 1;
}
.sidebar-session-del:hover {
  color: #f87171;
  border-color: rgba(248, 113, 113, 0.55);
  background: rgba(248, 113, 113, 0.08);
}
.sidebar-session-item:hover {
  background: var(--f-nav-hover-bg);
  color: var(--f-text);
}
.sidebar-session-item.is-active {
  border-color: var(--f-border);
  background: rgba(251, 146, 112, 0.08);
  color: var(--f-text);
}
.sidebar-session-title {
  display: block;
  font-size: 0.8rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-session-meta {
  margin-top: 3px;
  font-size: 0.72rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  opacity: 0.85;
}
.sidebar-meta-compact {
  display: none;
}
.sidebar-meta-compact h3 {
  margin: 0 0 0.5rem;
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--f-muted-2);
}
.sidebar-meta-box {
  font-size: 0.78rem;
  color: var(--f-muted);
  line-height: 1.45;
  word-break: break-all;
  padding: 0.35rem 0;
  border-bottom: 1px solid var(--f-border);
}
.sidebar-meta-box code {
  font-size: 0.72rem;
  color: var(--f-text);
}
.f-sb-spacer { flex: 0; min-height: 0.25rem; height: 0; }
.f-sb-up {
  padding: 0 0.5rem;
}
.f-sb-up .box {
  background: var(--f-panel-2);
  border-radius: 8px;
  padding: 1rem;
}
html[data-theme="light"] .f-sb-up .box {
  background: transparent;
  border: 1px solid var(--f-border);
}
.f-sb-up p { margin: 0 0 0.5rem; font-size: 0.75rem; color: var(--f-muted); line-height: 1.35; }
.f-sb-up .cta {
  width: 100%;
  padding: 8px;
  border: none;
  border-radius: 4px;
  font: inherit;
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  color: var(--f-accent-ink);
  background: linear-gradient(90deg, var(--f-accent), var(--f-accent-2));
}
.f-sb-user {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 0.5rem 0.25rem;
  margin-top: 0.5rem;
  text-decoration: none;
  color: inherit;
  border-radius: 8px;
}
.f-sb-user:hover {
  background: var(--f-nav-hover-bg);
}
html[data-sb-collapsed="1"] .f-sb,
html[data-sb-collapsed="1"] .sidebar {
  width: 76px !important;
  min-width: 76px !important;
  padding-left: 0.55rem !important;
  padding-right: 0.55rem !important;
}
html[data-sb-collapsed="1"] .brand-wordmark,
html[data-sb-collapsed="1"] .sb-label,
html[data-sb-collapsed="1"] .f-sb-recent,
html[data-sb-collapsed="1"] .sidebar-meta-compact,
html[data-sb-collapsed="1"] .f-sb-up,
html[data-sb-collapsed="1"] .sidebar-user-info {
  display: none !important;
}
html[data-sb-collapsed="1"] .f-sb-brand {
  padding: 0 0 0.75rem;
  justify-content: center;
  display: none;
}
html[data-sb-collapsed="1"] .f-sb-nav a,
html[data-sb-collapsed="1"] .f-sb-nav button {
  justify-content: center;
  padding-left: 0;
  padding-right: 0;
}
html[data-sb-collapsed="1"] .sb-collapse-btn svg {
  transform: rotate(180deg);
}
html[data-sb-collapsed="1"] .sb-head {
  justify-content: center;
}
html[data-sb-collapsed="1"] .sb-collapse-btn {
  width: 42px;
  height: 42px;
  border-radius: 10px;
}
.f-sb-user .av {
  width: 32px;
  height: 32px;
  border-radius: 12px;
  background: rgba(251, 146, 112, 0.15);
  color: var(--f-accent);
  display: grid;
  place-items: center;
  font-size: 0.75rem;
  font-weight: 700;
}
.f-sb-user .av img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: inherit;
  display: block;
}
.f-sb-user .nm { font-size: 0.875rem; font-weight: 500; word-break: break-all; }
.f-sb-user .pl { font-size: 0.6875rem; color: var(--f-muted); }
.f-main {
  flex: 1;
  min-width: 0;
  height: 100dvh;
  overflow: auto;
  position: relative;
}
.f-main::before {
  content: "";
  position: fixed;
  pointer-events: none;
  width: 800px;
  height: 600px;
  left: calc(var(--f-sb-w) + 30%);
  top: -200px;
  transform: translateX(-50%);
  border-radius: 12px;
  background: var(--f-ambient);
  filter: blur(60px);
  z-index: 0;
}
.f-main-inner {
  position: relative;
  z-index: 1;
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem 1.75rem 4rem;
}
.f-page-title {
  font-family: var(--f-serif);
  font-weight: 400;
  font-size: clamp(1.75rem, 3vw, 2.75rem);
  letter-spacing: -0.02em;
  margin: 0 0 0.5rem;
  line-height: 1.15;
}
.f-page-title.accent { color: var(--f-text); }
.f-page-sub {
  margin: 0 0 2rem;
  max-width: 42rem;
  font-size: 1rem;
  line-height: 1.55;
  color: var(--f-muted);
}
.f-row-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 2rem;
}
.f-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.65rem 1.25rem;
  border-radius: 8px;
  border: none;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
}
.f-btn-primary {
  color: var(--f-accent-ink);
  background: linear-gradient(90deg, var(--f-accent), var(--f-accent-2));
}
.f-btn-primary:hover { filter: brightness(1.04); }
.f-btn-ghost {
  background: transparent;
  color: var(--f-muted);
  border: 1px solid var(--f-border);
}
.f-btn-ghost:hover { color: var(--f-text); border-color: var(--f-muted); }
.f-card {
  background: var(--f-panel);
  border: 1px solid var(--f-border);
  border-radius: 12px;
  padding: 1.25rem 1.35rem;
}
.f-grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
}
.fshell-drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 140;
  background: rgba(0, 0, 0, 0.45);
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s;
  -webkit-tap-highlight-color: transparent;
}
html[data-theme="light"] .fshell-drawer-backdrop {
  background: rgba(15, 23, 42, 0.32);
}
html.fshell-drawer-open .fshell-drawer-backdrop {
  opacity: 1;
  pointer-events: auto;
  visibility: visible;
}
.crewai-fshell-menu-btn {
  display: none;
  position: fixed;
  bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
  left: calc(1rem + env(safe-area-inset-left, 0px));
  width: 52px;
  height: 52px;
  border-radius: 14px;
  z-index: 160;
  border: 1px solid var(--f-border);
  background: var(--f-panel);
  color: var(--f-text);
  box-shadow: 0 12px 40px -12px rgba(0, 0, 0, 0.45);
  cursor: pointer;
  place-items: center;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
@media (max-width: 960px) {
  .f-grid-3 { grid-template-columns: 1fr; }
  .f-shell {
    display: flex;
    flex-direction: row;
    height: 100dvh;
    max-height: 100dvh;
    overflow: hidden;
    position: relative;
  }
  .f-main {
    flex: 1;
    min-width: 0;
    height: 100dvh;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
  }
  .f-main-inner {
    padding: 1.25rem max(1rem, env(safe-area-inset-right, 0px)) calc(3rem + env(safe-area-inset-bottom, 0px)) max(1rem, env(safe-area-inset-left, 0px));
  }
  .f-topbar {
    padding: 0.75rem max(1rem, env(safe-area-inset-right, 0px)) 0.75rem max(1rem, env(safe-area-inset-left, 0px));
    padding-top: max(0.75rem, env(safe-area-inset-top, 0px));
  }
  .f-sb {
    position: fixed;
    top: 0;
    left: 0;
    height: 100dvh;
    max-height: 100dvh;
    width: min(var(--f-sb-w), 88vw);
    min-width: 0;
    z-index: 150;
    transform: translateX(-105%);
    transition: transform 0.22s ease;
    box-shadow: 8px 0 36px rgba(0, 0, 0, 0.32);
    flex-direction: column;
    flex-wrap: nowrap;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: calc(1rem + env(safe-area-inset-top, 0px)) calc(1rem + env(safe-area-inset-right, 0px)) calc(1rem + env(safe-area-inset-bottom, 0px)) calc(1rem + env(safe-area-inset-left, 0px));
    border-right: 1px solid var(--f-border);
  }
  html.fshell-drawer-open .f-sb {
    transform: translateX(0);
  }
  body:has(.f-shell) .crewai-fshell-menu-btn {
    display: grid;
  }
  html[data-sb-collapsed="1"] .f-sb .brand-wordmark,
  html[data-sb-collapsed="1"] .f-sb .sb-label,
  html[data-sb-collapsed="1"] .f-sb .f-sb-recent,
  html[data-sb-collapsed="1"] .f-sb .sidebar-meta-compact,
  html[data-sb-collapsed="1"] .f-sb .f-sb-up,
  html[data-sb-collapsed="1"] .f-sb .sidebar-user-info {
    display: revert !important;
  }
  html[data-sb-collapsed="1"] .f-sb .f-sb-brand {
    display: flex !important;
  }
  html[data-sb-collapsed="1"] .f-sb {
    width: min(var(--f-sb-w), 88vw) !important;
    min-width: 0 !important;
  }
}
@media (hover: none) and (pointer: coarse) {
  .sidebar-session-del {
    opacity: 1 !important;
  }
}
.f-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}
.f-table th,
.f-table td {
  padding: 0.65rem 0.75rem;
  text-align: left;
  border-bottom: 1px solid var(--f-border);
}
.f-table th {
  color: var(--f-muted);
  font-weight: 600;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.f-pill {
  display: inline-block;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  background: var(--f-panel-2);
  color: var(--f-muted);
}
.f-pill.ok { background: rgba(74, 222, 128, 0.12); color: #86efac; }
.f-pill.warn { background: rgba(251, 191, 36, 0.12); color: #fcd34d; }
.f-pill.neutral { background: rgba(163, 163, 163, 0.12); color: #d4d4d4; }
html[data-theme="light"] .f-pill.ok { background: rgba(22, 163, 74, 0.12); color: #15803d; }
html[data-theme="light"] .f-pill.warn { background: rgba(217, 119, 6, 0.12); color: #b45309; }
html[data-theme="light"] .f-pill.neutral { background: rgba(100, 116, 139, 0.12); color: #475569; }
.f-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.75rem;
  border-bottom: 1px solid var(--f-border);
  background: var(--f-bg);
  position: sticky;
  top: 0;
  z-index: 5;
}
.f-topbar a { color: var(--f-muted); text-decoration: none; font-size: 0.9rem; }
.f-topbar a:hover { color: var(--f-text); }
.f-link { color: var(--f-accent); text-decoration: none; }
.f-link:hover { text-decoration: underline; }
.f-sw { width: 44px; height: 24px; border-radius: 999px; background: var(--f-toggle-track); position: relative; cursor: pointer; border: none; padding: 0; flex-shrink: 0; }
.f-sw.on { background: var(--f-accent); }
.f-sw::after { content: ""; position: absolute; width: 18px; height: 18px; border-radius: 50%; background: var(--f-toggle-knob); top: 3px; left: 3px; transition: transform 0.15s; }
.f-sw.on::after { transform: translateX(20px); }
