/* ============================================================================
   ANALYZER LAYOUT - Shared CSS for All Analyzer Applications
   ============================================================================
   
   CONSOLIDATED shared layout for BizAnalyzer, EconAnalyzer, MarketAnalyzer.
   
   FEATURES:
   - Navy topbar with GOLD title
   - Sidebar with optional gold accent border
   - Gradient nav buttons with gold active icons
   - Bootstrap override layer
   
   DEPENDENCIES: Import AFTER theme-core.css
   
   USAGE:
   css:
     - /apps/js/shared/theme-core.css
     - /apps/js/shared/analyzer-layout.css
     - /apps/js/[app]/[app].css
   
   @version 3.0.0 (Consolidated with gold accents)
   @author Second Difference Solutions, LLC
   @updated January 2026
   ============================================================================ */


/* ============================================================================
   QUARTO OVERRIDES - Hide Quarto-generated elements for custom app layout
   ============================================================================
   
   When using page-layout: custom, Quarto still renders header elements.
   These rules ensure complete removal with no residual spacing.
   
   @added 2025-01-12
   @updated 2025-01-12 - Added footer, inline style override
   ============================================================================ */

html, body {
  margin: 0 !important;
  padding: 0 !important;
}

/* Prevent Quarto JS from adding body padding via data-bs-offset */
/* Target all possible body class combinations */
body,
body[data-bs-offset],
body.nav-fixed,
body.fullcontent,
body.quarto-light,
body.quarto-dark {
  padding-top: 0 !important;
  margin-top: 0 !important;
}

/* Override any inline style attribute on body */
body[style*="padding-top"] {
  padding-top: 0 !important;
}

/* Fully collapse all Quarto header/nav elements */
#quarto-header,
#quarto-search,
#quarto-search-results,
.quarto-title-block,
header#title-block-header,
header.quarto-title-block,
.navbar,
.quarto-title-meta {
  display: none !important;
  height: 0 !important;
  max-height: 0 !important;
  min-height: 0 !important;
  overflow: hidden !important;
  margin: 0 !important;
  padding: 0 !important;
  border: none !important;
  visibility: hidden !important;
}

/* Reset Quarto content container */
#quarto-content {
  padding: 0 !important;
  margin: 0 !important;
}

/* Ensure app takes full viewport */
.quarto-container {
  max-width: 100% !important;
  padding: 0 !important;
}

/* Hide Quarto footer on analyzer apps */
footer.footer,
.nav-footer {
  display: none !important;
  height: 0 !important;
  visibility: hidden !important;
}

/* ============================================================================
   END QUARTO OVERRIDES
   ============================================================================ */





/* ============================================================================
   1. APP CONTAINER & LAYOUT GRID
   ============================================================================ */
   
.app-container,
.analyzer-container {
  min-height: 100vh;
  width: 100%;
  background: var(--gray-50, #f9fafb);
  margin: 0;
  padding: 0;
}

/* Override Bootstrap's #quarto-content > * { padding-top: 14px } */
#quarto-content > .app-container,
#quarto-content > .analyzer-container,
#quarto-content > #app-content {
  padding-top: 0 !important;
}

.app-layout,
.analyzer-layout {
  display: flex;
  flex-direction: row;
  min-height: calc(100vh - 60px);
  width: 100%;
}


/* ============================================================================
   2. TOP BAR - Navy Background with Gold Title
   ============================================================================ */

