/* LexiCore™ Navigation V2 - Enterprise Legal Platform Styles */
/* Deep navy, muted gold, calm and authoritative */

/* ============================================
   TOP NAVIGATION (Simplified 5-Item)
   ============================================ */

.lexicore-top-nav {
  background: linear-gradient(135deg, #1a2332 0%, #2d3e50 100%);
  border-bottom: 3px solid #b8860b;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.15);
  position: sticky;
  top: 0;
  z-index: 1000;
}

.lexicore-nav-container {
  max-width: 1920px;
  margin: 0 auto;
  padding: 0 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 70px;
  gap: 2rem;
}

.lexicore-nav-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: white;
  font-size: 1.5rem;
  font-weight: 700;
  font-family: 'Georgia', 'Times New Roman', serif;
  letter-spacing: 0.5px;
}

.lexicore-nav-brand i {
  color: #b8860b;
  font-size: 2rem;
}

/* Firm name beside the product name. Deliberately quieter than the brand and
   separated by a rule, so it reads as "you are in this tenant" rather than as
   part of the product's name. Empty until filled, and the :empty rule keeps
   the divider from showing on its own. */
.lexicore-nav-org {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: 0.2px;
  color: rgba(255, 255, 255, 0.82);
  padding-left: 0.75rem;
  border-left: 1px solid rgba(255, 255, 255, 0.28);
  max-width: 22ch;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lexicore-nav-org:empty {
  display: none;
}

@media (max-width: 900px) {
  /* The firm name is the first thing to go when space is tight — the nav
     items are what people came for. */
  .lexicore-nav-org { display: none; }
}

.lexicore-nav-items {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex: 1;
  justify-content: center;
}

.lexicore-nav-item {
  color: rgba(255, 255, 255, 0.9);
  padding: 0.75rem 1.5rem;
  text-decoration: none;
  border-radius: 0.5rem;
  transition: all 0.2s ease;
  font-weight: 500;
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  letter-spacing: 0.3px;
}

.lexicore-nav-item:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #b8860b;
  transform: translateY(-1px);
}

.lexicore-nav-item.active,
.lexicore-nav-item[aria-current="page"] {
  background: rgba(184, 134, 11, 0.2);
  color: #b8860b;
  font-weight: 600;
}

.lexicore-nav-item i {
  font-size: 1.1rem;
}

/* User Info Section (Dropdown Trigger) */
.lexicore-nav-user {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding-left: 1.5rem;
  border-left: 1px solid rgba(255, 255, 255, 0.2);
  position: relative;
  cursor: pointer;
  padding: 0.5rem 1rem 0.5rem 1.5rem;
  border-radius: 0.5rem;
  transition: background 0.2s ease;
}

.lexicore-nav-user:hover {
  background: rgba(255, 255, 255, 0.08);
}

.lexicore-nav-user-info {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.25rem;
}

.lexicore-nav-user-name {
  color: white;
  font-weight: 600;
  font-size: 0.9rem;
}

.lexicore-nav-user-role {
  color: rgba(255, 255, 255, 0.7);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Chevron icon for dropdown */
.lexicore-nav-chevron {
  color: rgba(255, 255, 255, 0.6);
  font-size: 0.75rem;
  transition: transform 0.2s ease;
}

.lexicore-nav-user:hover .lexicore-nav-chevron,
.lexicore-nav-user.open .lexicore-nav-chevron {
  transform: rotate(180deg);
}

/* User Dropdown Menu */
.lexicore-nav-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  min-width: 220px;
  background: white;
  border-radius: 0.75rem;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15), 0 2px 10px rgba(0, 0, 0, 0.08);
  border: 1px solid #e5e7eb;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-8px);
  transition: all 0.2s ease;
  z-index: 1100;
  overflow: hidden;
}

/* Show dropdown on hover OR when open class is set */
.lexicore-nav-user:hover .lexicore-nav-dropdown,
.lexicore-nav-user.open .lexicore-nav-dropdown {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.lexicore-nav-dropdown-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  color: #374151;
  font-size: 0.875rem;
  font-weight: 500;
  text-decoration: none;
  transition: background 0.15s ease;
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}

.lexicore-nav-dropdown-item:hover {
  background: #f3f4f6;
}

