/*-- scss:defaults --*/

/*-- scss:rules --*/

/* ============================================================================
   MOBILE CORE - Combined Mobile Styles for ALL Analyzer Apps
   ============================================================================
   
   INCLUDES:
   - Hamburger menu button
   - Slide-out sidebar navigation
   - Nav overlay
   - Mobile content adjustments
   - Mobile account section
   - Touch enhancements
   - Print styles
   - Desktop sidebar visibility
   
   LOAD ORDER:
   1. theme-core.css
   2. analyzer-layout.css
   3. mobile-core.css (THIS FILE - load LAST for shared styles)
   4. [app].css (app-specific only)
   
   @version 3.0.0 (Cleaned - removed duplicate patches)
   @author Second Difference Solutions, LLC
   @updated January 2026
   ============================================================================ */


/* ============================================================================
   CSS VARIABLES - Mobile Theming
   ============================================================================ */

:root {
  --sidebar-width: 280px;
  --sidebar-transition: 0.3s ease;
  --topbar-height: 56px;
  
  /* Desktop sidebar */
  --sidebar-bg: var(--sds-navy, #002855);
  --sidebar-text: #ffffff;
  --sidebar-accent: var(--sds-gold, #EAAA00);
  --sidebar-overlay: rgba(0, 0, 0, 0.5);
  
  /* Mobile sidebar (light theme) */
  --mobile-sidebar-bg: #ffffff;
  --mobile-sidebar-text: #1f2937;
  --mobile-sidebar-text-muted: #6b7280;
  --mobile-sidebar-border: #e5e7eb;
  --mobile-sidebar-hover: #f3f4f6;
  --mobile-sidebar-active: #eff6ff;
  --mobile-sidebar-active-border: var(--sds-navy, #002855);
}


/* ============================================================================
   1. HAMBURGER BUTTON
   ============================================================================ */

.hamburger-btn {
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 5px;
  width: 40px;
  height: 40px;
  padding: 8px;
  background: transparent;
  border: none;
  cursor: pointer;
  z-index: 1002;
}

.hamburger-btn span {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--sidebar-accent);
  border-radius: 2px;
  transition: transform var(--sidebar-transition), opacity 0.2s ease;
}

/* Animated X when open */
.hamburger-btn.open span:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}

.hamburger-btn.open span:nth-child(2) {
  opacity: 0;
}

.hamburger-btn.open span:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}


/* ============================================================================
   2. NAV OVERLAY
   ============================================================================ */

.nav-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--sidebar-overlay);
  z-index: 1000;
  opacity: 0;
  transition: opacity var(--sidebar-transition);
}

.nav-overlay.visible {
  display: block;
  opacity: 1;
}


/* ============================================================================
   3. QUARTO OVERRIDES - Remove default Quarto elements
   ============================================================================ */

html, body {
  margin: 0 !important;
  padding: 0 !important;
}

body.nav-fixed {
  padding-top: 0 !important;
}

#quarto-header,
.quarto-title-block,
header#title-block-header,
header.quarto-title-block {
  display: none !important;
  height: 0 !important;
  margin: 0 !important;
  padding: 0 !important;
}

#quarto-content {
  padding: 0 !important;
  margin: 0 !important;
}

.quarto-container {
  max-width: 100% !important;
  padding: 0 !important;
}


/* ============================================================================
   4. MOBILE STYLES (max-width: 768px)
   ============================================================================ */

