/* ==========================================================
   Midas CRM — Layout: Sidebar, Header, Page Shell
   Matched to LC Product Pricing aesthetic
   ========================================================== */

/* === APP SHELL === */
.app-shell {
  display: flex;
  min-height: 100vh;
}

/* === SIDEBAR === */
.sidebar {
  position: fixed;
  top: 10px;
  left: 10px;
  width: var(--sidebar-width);
  height: calc(100vh - 20px);
  background: linear-gradient(180deg, var(--teal) 0%, var(--teal-light) 50%, var(--teal) 100%);
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: width 0.3s ease, transform 0.3s ease;
  overflow: hidden;
  border-radius: 16px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.15);
}

.sidebar-logo {
  padding: 24px 24px 16px;
}

.sidebar-logo-lockup {
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-mark {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  mix-blend-mode: lighten;
  border-radius: 4px;
}

.sidebar-logo h1 {
  color: var(--white);
  font-size: 22px;
  font-weight: 400;
  letter-spacing: 6px;
  white-space: nowrap;
  font-family: Georgia, 'Times New Roman', serif;
}

.sidebar-logo .sidebar-tagline {
  color: var(--gold-deep, #7A5E1E);
  font-size: 7px;
  letter-spacing: 1.8px;
  text-transform: uppercase;
  margin-top: 4px;
  white-space: nowrap;
}

.gold-rule {
  height: 2px;
  background: linear-gradient(90deg, var(--gold-mid, #B8902E) 0%, var(--gold) 30%, var(--gold-light) 60%, transparent 100%);
  margin: 0 24px 12px;
}

/* Nav Links */
.sidebar-nav {
  flex: 1;
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-section-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: rgba(255,255,255,0.35);
  padding: 16px 12px 6px;
  white-space: nowrap;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 6px;
  color: rgba(255,255,255,0.75);
  font-size: 14px;
  font-weight: 400;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
  text-decoration: none;
  position: relative;
}

.nav-link svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  opacity: 0.75;
}

.nav-link:hover {
  background: rgba(255,255,255,0.1);
  color: var(--white);
}

.nav-link:hover svg { opacity: 1; }

.nav-link.active {
  background: rgba(255,255,255,0.15);
  color: var(--gold);
  font-weight: 700;
}

.nav-link.active svg { opacity: 1; color: var(--gold); }

.nav-link.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 6px;
  bottom: 6px;
  width: 3px;
  background: var(--gold);
  border-radius: 0 2px 2px 0;
}

.nav-link.disabled {
  opacity: 0.3;
  pointer-events: none;
}

.nav-badge {
  margin-left: auto;
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 10px;
  background: rgba(255,255,255,0.15);
  color: rgba(255,255,255,0.5);
  font-weight: 700;
  letter-spacing: 0.5px;
  white-space: nowrap;
}

/* --- Collapsible Nav Groups (Tools, Reports) --- */
.nav-group {
  margin: 2px 0;
}

.nav-group-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  border: none;
  border-radius: 8px;
  background: none;
  color: rgba(255,255,255,0.6);
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s ease;
}

.nav-group-toggle:hover {
  background: rgba(255,255,255,0.1);
  color: var(--white);
}

.nav-group-icon {
  display: flex;
  width: 20px;
  height: 20px;
}

.nav-group-icon svg {
  width: 20px;
  height: 20px;
  opacity: 0.5;
}

.nav-group-toggle:hover .nav-group-icon svg { opacity: 1; }

.nav-group-arrow {
  margin-left: auto;
  display: flex;
  transition: transform 0.2s ease;
}

.nav-group-arrow svg {
  width: 14px;
  height: 14px;
  opacity: 0.4;
}

.nav-group-toggle.open .nav-group-arrow {
  transform: rotate(90deg);
}

.nav-group-items {
  display: none;
  padding-left: 8px;
}

.nav-group-toggle.open + .nav-group-items {
  display: block;
  animation: navGroupOpen 0.2s ease;
}

@keyframes navGroupOpen {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

.nav-link.nav-sub {
  padding-left: 20px;
  font-size: 12.5px;
}

.nav-link.nav-sub svg {
  width: 16px;
  height: 16px;
}

/* Sidebar Footer — Settings + User pinned to bottom */
.sidebar-footer {
  margin-top: auto;
  border-top: 1px solid rgba(255,255,255,0.1);
  padding-top: 8px;
}

.sidebar-user {
  padding: 12px 16px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.sidebar-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--gold);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: var(--teal-dark);
  flex-shrink: 0;
}

.sidebar-user-info { overflow: hidden; }

.sidebar-user-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--white);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user-role {
  font-size: 11px;
  color: rgba(255,255,255,0.5);
  text-transform: capitalize;
  white-space: nowrap;
}