.lexicore-nav-dropdown-item i {
  width: 18px;
  text-align: center;
  color: #6b7280;
  font-size: 0.9rem;
}

.lexicore-nav-dropdown-divider {
  height: 1px;
  background: #e5e7eb;
  margin: 0.25rem 0;
}

.lexicore-nav-dropdown-logout {
  color: #dc2626;
}

.lexicore-nav-dropdown-logout:hover {
  background: #fef2f2;
}

.lexicore-nav-dropdown-logout i {
  color: #dc2626;
}

/* Legacy standalone logout button (kept for backward compatibility) */
.lexicore-nav-logout {
  background: #b8860b;
  color: white;
  padding: 0.6rem 1rem;
  border-radius: 0.5rem;
  border: none;
  cursor: pointer;
  font-weight: 500;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.lexicore-nav-logout:hover {
  background: #8b6508;
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(184, 134, 11, 0.3);
}

/* ============================================
   LEFT SIDEBAR (Contextual Practice Mode)
   ============================================ */

.lexicore-sidebar {
  width: 280px;
  background: #f8f9fa;
  border-right: 1px solid #dee2e6;
  height: calc(100vh - 70px);
  position: fixed;
  left: 0;
  top: 70px;
  overflow-y: auto;
  overflow-x: hidden;
  box-shadow: 2px 0 8px rgba(0, 0, 0, 0.05);
  /* Smooth scrolling */
  scroll-behavior: smooth;
  /* Firefox scrollbar styling */
  scrollbar-width: thin;
  scrollbar-color: #b8860b #e9ecef;
}

/* Webkit browsers (Chrome, Safari, Edge) scrollbar styling */
.lexicore-sidebar::-webkit-scrollbar {
  width: 8px;
}

.lexicore-sidebar::-webkit-scrollbar-track {
  background: #e9ecef;
  border-radius: 4px;
}

.lexicore-sidebar::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, #b8860b 0%, #8b6508 100%);
  border-radius: 4px;
  border: 1px solid #e9ecef;
}

.lexicore-sidebar::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, #d4a00a 0%, #b8860b 100%);
}

.lexicore-sidebar-header {
  padding: 1.5rem;
  background: white;
  border-bottom: 2px solid #dee2e6;
}

.lexicore-sidebar-practice-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  border-radius: 0.5rem;
  font-weight: 600;
  font-size: 0.85rem;
  margin-bottom: 1rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.lexicore-sidebar-practice-badge.litigation {
  background: #dbeafe;
  color: #1e40af;
}

.lexicore-sidebar-practice-badge.transactional {
  background: #f3e8ff;
  color: #6b21a8;
}

.lexicore-sidebar-practice-badge.real-estate {
  background: #d1fae5;
  color: #065f46;
}

.lexicore-sidebar-practice-badge.ip {
  background: #fef3c7;
  color: #92400e;
}

.lexicore-sidebar-practice-badge.regulatory {
  background: #fef08a;
  color: #713f12;
}

.lexicore-sidebar-practice-badge.investigations {
  background: #fee2e2;
  color: #991b1b;
}

.lexicore-sidebar-matter-info {
  color: #6c757d;
}

.lexicore-sidebar-nav {
  padding: 1rem 0;
  /* Ensure nav doesn't cut off content */
  padding-bottom: 2rem;
}

/* Sidebar content wrapper for extra scrolling support */
.lexicore-sidebar-content {
  padding-bottom: 2rem;
  min-height: 100%;
}

.lexicore-sidebar-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.875rem 1.5rem;
  color: #495057;
  text-decoration: none;
  transition: all 0.2s ease;
  font-weight: 500;
  font-size: 0.9rem;
  border-left: 3px solid transparent;
}

.lexicore-sidebar-item:hover {
  background: #e9ecef;
  color: #1a2332;
  border-left-color: #b8860b;
}

.lexicore-sidebar-item.active {
  background: #fff;
  color: #1a2332;
  border-left-color: #b8860b;
  font-weight: 600;
}

.lexicore-sidebar-item i {
  font-size: 1rem;
  width: 20px;
  text-align: center;
  opacity: 0.7;
}

.lexicore-sidebar-item.active i {
  opacity: 1;
  color: #b8860b;
}

