/* ============================================
   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;
}

.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; }

/* ============================================
   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; }
}
