/* ──────────────────────────────────────────────────────────────
   WORKSPACE & PORTAL LAYOUT STYLES
   Sidebar navigation, responsive patterns, and dashboard layouts
   ────────────────────────────────────────────────────────────── */

:root {
  --sidebar-width: 250px;
  --sidebar-width-mobile: 60px;
  --sidebar-bg: #12121a;
  --sidebar-border: rgba(0, 191, 255, 0.1);
  --sidebar-text: #a0a0b0;
  --sidebar-text-hover: #f0f0f0;
  --sidebar-active: #00BFFF;
  --sidebar-active-bg: rgba(0, 191, 255, 0.1);
  --workspace-header-height: 60px;
  --transition-speed: 0.3s;
}

/* ── WORKSPACE & PORTAL WRAPPER ────────────────────────────── */

.workspace-layout,
.portal-layout {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ── SIDEBAR CONTAINER ────────────────────────────────────── */

.sidebar {
  position: fixed;
  left: 0;
  top: var(--workspace-header-height);
  width: var(--sidebar-width);
  height: calc(100vh - var(--workspace-header-height));
  background-color: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border);
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 1000;
  transition: width var(--transition-speed) ease, transform var(--transition-speed) ease;
  padding-top: 1rem;
}

.sidebar.collapsed {
  width: var(--sidebar-width-mobile);
}

.sidebar::-webkit-scrollbar {
  width: 6px;
}

.sidebar::-webkit-scrollbar-track {
  background: transparent;
}

.sidebar::-webkit-scrollbar-thumb {
  background: rgba(0, 191, 255, 0.2);
  border-radius: 3px;
}

.sidebar::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 191, 255, 0.4);
}

/* ── SIDEBAR TOGGLE BUTTON ────────────────────────────────── */

.sidebar-toggle {
  position: fixed;
  top: 10px;
  left: 10px;
  width: 40px;
  height: 40px;
  background: transparent;
  border: 1px solid var(--sidebar-border);
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1001;
  transition: background-color var(--transition-speed) ease, border-color var(--transition-speed) ease;
  color: var(--sidebar-active);
  font-size: 20px;
}

.sidebar-toggle:hover {
  background-color: rgba(0, 191, 255, 0.1);
  border-color: rgba(0, 191, 255, 0.3);
}

/* ── WORKSPACE HEADER ────────────────────────────────────── */

.workspace-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--workspace-header-height);
  background: rgba(10, 10, 15, 0.95);
  border-bottom: 1px solid var(--sidebar-border);
  display: flex;
  align-items: center;
  padding: 0 1.5rem;
  z-index: 1050;
  backdrop-filter: blur(10px);
}

.workspace-header-left {
  display: flex;
  align-items: center;
  gap: 2rem;
  flex: 1;
}

.workspace-header-logo {
  font-size: 18px;
  font-weight: 600;
  color: #f0f0f0;
  white-space: nowrap;
  letter-spacing: 0.5px;
}

.workspace-header-module {
  font-size: 14px;
  color: var(--sidebar-text);
  font-weight: 500;
}

.workspace-header-right {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  margin-left: auto;
}

.workspace-user-menu {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  cursor: pointer;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  transition: background-color var(--transition-speed) ease;
}

.workspace-user-menu:hover {
  background-color: rgba(0, 191, 255, 0.1);
}

.workspace-user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, #00BFFF, #0099cc);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
  color: #fff;
}

.workspace-user-name {
  font-size: 14px;
  color: #f0f0f0;
  font-weight: 500;
}

.workspace-header-actions {
  display: flex;
  gap: 0.5rem;
}

.workspace-header-action {
  padding: 0.5rem 0.75rem;
  color: var(--sidebar-text);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  transition: all var(--transition-speed) ease;
}

.workspace-header-action:hover {
  color: var(--sidebar-active);
  border-color: var(--sidebar-border);
}

/* ── DIVISION SWITCHER ───────────────────────────────────– */

.division-switcher {
  position: relative;
  display: flex;
  align-items: center;
  margin-right: 2rem;
}

.division-toggle-btn {
  appearance: none;
  -webkit-appearance: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.85rem;
  background: linear-gradient(180deg, rgba(0, 191, 255, 0.18), rgba(0, 191, 255, 0.08));
  border: 1px solid rgba(0, 191, 255, 0.4);
  border-radius: 10px;
  color: #d8f7ff;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: all 180ms ease;
  white-space: nowrap;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08), 0 6px 14px rgba(0, 0, 0, 0.35);
}

