/* ============================================
   Sidebar navigation — Workspace switcher
   Independent of styles.css — safe to edit alone
   ============================================ */

:root {
  --ws-sidebar-width: 220px;
  --ws-sidebar-collapsed: 56px;
  --ws-sidebar-bg: #1f2937;
  --ws-sidebar-bg-hover: #374151;
  --ws-sidebar-bg-active: #111827;
  --ws-sidebar-text: #d1d5db;
  --ws-sidebar-text-hover: #ffffff;
  --ws-sidebar-accent: #f59e0b;
}

body {
  margin-left: var(--ws-sidebar-width);
  transition: margin-left .2s ease;
}

body.ws-sidebar-collapsed {
  margin-left: var(--ws-sidebar-collapsed);
}

.app-sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--ws-sidebar-width);
  background: var(--ws-sidebar-bg);
  color: var(--ws-sidebar-text);
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: width .2s ease;
  overflow: hidden;
  box-shadow: 2px 0 8px rgba(0,0,0,.06);
}

body.ws-sidebar-collapsed .app-sidebar {
  width: var(--ws-sidebar-collapsed);
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid #374151;
  white-space: nowrap;
}

.sidebar-brand {
  font-size: 16px;
  font-weight: 600;
  color: #fff;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: opacity .2s ease;
}

body.ws-sidebar-collapsed .sidebar-brand { opacity: 0; pointer-events: none; }