@media (max-width: 768px) {
  
  /* ----- Show Hamburger ----- */
  .hamburger-btn {
    display: flex !important;
  }
  
  
  /* ----- Hide Topbar Items (moved to sidebar) ----- */
  .topbar-center,
  .topbar-right {
    display: none !important;
  }
  
  .topbar-left {
    display: flex !important;
    align-items: center;
    gap: 0.5rem;
  }
  
  
  /* ----- Slide-Out Sidebar ----- */
  .app-sidebar,
  .analyzer-sidebar {
    position: fixed !important;
    top: var(--topbar-height, 56px) !important;
    left: 0 !important;
    width: var(--sidebar-width) !important;
    height: calc(100vh - var(--topbar-height, 56px)) !important;
    background: var(--mobile-sidebar-bg) !important;
    border-right: 1px solid var(--mobile-sidebar-border) !important;
    z-index: 1001 !important;
    display: flex !important;
    flex-direction: column !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    transform: translateX(-100%) !important;
    transition: transform var(--sidebar-transition) !important;
    box-shadow: none !important;
  }
  
  .app-sidebar.open,
  .analyzer-sidebar.open {
    transform: translateX(0) !important;
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.15) !important;
  }
  
  
  /* ----- Sidebar Header with Close Button ----- */
  .sidebar-header {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    padding: 1rem !important;
    border-bottom: 1px solid var(--mobile-sidebar-border) !important;
    flex-shrink: 0 !important;
    background: var(--mobile-sidebar-bg) !important;
  }
  
  .sidebar-title {
    font-size: 1rem !important;
    font-weight: 600 !important;
    color: var(--mobile-sidebar-text) !important;
    margin: 0 !important;
  }
  
  .sidebar-close {
    width: 32px !important;
    height: 32px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    background: none !important;
    border: none !important;
    color: #6b7280 !important;
    cursor: pointer !important;
    border-radius: 4px !important;
    padding: 0 !important;
    flex-shrink: 0 !important;
  }
  
  .sidebar-close:hover {
    background: var(--mobile-sidebar-hover) !important;
    color: #111827 !important;
  }
  
  
  /* ----- User Email Area ----- */
  .sidebar-user {
    display: block !important;
    padding: 0.75rem 1rem !important;
    font-size: 0.8125rem !important;
    color: var(--mobile-sidebar-text-muted) !important;
    border-bottom: 1px solid var(--mobile-sidebar-border) !important;
    background: var(--mobile-sidebar-bg) !important;
  }
  
  
  /* ----- QB Section in Mobile Sidebar ----- */
  .sidebar-qb-section {
    padding: 0.75rem 1rem !important;
    border-bottom: 1px solid var(--mobile-sidebar-border) !important;
    background: #f9fafb !important;
  }
  
  .sidebar-qb-status {
    display: flex !important;
    align-items: center !important;
    gap: 0.5rem !important;
    font-size: 0.8125rem !important;
    color: #6b7280 !important;
    margin-bottom: 0.5rem !important;
  }
  
  .sidebar-qb-status .qb-dot {
    width: 8px !important;
    height: 8px !important;
    border-radius: 50% !important;
    background: #9ca3af !important;
    flex-shrink: 0 !important;
  }
  
  .sidebar-qb-status .qb-dot.connected {
    background: #10b981 !important;
  }
  
  .sidebar-qb-connect {
    margin-top: 0.5rem !important;
  }
  
  .sidebar-qb-connect img {
    display: block !important;
    max-width: 100% !important;
    height: auto !important;
    cursor: pointer !important;
  }
  
  .sidebar-qb-connect .btn-qb-disconnect {
    width: 100% !important;
    padding: 0.5rem 1rem !important;
    font-size: 0.8125rem !important;
    font-weight: 500 !important;
    color: #dc2626 !important;
    background: #fef2f2 !important;
    border: 1px solid #fecaca !important;
    border-radius: 6px !important;
    cursor: pointer !important;
  }
  
  .sidebar-qb-connect .btn-qb-disconnect:hover {
    background: #fee2e2 !important;
  }
  
  
  /* ----- Sidebar Navigation ----- */
  .sidebar-nav {
    flex: 1 1 auto !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    padding: 0.5rem 0 !important;
    min-height: 0 !important;
    -webkit-overflow-scrolling: touch;
  }
  
  .nav-btn {
    display: block !important;
    width: 100% !important;
    padding: 0.75rem 1rem !important;
    background: transparent !important;
    border: none !important;
    border-left: 3px solid transparent !important;
    text-align: left !important;
    cursor: pointer !important;
    color: var(--mobile-sidebar-text) !important;
    font-size: 0.875rem !important;
    font-weight: 500 !important;
    transition: background 0.15s ease !important;
    min-height: 44px !important;
  }
  
  .nav-btn:hover {
    background: var(--mobile-sidebar-hover) !important;
  }
  
  .nav-btn.active {
    background: var(--mobile-sidebar-active) !important;
    color: var(--sds-navy, #002855) !important;
    border-left-color: var(--mobile-sidebar-active-border) !important;
    font-weight: 600 !important;
  }
  
  .nav-icon {
    display: none !important;
  }
  
  .nav-label {
    display: inline !important;
  }
  
  
  /* ----- Sign Out Section ----- */
  .sidebar-signout {
    padding: 1rem !important;
    margin-top: auto !important;
    border-top: 1px solid var(--mobile-sidebar-border) !important;
    flex-shrink: 0 !important;
  }
  
  .sidebar-signout-btn {
    width: 100% !important;
    padding: 0.75rem 1rem !important;
    font-size: 0.875rem !important;
    font-weight: 500 !important;
    color: #dc2626 !important;
    background: #fef2f2 !important;
    border: 1px solid #fecaca !important;
    border-radius: 6px !important;
    cursor: pointer !important;
  }
  
  .sidebar-signout-btn:hover {
    background: #fee2e2 !important;
  }
  
  
  /* ----- Hide Desktop Sidebar Elements ----- */
  .sidebar-footer {
    display: none !important;
  }
  
  
  /* ----- Topbar Adjustments ----- */
  .app-topbar {
    padding: 0.75rem 1rem;
    gap: 0.5rem;
    position: relative;
    z-index: 999;
  }
  
  .app-title {
    font-size: 1.125rem;
  }
  
  .app-subtitle {
    display: none;
  }
  
  
  /* ----- Main Content ----- */
  .app-main,
  .analyzer-main {
    padding: 1rem;
  }
  
  .section-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }
  
  .section-header h2 {
    font-size: 1.125rem;
  }
  
  
  /* ----- Metrics Grid ----- */
  .metrics-grid {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }
  
  .metric-card {
    padding: 1rem;
  }
  
  .metric-value {
    font-size: 1.375rem;
  }
  
  
  /* ----- Sub-tabs ----- */
  .sub-tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding: 0.25rem;
    gap: 0.25rem;
  }
  
  .sub-tabs::-webkit-scrollbar {
    display: none;
  }
  
  .sub-tab {
    flex: 0 0 auto;
    min-width: auto;
    padding: 0.5rem 0.875rem;
    font-size: 0.8125rem;
    white-space: nowrap;
    min-height: 44px;
  }
  
  
  /* ----- Action Buttons ----- */
  .action-buttons {
    flex-direction: column;
  }
  
  .btn-action {
    width: 100%;
    justify-content: center;
    min-height: 44px;
  }
  
  
  /* ----- Stats Grid ----- */
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
  }
  
  .stat-card {
    padding: 0.875rem;
  }
  
  .stat-value {
    font-size: 1.125rem;
  }
  
  
  /* ----- Info/Settings Cards ----- */
  .info-card,
  .settings-card {
    padding: 1rem;
  }
  
  .settings-grid-layout {
    grid-template-columns: 1fr;
  }
  
  
  /* ----- Touch Enhancements ----- */
  .nav-btn:active,
  .sub-tab:active,
  .btn-action:active {
    transform: scale(0.98);
  }
  
  .app-main,
  .analyzer-main,
  .sub-tabs {
    -webkit-overflow-scrolling: touch;
  }
}