.division-toggle-btn:hover {
  background: linear-gradient(180deg, rgba(0, 191, 255, 0.24), rgba(0, 191, 255, 0.12));
  border-color: rgba(0, 191, 255, 0.7);
  transform: translateY(-1px);
}

.division-toggle-caret {
  font-size: 0.8rem;
  margin-left: 0.2rem;
  opacity: 0.9;
}

.division-current {
  font-weight: 700;
  letter-spacing: 0.3px;
  text-transform: capitalize;
}

.division-dropdown-menu {
  position: absolute;
  top: calc(100% + 0.75rem);
  right: 0;
  background: linear-gradient(180deg, #171726, #11111b);
  border: 1px solid rgba(0, 191, 255, 0.3);
  border-radius: 12px;
  min-width: 250px;
  z-index: 1001;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.55);
  display: none;
  padding: 0;
  backdrop-filter: blur(10px);
  overflow: hidden;
}

.division-dropdown-menu.show {
  display: block;
}

.division-dropdown-inner {
  padding: 0.55rem;
}

.division-dropdown-title {
  padding: 0.45rem 0.5rem 0.6rem;
  font-size: 11px;
  color: #9ab8c2;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  font-weight: 700;
}

.division-option {
  appearance: none;
  -webkit-appearance: none;
  display: flex;
  align-items: center;
  width: 100%;
  gap: 0.5rem;
  padding: 0.62rem 0.7rem;
  margin-bottom: 0.35rem;
  text-align: left;
  background: rgba(0, 191, 255, 0.04);
  border: 1px solid rgba(0, 191, 255, 0.16);
  border-radius: 9px;
  color: #b8d6df;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 160ms ease;
}

.division-option:hover {
  background: rgba(0, 191, 255, 0.14);
  border-color: rgba(0, 191, 255, 0.4);
  color: #e8fbff;
  transform: translateX(1px);
}

.division-option.active-div {
  background: rgba(0, 191, 255, 0.22);
  color: #e9fcff;
  border-color: rgba(0, 191, 255, 0.55);
  box-shadow: inset 0 0 0 1px rgba(0, 191, 255, 0.3);
}

.division-option:last-child {
  margin-bottom: 0;
}

.division-option-check {
  width: 16px;
  opacity: 0;
  color: #8de6ff;
}

.division-option-check.visible {
  opacity: 1;
}

.division-option-label {
  display: inline-block;
}

.division-logo {
  font-size: 18px;
  line-height: 1;
}

.division-name {
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.3px;
}

/* ── MAIN CONTENT AREA ────────────────────────────────────– */

.workspace-content,
.portal-content {
  margin-left: var(--sidebar-width);
  margin-top: var(--workspace-header-height);
  flex: 1;
  padding: 2rem;
}

.workspace-content.sidebar-collapsed,
.portal-content.sidebar-collapsed {
  margin-left: var(--sidebar-width-mobile);
}

/* ── SIDEBAR NAVIGATION ────────────────────────────────────– */

.sidebar-nav {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
}

.sidebar-section {
  margin-bottom: 2rem;
}