/* ============================================
   SIDEBAR ITEM NESTED STRUCTURE
   (icon + content with label/description)
   ============================================ */

.lexicore-sidebar-item-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  min-width: 36px;
  border-radius: 8px;
  background: #f0f0f0;
  font-size: 14px;
  color: #6c757d;
}

.lexicore-sidebar-item.active .lexicore-sidebar-item-icon {
  background: #d4af37;
  color: #fff;
}

.lexicore-sidebar-item:hover .lexicore-sidebar-item-icon {
  background: #e2e6ea;
}

.lexicore-sidebar-item-content {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
}

.lexicore-sidebar-item-label {
  font-size: 0.875rem;
  font-weight: inherit;
  line-height: 1.3;
  color: inherit;
}

.lexicore-sidebar-item-description {
  font-size: 0.75rem;
  color: #868e96;
  line-height: 1.3;
  font-weight: 400;
}

.lexicore-sidebar-item.active .lexicore-sidebar-item-description {
  color: #666;
}

/* ============================================
   LEGAL NOTICE (Refined & Unobtrusive)
   ============================================ */

.lexicore-legal-notice {
  background: #fffbf0;
  border-bottom: 1px solid #e5d7a8;
  padding: 0.75rem 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.85rem;
  color: #856404;
}

.lexicore-legal-notice-content {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.lexicore-legal-notice-content i {
  color: #b8860b;
  font-size: 1.1rem;
}

.lexicore-legal-notice-close {
  background: none;
  border: none;
  color: #856404;
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  opacity: 0.7;
  transition: opacity 0.2s ease;
}

.lexicore-legal-notice-close:hover {
  opacity: 1;
}

/* ============================================
   MAIN CONTENT AREA (With Sidebar)
   ============================================ */

.lexicore-main-content {
  margin-left: 280px;
  padding: 2rem;
  min-height: calc(100vh - 70px);
  background: #ffffff;
}

.lexicore-main-content.no-sidebar {
  margin-left: 0;
}

/* ============================================
   RESPONSIVE DESIGN
   ============================================ */

@media (max-width: 1024px) {
  .lexicore-nav-brand {
    font-size: 1.2rem;
  }
  
  .lexicore-nav-brand .text-xs {
    display: none;
  }
  
  .lexicore-sidebar {
    width: 240px;
  }
  
  .lexicore-main-content {
    margin-left: 240px;
  }
}

@media (max-width: 1024px) {
  .lexicore-nav-container {
    padding: 0 1rem;
    position: relative;
  }

  /* Hamburger menu replaces icon-only nav */
  .lexicore-nav-hamburger {
    display: flex;
  }

  .lexicore-nav-items {
    display: none;
    position: absolute;
    top: 70px;
    left: 0;
    right: 0;
    background: linear-gradient(135deg, #1a2332 0%, #2d3e50 100%);
    flex-direction: column;
    padding: 0.5rem 1rem 1rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    z-index: 999;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
  }

  .lexicore-nav-items.mobile-nav-open {
    display: flex;
  }

  .lexicore-nav-item {
    padding: 0.875rem 1rem;
    width: 100%;
    justify-content: flex-start;
  }

  .lexicore-nav-item span {
    display: inline;
  }

  .lexicore-nav-user-info {
    display: none;
  }

  .lexicore-sidebar {
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    z-index: 900;
  }

  .lexicore-sidebar.mobile-open {
    transform: translateX(0);
    box-shadow: 2px 0 12px rgba(0, 0, 0, 0.15);
  }

  .lexicore-main-content {
    margin-left: 0;
    padding: 1rem;
  }

  /* Phase 1: Override hardcoded inline margin-left: 280px on 30+ pages */
  [style*="margin-left: 280px"],
  [style*="margin-left:280px"],
  [style*="margin-left: 260px"],
  [style*="margin-left:260px"] {
    margin-left: 0 !important;
    max-width: 100% !important;
  }

  /* Collapse the page-internal sidebar container (used on billing,
     litigation, and other pages that build a flex layout around
     <div id="practice-sidebar" style="width:280px;min-width:280px;...">)
     so the main content fills the tablet/phone viewport. The sidebar
     slides in as an overlay via mobile-open instead. */
  #practice-sidebar {
    width: 0 !important;
    min-width: 0 !important;
    padding: 0 !important;
    border-right: none !important;
    overflow: visible !important;
  }

  /* Phase 4: Minimum 44px touch targets (WCAG 2.5.5) */
  button,
  a.btn,
  .btn,
  select,
  .lexicore-nav-item,
  .lexicore-sidebar-item,
  .lexicore-nav-dropdown-item {
    min-height: 44px;
  }

  /* Phase 5: Modal mobile rules */
  .modal-content,
  [class*="modal"] > div:first-child {
    width: 95vw !important;
    max-width: 95vw !important;
    max-height: 90vh !important;
    overflow-y: auto !important;
  }

  /* Phase 6: Legal notice wrapping */
  .lexicore-legal-notice {
    flex-direction: column;
    padding: 0.5rem 1rem;
    font-size: 0.8rem;
    gap: 0.5rem;
    text-align: center;
  }

  /* Sidebar toggle button visibility */
  .lexicore-sidebar-toggle {
    display: flex;
  }
}

/* Extra-small screens */
@media (max-width: 480px) {
  .metrics-grid,
  .stats-grid,
  .stat-grid {
    grid-template-columns: 1fr !important;
  }
}

/* ============================================
   HAMBURGER MENU BUTTON (hidden on desktop)
   ============================================ */

.lexicore-nav-hamburger {
  display: none;
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.9);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0.5rem;
  border-radius: 0.375rem;
  transition: background 0.2s ease;
  min-width: 44px;
  min-height: 44px;
  align-items: center;
  justify-content: center;
}