.sidebar-user-menu {
  display: none;
  padding: 4px 12px 12px;
}

.sidebar-user-menu.visible {
  display: block;
  animation: userMenuIn 0.15s ease;
}

@keyframes userMenuIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.sidebar-user-menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 10px 14px;
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 8px;
  background: rgba(255,255,255,0.08);
  color: rgba(255,255,255,0.8);
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s ease;
}

.sidebar-user-menu-item:hover {
  background: rgba(255,255,255,0.15);
  color: white;
  border-color: rgba(255,255,255,0.25);
}

.sidebar-user-menu-item svg {
  stroke: currentColor;
  opacity: 0.7;
}

/* === MAIN CONTENT === */
.main-content {
  flex: 1;
  margin-left: calc(var(--sidebar-width) + 20px);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: margin-left 0.3s ease;
  animation: fadeInContent 0.18s ease;
}

@keyframes fadeInContent {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* === PAGE HEADER (matches product-pricing .header style) === */
.page-header {
  height: var(--header-height);
  background: var(--white);
  border-bottom: 1px solid var(--border);
  padding: 0 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
}

.page-header-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.hamburger {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  color: var(--dark-gray);
}

.hamburger svg { width: 22px; height: 22px; }

.page-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--dark-gray);
  letter-spacing: 0.5px;
}

.breadcrumbs {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--light-gray);
}

.breadcrumbs a { color: var(--teal); font-weight: 700; }
.breadcrumbs .sep { color: var(--border); }

.page-header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.btn-external {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  text-decoration: none;
  color: var(--text-dark);
  border-color: var(--border-light);
}

.btn-external:hover {
  border-color: var(--teal);
  color: var(--teal);
  background: var(--teal-pale);
}

.btn-external svg {
  opacity: 0.6;
}

.btn-external:hover svg {
  opacity: 1;
}

/* === PAGE BODY === */
.page-body {
  flex: 1;
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
  padding: 32px 24px;
}

/* === MOBILE OVERLAY === */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 99;
}

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

/* === RESPONSIVE === */

/* Tablet: collapsed sidebar */
@media (max-width: 1023px) {
  .sidebar { width: var(--sidebar-collapsed); }

  .sidebar-logo h1,
  .sidebar-logo .sidebar-tagline,
  .gold-rule,
  .nav-section-label,
  .nav-link span,
  .nav-badge,
  .sidebar-user-info { display: none; }

  .sidebar-logo { padding: 20px 0; display: flex; justify-content: center; }
  .sidebar-nav { padding: 8px 6px; align-items: center; }
  .nav-link { justify-content: center; padding: 10px; }
  .nav-link.active::before { display: none; }
  .sidebar-user { justify-content: center; padding: 12px 6px; }

  .main-content { margin-left: calc(var(--sidebar-collapsed) + 20px); }
}

/* Mobile: drawer sidebar */
@media (max-width: 767px) {
  .sidebar {
    width: var(--sidebar-width);
    transform: translateX(-100%);
  }

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

  .sidebar-logo h1,
  .sidebar-logo .sidebar-tagline,
  .gold-rule,
  .nav-section-label,
  .nav-link span,
  .nav-badge,
  .sidebar-user-info { display: revert; }

  .sidebar-logo { padding: 24px 24px 16px; display: block; justify-content: unset; }
  .sidebar-nav { padding: 8px 12px; align-items: stretch; }
  .nav-link { justify-content: flex-start; padding: 10px 12px; }
  .nav-link.active::before { display: block; }
  .sidebar-user { justify-content: flex-start; padding: 16px; }

  .main-content { margin-left: 0; }

  .hamburger { display: flex; }

  .page-body { padding: 20px 16px; }
  .page-header { padding: 0 16px; }
}