.sidebar-section-title {
  padding: 0.75rem 1rem;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #666680;
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-item {
  position: relative;
  margin: 0;
  padding: 0;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: all var(--transition-speed) ease;
  border-left: 4px solid transparent;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

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

.sidebar-link.active {
  border-left-color: var(--sidebar-active);
  color: var(--sidebar-active);
  background-color: rgba(0, 191, 255, 0.05);
}

.sidebar-icon {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.sidebar.collapsed .sidebar-link {
  padding: 0.75rem;
  justify-content: center;
}

.sidebar.collapsed .sidebar-section-title,
.sidebar.collapsed .sidebar-link span:not(.sidebar-icon) {
  display: none;
}

.sidebar.collapsed .sidebar-icon {
  width: 24px;
  height: 24px;
}

/* ── SIDEBAR MOBILE OVERLAY ────────────────────────────────– */

.sidebar-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 999;
  display: none;
  opacity: 0;
  transition: opacity var(--transition-speed) ease;
}

.sidebar-overlay.active {
  display: block;
  opacity: 1;
}

/* ── DASHBOARD WIDGET GRID ────────────────────────────────– */

.dashboard-widgets {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.dashboard-widget {
  background: #1a1a2e;
  border: 1px solid rgba(0, 191, 255, 0.1);
  border-radius: 8px;
  padding: 1.5rem;
  cursor: pointer;
  transition: all var(--transition-speed) ease;
  text-decoration: none;
  color: inherit;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.dashboard-widget:hover {
  background: rgba(0, 191, 255, 0.05);
  border-color: rgba(0, 191, 255, 0.3);
  transform: translateY(-4px);
  box-shadow: 0 8px 24px rgba(0, 191, 255, 0.1);
}

.dashboard-widget-icon {
  width: 48px;
  height: 48px;
  background: rgba(0, 191, 255, 0.15);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  color: var(--sidebar-active);
}

.dashboard-widget-title {
  font-size: 16px;
  font-weight: 600;
  color: #f0f0f0;
  margin: 0;
}

.dashboard-widget-description {
  font-size: 13px;
  color: var(--sidebar-text);
  margin: 0;
}

.dashboard-widget-stat {
  font-size: 24px;
  font-weight: 700;
  color: var(--sidebar-active);
  margin: 0;
}

/* ── PORTAL HEADER (WITH PUBLIC NAV) ────────────────────– */

.portal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 2rem;
  background: rgba(10, 10, 15, 0.9);
  border-bottom: 1px solid rgba(0, 191, 255, 0.1);
  gap: 2rem;
  flex-wrap: wrap;
}

.portal-header-left {
  display: flex;
  align-items: center;
  gap: 2rem;
}

.portal-badge {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  background: rgba(0, 191, 255, 0.15);
  color: var(--sidebar-active);
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-left: 0.5rem;
}

.portal-header-right {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  margin-left: auto;
}

.portal-customer-menu {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
}

.portal-customer-name {
  font-size: 14px;
  color: #f0f0f0;
  font-weight: 500;
}

.portal-dropdown-toggle {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--sidebar-text);
  transition: color var(--transition-speed) ease;
}

.portal-customer-menu:hover .portal-dropdown-toggle {
  color: var(--sidebar-active);
}

/* ── RESPONSIVE: TABLET (768px - 1023px) ────────────────── */

@media (max-width: 1023px) {
  .sidebar {
    width: var(--sidebar-width-mobile);
  }

  .workspace-content,
  .portal-content {
    margin-left: var(--sidebar-width-mobile);
  }

  .workspace-content.sidebar-collapsed,
  .portal-content.sidebar-collapsed {
    margin-left: 0;
  }

  .sidebar.collapsed {
    transform: translateX(-100%);
  }
}

/* ── RESPONSIVE: MOBILE (< 768px) ──────────────────────── */

@media (max-width: 767px) {
  :root {
    --workspace-header-height: 56px;
  }

  .sidebar {
    width: 100%;
    height: 100vh;
    top: 0;
    transform: translateX(-100%);
  }

  .sidebar.active {
    transform: translateX(0);
  }

  .sidebar.collapsed {
    transform: translateX(-100%);
  }

  .workspace-content,
  .portal-content {
    margin-left: 0;
    margin-top: var(--workspace-header-height);
    padding: 1.5rem;
  }

  .workspace-header {
    height: var(--workspace-header-height);
    padding: 0 1rem;
  }

  .workspace-header-left {
    gap: 1rem;
  }

  .workspace-header-logo {
    font-size: 16px;
  }

  .workspace-header-module {
    display: none;
  }

  .workspace-header-right {
    gap: 0.75rem;
  }

  .workspace-user-name {
    display: none;
  }

  .sidebar-toggle {
    top: 8px;
    left: 8px;
    width: 36px;
    height: 36px;
  }

  .sidebar-toggle.active {
    border-color: var(--sidebar-active);
  }

  .sidebar-overlay {
    display: none;
  }

  .sidebar-overlay.active {
    display: block;
  }

  .dashboard-widgets {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .portal-header {
    padding: 1rem;
    flex-direction: column;
    align-items: flex-start;
  }

  .portal-header-left {
    width: 100%;
    gap: 1rem;
  }

  .portal-header-right {
    width: 100%;
    margin-left: 0;
  }
}

/* ── UTILITY: SHOW/HIDE BY DEVICE ──────────────────────── */

.show-on-mobile {
  display: none;
}

.hide-on-mobile {
  display: block;
}

@media (max-width: 767px) {
  .show-on-mobile {
    display: block;
  }

  .hide-on-mobile {
    display: none;
  }
}

/* ── SIDEBAR SECTION DIVIDER ────────────────────────────– */

.sidebar-divider {
  height: 1px;
  background: var(--sidebar-border);
  margin: 1rem 0.5rem;
}