.app-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.875rem 1.5rem;
  background: var(--sds-navy, #002855);
  color: #ffffff;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

/* App Title - GOLD color on navy background */
.app-title {
  margin: 0;
  font-size: 1.375rem;
  font-weight: 700;
  color: var(--sds-gold, #EAAA00);
}

/* Subtitle - lighter white */
.app-subtitle {
  color: rgba(255, 255, 255, 0.7);
  font-size: 0.875rem;
  padding-left: 0.75rem;
}

.topbar-center {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  flex: 1;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.user-email {
  color: rgba(255, 255, 255, 0.8);
  font-size: 0.8125rem;
}


/* ============================================================================
   3. TOP BAR BUTTONS
   ============================================================================ */

/* Dashboard/Nav button - transparent with white border */
.btn-nav {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: #ffffff;
  border-radius: 6px;
  font-size: 0.8125rem;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-nav:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.5);
  color: #ffffff;
}

/* Sign Out button - Red */
.btn-signout {
  padding: 0.5rem 1rem;
  background: var(--color-error, #dc2626);
  border: none;
  color: #ffffff;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.8125rem;
  font-weight: 500;
  transition: background 0.2s ease;
}

.btn-signout:hover {
  background: #b91c1c;
}


/* ============================================================================
   4. SIDEBAR - With Gold Accent Option
   ============================================================================ */

.app-sidebar,
.analyzer-sidebar {
  width: 25%;                           /* CHANGED: 25% of viewport */
  min-width: 220px;                     /* CHANGED: Minimum readable width */
  max-width: 320px;                     /* ADD: Maximum comfortable width */
  background: #ffffff;
  border-right: 1px solid var(--gray-200, #e5e7eb);
  border-left: none;                    /* ADD: Explicitly no left border */
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  flex-shrink: 0;
}

/* Gold accent variant - add class="app-sidebar gold-accent" */
.app-sidebar.gold-accent,
.analyzer-sidebar.gold-accent {
  border-right: 3px solid var(--sds-gold, #EAAA00);
}

/* Sidebar header */
.sidebar-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--gray-200, #e5e7eb);
}

.sidebar-title {
  margin: 0;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--sds-gold, #EAAA00);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}


/* ============================================================================
   5. SIDEBAR SECTIONS
   ============================================================================ */

.sidebar-section {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--gray-100, #f3f4f6);
}

.sidebar-section:last-child {
  border-bottom: none;
}

.sidebar-label {
  display: block;
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--gray-500, #6b7280);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.75rem;
}

.sidebar-hint {
  font-size: 0.6875rem;
  color: var(--gray-400, #9ca3af);
  margin-top: 0.5rem;
}

.sidebar-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--gray-200, #e5e7eb);
  display: flex;
  gap: 1rem;
  margin-top: auto;
}

.sidebar-link {
  color: var(--gray-500, #6b7280);
  font-size: 0.6875rem;
  text-decoration: none;
}

.sidebar-link:hover {
  color: var(--sds-navy, #002855);
}


/* ============================================================================
   6. SIDEBAR NAVIGATION - Gradient Active State
   ============================================================================ */

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 0.5rem 0;
}

.nav-btn {
  display: flex;
  align-items: center;
  width: 100%;
  padding: 0.625rem 1.25rem;
  border: none;
  background: transparent;
  text-align: left;
  cursor: pointer;
  transition: all 0.15s ease;
  color: var(--gray-600, #4b5563);
  gap: 0.75rem;
}

.nav-btn:hover {
  background: var(--gray-50, #f9fafb);
  color: var(--sds-navy, #002855);
}

/* Active nav button - NAVY GRADIENT */
.nav-btn.active {
  background: linear-gradient(90deg, var(--sds-navy, #002855) 0%, var(--sds-navy-light, #003875) 100%);
  color: #ffffff;
}

/* Active nav icon - GOLD background */
.nav-btn.active .nav-icon {
  background: var(--sds-gold, #EAAA00);
  color: var(--sds-navy, #002855);
}

.nav-icon {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--gray-200, #e5e7eb);
  border-radius: 6px;
  font-weight: 700;
  font-size: 0.6875rem;
  color: var(--gray-600, #4b5563);
  flex-shrink: 0;
  transition: all 0.15s ease;
}

.nav-label {
  font-size: 0.8125rem;
  font-weight: 500;
}


/* ============================================================================
   7. MAIN CONTENT AREA
   ============================================================================ */

.app-main,
.analyzer-main {
  flex: 1;                              /* Fills remaining space (75%) */
  min-width: 0;                         /* ADD: Prevents flex overflow issues */
  padding: 1.5rem;
  overflow-y: auto;
  background: var(--gray-50, #f9fafb);
}


.content-section,
.content-view {
  display: none;
}

.content-section.active,
.content-view.active {
  display: block;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.section-header h2 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--gray-900, #111827);
}

.section-subtitle {
  font-size: 0.8125rem;
  color: var(--gray-500, #6b7280);
  padding-left: 0.75rem;
  border-left: 2px solid var(--sds-gold, #EAAA00);
}


/* ============================================================================
   8. METRIC CARDS - Navy Left Border Accent
   ============================================================================ */

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.metric-card {
  background: #ffffff;
  border-radius: 10px;
  padding: 1.25rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  border-left: 4px solid var(--sds-navy, #002855);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.metric-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.metric-label {
  display: block;
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--gray-500, #6b7280);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.5rem;
}

.metric-value {
  display: block;
  font-size: 1.625rem;
  font-weight: 700;
  color: var(--gray-900, #111827);
  margin-bottom: 0.25rem;
}

.metric-trend {
  font-size: 0.75rem;
  color: var(--gray-500, #6b7280);
}

.metric-trend.positive {
  color: var(--color-success, #059669);
}

.metric-trend.negative {
  color: var(--color-error, #dc2626);
}


/* ============================================================================
   9. ACTION BUTTONS - Navy Gradient
   ============================================================================ */

.action-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.btn-action {
  padding: 0.75rem 1.25rem;
  background: linear-gradient(135deg, var(--sds-navy, #002855) 0%, var(--sds-navy-light, #003875) 100%);
  color: #ffffff;
  border: none;
  border-radius: 8px;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 2px 4px rgba(0, 40, 85, 0.15);
}

.btn-action:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 40, 85, 0.25);
}

.btn-action.btn-secondary {
  background: var(--gray-100, #f3f4f6);
  color: var(--gray-700, #374151);
  box-shadow: none;
  border: 1px solid var(--gray-200, #e5e7eb);
}

.btn-action.btn-secondary:hover {
  background: var(--gray-200, #e5e7eb);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}


/* ============================================================================
   10. SUB-TABS NAVIGATION
   ============================================================================ */

.sub-tabs {
  display: flex;
  gap: 0.25rem;
  padding: 0.25rem;
  background: var(--gray-100, #f3f4f6);
  border-radius: 8px;
  margin-bottom: 1.5rem;
}

.sub-tab {
  flex: 1;
  padding: 0.625rem 1rem;
  border: none;
  background: transparent;
  color: var(--gray-600, #4b5563);
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  border-radius: 6px;
  transition: all 0.15s ease;
  text-align: center;
}

.sub-tab:hover {
  background: var(--gray-200, #e5e7eb);
  color: var(--gray-800, #1f2937);
}

/* UPDATED CODE: Enhanced active state visibility */
.sub-tab.active {
  background: var(--sds-navy, #002855);
  color: #ffffff;
  box-shadow: 0 2px 4px rgba(0, 40, 85, 0.2);
  font-weight: 600;
}

/* Optional: Add hover state that doesn't conflict with active */
.sub-tab:hover:not(.active) {
  background: var(--gray-200, #e5e7eb);
  color: var(--gray-800, #1f2937);
}

/* ============================================================================
   11. INFO & SETTINGS CARDS
   ============================================================================ */

.info-card,
.settings-card {
  background: #ffffff;
  border-radius: 10px;
  padding: 1.25rem;
  margin-bottom: 1.25rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.info-card h3,
.settings-card h3 {
  margin: 0 0 1rem 0;
  font-size: 1rem;
  font-weight: 600;
  color: var(--gray-700, #374151);
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--gray-200, #e5e7eb);
}


/* ============================================================================
   12. QUICK ACTIONS CARD
   ============================================================================ */

.quick-actions {
  background: #ffffff;
  border-radius: 10px;
  padding: 1.25rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.quick-actions h3 {
  margin: 0 0 1rem 0;
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--gray-700, #374151);
}


/* ============================================================================
   13. LOADING & SPINNER
   ============================================================================ */

.auth-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
  gap: 1rem;
  color: var(--gray-600, #4b5563);
}

.spinner {
  border: 4px solid var(--gray-200, #e5e7eb);
  border-top: 4px solid var(--sds-navy, #002855);
  border-radius: 50%;
  width: 40px;
  height: 40px;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}


/* ============================================================================
   14. BOOTSTRAP OVERRIDE LAYER
   ============================================================================
   
   Bootstrap applies default background-color to buttons which overrides
   our gradient backgrounds. These rules ensure our styles win.
   ============================================================================ */

/* Force button gradients */
button.btn-action,
.action-buttons button,
.action-buttons .btn-action {
  background: linear-gradient(135deg, var(--sds-navy, #002855) 0%, var(--sds-navy-light, #003875) 100%) !important;
  background-color: transparent !important;
  color: #ffffff !important;
}

button.btn-action.btn-secondary,
.action-buttons button.btn-secondary {
  background: var(--gray-100, #f3f4f6) !important;
  color: var(--gray-700, #374151) !important;
}

/* Force metric card border */
.metrics-grid .metric-card {
  border-left: 4px solid var(--sds-navy, #002855) !important;
}

/* Force nav button active state */
.sidebar-nav .nav-btn.active,
.nav-btn.active {
  background: linear-gradient(90deg, var(--sds-navy, #002855) 0%, var(--sds-navy-light, #003875) 100%) !important;
  color: #ffffff !important;
}

.sidebar-nav .nav-btn.active .nav-icon,
.nav-btn.active .nav-icon {
  background: var(--sds-gold, #EAAA00) !important;
  color: var(--sds-navy, #002855) !important;
}

/* Force sign out button */
button.btn-signout {
  background: var(--color-error, #dc2626) !important;
  color: #ffffff !important;
}

button.btn-signout:hover {
  background: #b91c1c !important;
}


/* ============================================================================
   QB CONTROLS ALIGNMENT FIX
   ============================================================================ */

.qb-topbar-controls {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.qb-status-badge {
  display: inline-flex;
  align-items: center;
}

.qb-connect-topbar {
  display: flex;
  align-items: center;
}

.qb-connect-topbar img {
  vertical-align: middle;
  max-height: 32px;
}

.qb-disconnect-topbar-btn {
  vertical-align: middle;
  height: 32px;
  display: inline-flex;
  align-items: center;
}