/* ============================================================================
   5. SMALL MOBILE (max-width: 480px)
   ============================================================================ */

@media (max-width: 480px) {
  
  :root {
    --sidebar-width: 260px;
  }
  
  .app-topbar {
    padding: 0.625rem 0.75rem;
  }
  
  .app-title {
    font-size: 1rem;
  }
  
  .app-main,
  .analyzer-main {
    padding: 0.75rem;
  }
  
  .metric-card {
    padding: 0.875rem;
  }
  
  .metric-value {
    font-size: 1.25rem;
  }
  
  .stats-grid {
    grid-template-columns: 1fr;
  }
  
  .nav-btn {
    padding: 0.625rem 1rem !important;
    font-size: 0.8125rem !important;
    min-height: 40px !important;
  }
}


/* ============================================================================
   6. LANDSCAPE MOBILE
   ============================================================================ */

@media (max-width: 768px) and (orientation: landscape) {
  
  :root {
    --topbar-height: 44px;
  }
  
  .metrics-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .stats-grid {
    grid-template-columns: repeat(3, 1fr);
  }
  
  .app-sidebar,
  .analyzer-sidebar {
    top: 44px !important;
    height: calc(100vh - 44px) !important;
  }
  
  .nav-btn {
    padding: 0.5rem 1rem !important;
    min-height: 36px !important;
  }
}


/* ============================================================================
   7. PRINT STYLES
   ============================================================================ */

@media print {
  
  .app-topbar,
  .app-sidebar,
  .analyzer-sidebar,
  .nav-overlay,
  .hamburger-btn,
  .sidebar-signout,
  .btn-action,
  .sub-tabs {
    display: none !important;
  }
  
  .app-layout,
  .analyzer-layout {
    display: block;
  }
  
  .app-main,
  .analyzer-main {
    padding: 0;
    width: 100%;
  }
  
  .content-section,
  .content-view {
    display: block !important;
    page-break-after: always;
  }
  
  .metric-card,
  .stat-card,
  .info-card,
  .settings-card {
    box-shadow: none;
    border: 1px solid #ccc;
  }
}


/* ============================================================================
   8. REDUCED MOTION
   ============================================================================ */