.lexicore-nav-hamburger:hover {
  background: rgba(255, 255, 255, 0.1);
}

/* ============================================
   SIDEBAR TOGGLE BUTTON (mobile, bottom-left)
   ============================================ */

.lexicore-sidebar-toggle {
  position: fixed;
  bottom: 1.5rem;
  left: 1.5rem;
  width: 3rem;
  height: 3rem;
  background: linear-gradient(135deg, #1a2332 0%, #2d3e50 100%);
  color: #ffffff;
  border: none;
  border-radius: 50%;
  font-size: 1.25rem;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
}

.lexicore-sidebar-toggle:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.3);
}

/* Show sidebar toggle on tablet/phone (iPad, iPhone).
   Placed AFTER the base rule so source-order cascade picks this up. */
@media (max-width: 1024px) {
  .lexicore-sidebar-toggle {
    display: flex !important;
  }
}

/* ============================================
   ACCESSIBILITY
   ============================================ */

.lexicore-nav-item:focus,
.lexicore-sidebar-item:focus,
.lexicore-nav-logout:focus,
.lexicore-nav-dropdown-item:focus,
.lexicore-legal-notice-close:focus {
  outline: 2px solid #b8860b;
  outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  .lexicore-top-nav {
    border-bottom-width: 4px;
  }
  
  .lexicore-nav-item,
  .lexicore-sidebar-item {
    font-weight: 600;
  }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
  .lexicore-nav-item,
  .lexicore-sidebar-item,
  .lexicore-nav-logout,
  .lexicore-sidebar {
    transition: none;
  }
}

/* ============================================================ */
/* FIX: Tailwind CSS v4 @layer base { * { margin:0; padding:0 } }
   overrides inline styles in some browsers due to cascade layer
   resolution order. This unlayered CSS file has higher cascade
   priority than @layer base, restoring the intended sidebar layout.
   SCOPED to desktop (>=1025px) so iPad/iPhone don't inherit the
   280px sidebar offset when the sidebar is collapsed.
   ============================================================ */
@media (min-width: 1025px) {
  [style*="margin-left: 280px"] {
    margin-left: 280px !important;
    max-width: calc(100% - 280px) !important;
  }
  [style*="padding: 2rem"] {
    padding: 2rem !important;
  }
  [style*="padding: 0.75rem 2rem"] {
    padding: 0.75rem 2rem !important;
  }
  [style*="padding: 0.5rem 2rem"] {
    padding: 0.5rem 2rem !important;
  }
  [style*="padding: 0 2rem"] {
    padding: 0 2rem 2rem 2rem !important;
  }
  [style*="padding-right: 340px"] {
    padding-right: 340px !important;
  }
}
