/**
 * Shared Layout Styles for SSI Builders Demo Pages
 * Mobile-First Responsive Design
 */

/* Reset & Base */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Roboto', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: #f5f5f5;
  color: #202124;
  line-height: 1.6;
  overflow-x: hidden;
}

/* Page Layout */
.page-layout {
  display: flex;
  min-height: 100vh;
  position: relative;
}

/* Sidebar Container */
#sidebar-container {
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  z-index: 100;
  transition: all 0.3s ease;
}

/* Content Area */
.demo-content {
  flex: 1;
  margin-left: 280px;
  padding: 24px;
  max-width: 100%;
  transition: margin-left 0.3s ease;
}

.demo-content-inner {
  max-width: 1200px;
  margin: 0 auto;
}

/* Page Header */
.page-header {
  margin-bottom: 32px;
  padding-bottom: 16px;
  border-bottom: 2px solid #e0e0e0;
}

.page-header h1 {
  font-size: 2rem;
  font-weight: 500;
  color: #1a73e8;
  margin-bottom: 8px;
}

.page-header p {
  font-size: 1rem;
  color: #5f6368;
}

/* Section Styling */
.demo-section {
  background: #ffffff;
  border-radius: 8px;
  padding: 24px;
  margin-bottom: 24px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.demo-section h2 {
  font-size: 1.5rem;
  font-weight: 500;
  color: #202124;
  margin-bottom: 16px;
}

.demo-section h3 {
  font-size: 1.25rem;
  font-weight: 500;
  color: #5f6368;
  margin-bottom: 12px;
}

.demo-section p {
  color: #5f6368;
  margin-bottom: 12px;
  line-height: 1.6;
}

/* Code Blocks */
.code-block {
  background: #f8f9fa;
  border: 1px solid #e0e0e0;
  border-radius: 4px;
  padding: 16px;
  margin: 12px 0;
  overflow-x: auto;
  font-family: 'Monaco', 'Courier New', monospace;
  font-size: 0.875rem;
  line-height: 1.4;
}

/* Mobile Menu Toggle */
.mobile-menu-toggle {
  display: none;
  position: fixed;
  top: 16px;
  left: 16px;
  z-index: 1001;
  width: 48px;
  height: 48px;
  background: #1a73e8;
  color: #ffffff;
  border: none;
  border-radius: 50%;
  font-size: 1.5rem;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  transition: transform 0.2s ease, background 0.2s ease;
}

.mobile-menu-toggle:hover {
  background: #1557b0;
  transform: scale(1.05);
}

.mobile-menu-toggle:active {
  transform: scale(0.95);
}

/* Responsive Breakpoints */

/* Tablet (768px - 1023px) */
@media (max-width: 1023px) {
  #sidebar-container {
    transform: translateX(-280px);
  }

  #sidebar-container.mobile-open {
    transform: translateX(0);
  }

  .demo-content {
    margin-left: 0;
    padding: 20px;
  }

  .mobile-menu-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
  }

  /* Overlay when sidebar is open */
  #sidebar-container.mobile-open::after {
    content: '';
    position: fixed;
    top: 0;
    left: 280px;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: -1;
  }
}

/* Mobile (< 768px) */
@media (max-width: 767px) {
  .demo-content {
    padding: 16px;
  }

  .page-header h1 {
    font-size: 1.5rem;
  }

  .demo-section {
    padding: 16px;
    margin-bottom: 16px;
  }

  .demo-section h2 {
    font-size: 1.25rem;
  }

  .demo-section h3 {
    font-size: 1.125rem;
  }

  .code-block {
    padding: 12px;
    font-size: 0.8125rem;
  }

  /* Make sidebar full-width on mobile */
  #sidebar-container {
    width: 280px;
    max-width: 85vw;
  }
}

/* Large Mobile (480px - 767px) */
@media (min-width: 480px) and (max-width: 767px) {
  .demo-content {
    padding: 18px;
  }

  .page-header h1 {
    font-size: 1.75rem;
  }
}

/* Desktop (1024px+) */
@media (min-width: 1024px) {
  #sidebar-container {
    transform: translateX(0);
  }

  .demo-content {
    margin-left: 280px;
    padding: 32px;
  }

  .page-header {
    margin-bottom: 40px;
  }

  .demo-section {
    padding: 32px;
    margin-bottom: 32px;
  }
}

/* Large Desktop (1440px+) */
@media (min-width: 1440px) {
  .demo-content-inner {
    max-width: 1400px;
  }

  .page-header h1 {
    font-size: 2.5rem;
  }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
  * {
    animation: none !important;
    transition: none !important;
  }
}

/* Print Styles */
@media print {
  #sidebar-container,
  .mobile-menu-toggle {
    display: none;
  }

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

  .demo-section {
    box-shadow: none;
    border: 1px solid #e0e0e0;
    page-break-inside: avoid;
  }
}

/* ===================================
   Dark Mode Overrides
   Applied via .dark-mode or .m3-dark class on html
   =================================== */
html.dark-mode body,
html.m3-dark body {
  background: var(--m3-background, #121212);
  color: var(--m3-on-background, #e1e1e1);
}

html.dark-mode .page-header,
html.m3-dark .page-header {
  border-bottom-color: var(--m3-outline-variant, #3d3d3d);
}

html.dark-mode .page-header h1,
html.m3-dark .page-header h1 {
  color: var(--m3-primary, #8ab4f8);
}

html.dark-mode .page-header p,
html.m3-dark .page-header p {
  color: var(--m3-on-surface-variant, #a1a1a1);
}

html.dark-mode .demo-section,
html.m3-dark .demo-section {
  background: var(--m3-surface, #1e1e1e);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

html.dark-mode .demo-section h2,
html.m3-dark .demo-section h2 {
  color: var(--m3-on-surface, #e1e1e1);
}

html.dark-mode .demo-section h3,
html.m3-dark .demo-section h3 {
  color: var(--m3-on-surface-variant, #a1a1a1);
}

html.dark-mode .demo-section p,
html.m3-dark .demo-section p {
  color: var(--m3-on-surface-variant, #a1a1a1);
}

html.dark-mode .code-block,
html.m3-dark .code-block {
  background: var(--m3-surface-container-highest, #353535);
  border-color: var(--m3-outline-variant, #3d3d3d);
}

/* Dark mode for demo-content area */
html.dark-mode .demo-content,
html.m3-dark .demo-content {
  background: var(--m3-background, #121212);
}

/* Dark mode badges */
html.dark-mode .badge,
html.m3-dark .badge {
  background: var(--m3-primary-container, #004a77);
  color: var(--m3-on-primary-container, #d1e4ff);
}

html.dark-mode .badge.new,
html.m3-dark .badge.new {
  background: var(--m3-tertiary-container, #003c2a);
  color: var(--m3-on-tertiary-container, #a8f5c5);
}