@media (prefers-reduced-motion: reduce) {
  
  .app-sidebar,
  .analyzer-sidebar,
  .nav-overlay,
  .hamburger-btn span,
  .nav-btn,
  .sub-tab,
  .btn-action {
    transition: none !important;
  }
  
  .spinner,
  .spinner-small {
    animation: none;
    border-top-color: var(--sds-navy, #002855);
  }
}


/* ============================================================================
   9. SAFE AREA INSETS (Notched Devices)
   ============================================================================ */

@supports (padding: env(safe-area-inset-left)) {
  
  @media (max-width: 768px) {
    
    .app-topbar {
      padding-left: max(1rem, env(safe-area-inset-left));
      padding-right: max(1rem, env(safe-area-inset-right));
    }
    
    .app-sidebar,
    .analyzer-sidebar {
      padding-left: env(safe-area-inset-left);
    }
    
    .app-main,
    .analyzer-main {
      padding-left: max(1rem, env(safe-area-inset-left));
      padding-right: max(1rem, env(safe-area-inset-right));
      padding-bottom: max(1rem, env(safe-area-inset-bottom));
    }
  }
}


/* ============================================================================
   10. ACCESSIBILITY - Focus States
   ============================================================================ */

.hamburger-btn:focus {
  outline: 2px solid var(--sidebar-accent);
  outline-offset: 2px;
}

.hamburger-btn:focus:not(:focus-visible) {
  outline: none;
}

.nav-btn:focus {
  outline: 2px solid var(--sidebar-accent);
  outline-offset: -2px;
}

.nav-btn:focus:not(:focus-visible) {
  outline: none;
}

@media (prefers-contrast: high) {
  
  .nav-btn,
  .sub-tab,
  .metric-card,
  .stat-card {
    border: 2px solid currentColor;
  }
  
  *:focus {
    outline: 3px solid currentColor;
    outline-offset: 2px;
  }
}


/* ============================================================================
   11. DESKTOP LAYOUT (769px+) - Sidebar Visible
   ============================================================================ */

@media (min-width: 769px) {
  
  /* Sidebar VISIBLE on desktop - 25% width */
  .app-sidebar,
  .analyzer-sidebar {
    position: relative !important;
    left: 0 !important;
    width: 25% !important;              /* CHANGED: Match analyzer-layout.css */
    min-width: 220px !important;        /* CHANGED: Match analyzer-layout.css */
    max-width: 320px !important;        /* ADD: Match analyzer-layout.css */
    display: flex !important;
    flex-direction: column !important;
    height: calc(100vh - 60px) !important;
    transform: none !important;
    background: var(--gray-50, #f7fafc) !important;
    border-right: 1px solid var(--gray-200, #e5e7eb) !important;
    border-left: none !important;       /* ADD: Explicitly no left border */
    overflow-y: auto !important;
  }
  /* Horizontal flex layout */
  .app-layout,
  .analyzer-layout {
    display: flex !important;
    flex-direction: row !important;
  }
  

  /* Main content fills remaining 75% */
  .app-main,
  .analyzer-main {
    flex: 1 !important;
    width: 75% !important;              /* ADD: Explicit 75% width */
    margin-left: 0 !important;
    min-width: 0 !important;
    background: var(--gray-50, #f9fafb) !important;  /* ADD: Ensure no blue gaps */
  }
  
  /* Hide mobile-only elements */
  .hamburger-btn,
  .nav-overlay,
  .sidebar-header,
  .sidebar-close,
  .sidebar-user,
  .sidebar-signout,
  .sidebar-qb-section {
    display: none !important;
  }
  
  /* Show desktop topbar items */
  .topbar-center,
  .topbar-right {
    display: flex !important;
  }
  
  /* Show desktop sidebar footer */
  .sidebar-footer {
    display: flex !important;
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--gray-200, #e5e7eb);
    gap: 1rem;
    margin-top: auto;
  }
  
  /* Desktop nav styling */
  .sidebar-nav {
    display: flex !important;
    flex-direction: column !important;
    padding: 0.5rem 0 !important;
    flex: 1 !important;
    overflow-y: auto !important;
  }
  
  .nav-btn {
    display: flex !important;
    align-items: center !important;
    width: 100% !important;
    padding: 0.75rem 1.5rem !important;
    border: none !important;
    border-left: none !important;
    background: transparent !important;
    text-align: left !important;
    cursor: pointer !important;
    color: var(--gray-600, #4a5568) !important;
    font-size: 0.9rem !important;
    font-weight: 500 !important;
    border-radius: 0 !important;
    transform: none !important;
  }
  
  .nav-btn:hover {
    background: var(--gray-100, #f3f4f6) !important;
    color: var(--sds-navy, #002855) !important;
  }
  
  .nav-btn.active {
    background: linear-gradient(90deg, var(--sds-navy, #002855) 0%, var(--sds-navy-light, #003d7a) 100%) !important;
    color: white !important;
    border-left: none !important;
  }
  
  .nav-label {
    display: inline !important;
  }
}


/* ============================================================================
   END OF MOBILE-CORE.CSS
   ============================================================================ */