.sidebar-toggle {
  background: transparent;
  border: none;
  color: #f3f4f6;
  width: 28px;
  height: 28px;
  font-size: 16px;
  cursor: pointer;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.sidebar-toggle:hover { background: var(--ws-sidebar-bg-hover); }

.sidebar-nav {
  display: flex;
  flex-direction: column;
  padding: 12px 0;
  gap: 2px;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  /* Dark-themed scrollbar */
  scrollbar-width: thin;
  scrollbar-color: #4b5563 transparent;
}
.sidebar-nav::-webkit-scrollbar { width: 6px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav::-webkit-scrollbar-thumb { background: #4b5563; border-radius: 3px; }
.sidebar-nav::-webkit-scrollbar-thumb:hover { background: #6b7280; }

.sidebar-item {
  display: flex;
  align-items: center;
  gap: 14px;
  background: transparent;
  border: none;
  color: var(--ws-sidebar-text);
  padding: 12px 16px;
  font-size: 14px;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  border-left: 3px solid transparent;
  white-space: nowrap;
  font-family: inherit;
}

.sidebar-item:hover {
  background: var(--ws-sidebar-bg-hover);
  color: var(--ws-sidebar-text-hover);
}

.sidebar-item.active {
  background: var(--ws-sidebar-bg-active);
  color: #fff;
  border-left-color: var(--ws-sidebar-accent);
}

.sidebar-icon {
  font-size: 18px;
  flex-shrink: 0;
  width: 22px;
  text-align: center;
}

.sidebar-label {
  flex: 1;
  transition: opacity .2s ease;
  overflow: hidden;
  text-overflow: ellipsis;
}

body.ws-sidebar-collapsed .sidebar-label {
  opacity: 0;
  pointer-events: none;
}

.sidebar-footer {
  margin-top: auto;
  padding: 12px 16px;
  font-size: 11px;
  color: #6b7280;
  border-top: 1px solid #374151;
  white-space: nowrap;
  overflow: hidden;
  transition: opacity .2s ease;
}

body.ws-sidebar-collapsed .sidebar-footer { opacity: 0; }

/* ───── Sidebar account block (bottom) ───── */
.sidebar-account {
  margin-top: auto;
  border-top: 1px solid #374151;
  padding: 10px 12px;
  position: relative;
}
.account-trigger {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: transparent;
  border: none;
  border-radius: 8px;
  color: var(--ws-sidebar-text);
  cursor: pointer;
  text-align: left;
  transition: background .15s;
}
.account-trigger:hover { background: var(--ws-sidebar-bg-hover); color: var(--ws-sidebar-text-hover); }
.account-avatar {
  flex-shrink: 0;
  width: 32px; height: 32px;
  background: var(--ws-sidebar-accent);
  color: #1f2937;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px;
}
.account-info {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column; gap: 2px;
  overflow: hidden;
  transition: opacity .2s ease;
}
.account-name {
  font-size: 13px; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.account-role {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #9ca3af;
}
.account-role.role-admin { color: #fca5a5; }
.account-role.role-super_admin { color: #d8b4fe; }
.account-caret {
  flex-shrink: 0;
  font-size: 18px;
  color: #9ca3af;
  transition: opacity .2s ease;
}
body.ws-sidebar-collapsed .account-info,
body.ws-sidebar-collapsed .account-caret { opacity: 0; pointer-events: none; }

.account-menu {
  position: absolute;
  bottom: 100%;
  left: 12px; right: 12px;
  margin-bottom: 6px;
  background: #111827;
  border: 1px solid #374151;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  overflow: hidden;
  z-index: 200;
}
.account-menu-item {
  width: 100%;
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px;
  background: transparent;
  border: none;
  color: var(--ws-sidebar-text);
  cursor: pointer;
  font-size: 13px;
  text-align: left;
  transition: background .15s, color .15s;
}
.account-menu-item:hover { background: var(--ws-sidebar-bg-hover); color: #fff; }
.account-menu-item:last-child:hover { background: #7f1d1d; }

/* ============================================
   Folders trong sidebar — group workspaces
   ============================================ */
.sidebar-folder-add {
  display: flex;
  align-items: center;
  gap: 14px;
  background: transparent;
  border: 1px dashed #4b5563;
  color: #9ca3af;
  padding: 7px 14px;
  margin: 4px 12px 8px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12.5px;
  font-family: inherit;
  text-align: left;
  white-space: nowrap;
  opacity: 0.75;
  transition: opacity .15s, background .15s, color .15s;
}
.sidebar-folder-add:hover {
  opacity: 1;
  background: var(--ws-sidebar-bg-hover);
  color: var(--ws-sidebar-text-hover);
  border-color: var(--ws-sidebar-accent);
}
body.ws-sidebar-collapsed .sidebar-folder-add {
  padding: 7px 0;
  justify-content: center;
  border: none;
  margin: 4px 6px 8px;
}
body.ws-sidebar-collapsed .sidebar-folder-add .sidebar-label { opacity: 0; pointer-events: none; }

.sidebar-folder {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  font-size: 12px;
  color: #9ca3af;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  transition: background .15s;
}
.sidebar-folder:hover { background: var(--ws-sidebar-bg-hover); color: #fff; }
.folder-toggle {
  width: 12px;
  flex-shrink: 0;
  font-size: 10px;
  display: inline-block;
  text-align: center;
}
.folder-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
}
.folder-btn {
  background: transparent;
  border: none;
  color: inherit;
  cursor: pointer;
  font-size: 12px;
  padding: 2px 4px;
  border-radius: 3px;
  opacity: 0;
  transition: opacity .15s, background .15s;
}
.sidebar-folder:hover .folder-btn { opacity: 0.7; }
.folder-btn:hover { opacity: 1 !important; background: rgba(255,255,255,0.1); }
body.ws-sidebar-collapsed .sidebar-folder { padding: 8px 6px; justify-content: center; }
body.ws-sidebar-collapsed .folder-name,
body.ws-sidebar-collapsed .folder-btn { display: none; }

.sidebar-folder-body { display: flex; flex-direction: column; gap: 2px; }
.sidebar-folder-body.collapsed { display: none; }

.sidebar-item-nested { padding-left: 32px !important; }
body.ws-sidebar-collapsed .sidebar-item-nested { padding-left: 16px !important; }

/* Drag visuals */
.sidebar-item.dragging { opacity: 0.4; }
.sidebar-folder.drag-over,
.sidebar-folder-body.drag-over {
  background: var(--ws-sidebar-accent);
  color: #1f2937;
  outline: 2px dashed var(--ws-sidebar-accent);
  outline-offset: -2px;
}
.sidebar-folder.drag-over .folder-name,
.sidebar-folder.drag-over .folder-toggle { color: #1f2937; }

/* Folder modal — create/rename với emoji picker */
.sf-modal-overlay {
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, 0.5);
  z-index: 9999;
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
}
.sf-modal {
  background: #fff;
  border-radius: 12px;
  padding: 22px 24px;
  max-width: 460px;
  width: 100%;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.sf-modal h3 { margin: 0 0 16px; font-size: 17px; color: #1f2937; }
.sf-modal label { display: block; font-size: 12.5px; font-weight: 600; color: #4b5563; margin: 10px 0 6px; }
.sf-emoji-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 4px;
  padding: 8px;
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  max-height: 200px;
  overflow-y: auto;
}
.sf-emoji-btn {
  background: #fff;
  border: 1px solid transparent;
  border-radius: 5px;
  padding: 6px 0;
  font-size: 20px;
  cursor: pointer;
  transition: all .12s;
}
.sf-emoji-btn:hover { background: #f3f4f6; border-color: #d1d5db; }
.sf-emoji-btn.selected { background: #fef3c7; border-color: #f59e0b; }
.sf-name-input {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
}
.sf-name-input:focus { outline: none; border-color: #2563eb; box-shadow: 0 0 0 3px rgba(37,99,235,0.15); }
.sf-modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.sf-btn {
  padding: 8px 18px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  background: #fff;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}
.sf-btn:hover { background: #f3f4f6; }
.sf-btn-ok { background: #1B2A4A; color: #fff; border-color: #1B2A4A; }
.sf-btn-ok:hover { background: #2a3d5f; }

/* ============================================
   Workspace containers
   ============================================ */

.workspace { display: none; }
.workspace.active { display: block; }

/* ============================================
   Commercial Plan — placeholder styles
   ============================================ */

#workspace-commercial-plan {
  min-height: 100vh;
  padding: 32px;
}

.cp-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 70vh;
  text-align: center;
  gap: 16px;
  color: #6b7280;
}

.cp-placeholder .cp-icon {
  font-size: 64px;
  opacity: .6;
}

.cp-placeholder h2 {
  font-size: 28px;
  color: #1f2937;
  margin: 0;
}

.cp-placeholder p {
  font-size: 14px;
  max-width: 480px;
  line-height: 1.6;
  margin: 0;
}

/* ============================================
   Responsive — mobile
   ============================================ */

@media (max-width: 768px) {
  :root { --ws-sidebar-width: 180px; }
  body { margin-left: var(--ws-sidebar-collapsed); }
  .app-sidebar { width: var(--ws-sidebar-collapsed); }
  .sidebar-label, .sidebar-brand, .sidebar-footer { opacity: 0; }
  body.ws-sidebar-open .app-sidebar { width: var(--ws-sidebar-width); }
  body.ws-sidebar-open .sidebar-label,
  body.ws-sidebar-open .sidebar-brand,
  body.ws-sidebar-open .sidebar-footer { opacity: 1; }
}
