/* Responsive Design - Mobile & Tablet Breakpoints */

/* === TABLET (max-width: 1024px) === */

@media (max-width: 1024px) {
  :root {
    --sidebar-width: 240px;
    --space-8: 1.5rem;
    --space-12: 2rem;
  }

  .app-container {
    grid-template-columns: var(--sidebar-width) 1fr;
  }

  .hero-title {
    font-size: var(--text-5xl);
  }

  .hero-subtitle {
    font-size: var(--text-xl);
  }

  .dashboard-section {
    padding: var(--space-6);
  }

  .grid-cols-4 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .grid-cols-3 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* === MOBILE (max-width: 768px) === */

@media (max-width: 768px) {
  :root {
    --header-height: 60px;
    --sidebar-width: 100%;
    --space-6: 1rem;
    --space-8: 1.25rem;
    --space-12: 1.5rem;
    --text-6xl: 2.5rem;
    --text-5xl: 2rem;
    --text-4xl: 1.75rem;
    --text-3xl: 1.5rem;
    --text-2xl: 1.25rem;
  }

  /* === LAYOUT === */

  .app-container {
    grid-template-areas:
      "header"
      "main";
    grid-template-columns: 1fr;
    grid-template-rows: var(--header-height) 1fr;
  }

  .app-header {
    padding: 0 var(--space-4);
  }

  .header-logos {
    gap: var(--space-4);
  }

  .header-logo {
    height: 35px;
  }

  .header-divider {
    height: 30px;
  }

  .header-progress-text {
    display: none;
  }

  .app-sidebar {
    position: fixed;
    top: var(--header-height);
    left: 0;
    width: 100%;
    height: calc(100vh - var(--header-height));
    z-index: var(--z-fixed);
    transform: translateX(-100%);
    box-shadow: var(--shadow-xl);
  }

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

  .app-main {
    padding: var(--space-4);
  }

  /* Mobile Menu Toggle */
  .mobile-menu-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: var(--border-radius-md);
    background-color: var(--bg-secondary);
    border: none;
    cursor: pointer;
    transition: all var(--transition-fast);
  }

  .mobile-menu-toggle:hover {
    background-color: var(--bg-active);
  }

  .mobile-menu-icon {
    display: flex;
    flex-direction: column;
    gap: 4px;
    width: 20px;
  }

  .mobile-menu-icon span {
    display: block;
    width: 100%;
    height: 2px;
    background-color: var(--text-primary);
    transition: all var(--transition-fast);
  }

  .mobile-menu-toggle.open .mobile-menu-icon span:nth-child(1) {
    transform: rotate(45deg) translateY(7px);
  }

  .mobile-menu-toggle.open .mobile-menu-icon span:nth-child(2) {
    opacity: 0;
  }

  .mobile-menu-toggle.open .mobile-menu-icon span:nth-child(3) {
    transform: rotate(-45deg) translateY(-7px);
  }

  /* === SECTIONS === */

  .dashboard-section {
    padding: var(--space-4);
    margin-bottom: var(--space-4);
  }

  .dashboard-section-title {
    font-size: var(--text-2xl);
  }

  .dashboard-section-subtitle {
    font-size: var(--text-base);
  }

  /* === HERO === */

  #section-hero {
    min-height: calc(100vh - var(--header-height) - var(--space-8));
    padding: var(--space-6);
  }

  .hero-title {
    font-size: var(--text-4xl);
  }

  .hero-subtitle {
    font-size: var(--text-lg);
    margin-bottom: var(--space-6);
  }

  .hero-metrics {
    grid-template-columns: 1fr;
    gap: var(--space-4);
  }

  .hero-metric {
    padding: var(--space-4);
  }

  .hero-metric-value {
    font-size: var(--text-3xl);
  }

  /* === CARDS === */

  .card {
    padding: var(--space-4);
  }

  .card-title {
    font-size: var(--text-lg);
  }

  .context-cards {
    grid-template-columns: 1fr;
    gap: var(--space-4);
  }

  .context-card {
    padding: var(--space-6);
  }

  .context-icon {
    width: 50px;
    height: 50px;
    font-size: var(--text-2xl);
  }

  /* === THREE LOOPS === */

  .loops-grid {
    grid-template-columns: 1fr;
    gap: var(--space-4);
  }

  .loop-card {
    padding: var(--space-6);
  }

  .loop-number {
    width: 50px;
    height: 50px;
    font-size: var(--text-xl);
  }

  .loop-title {
    font-size: var(--text-xl);
    padding-right: 60px;
  }

  .loop-impact-value {
    font-size: var(--text-2xl);
  }

  /* === FINANCIAL === */

  .scenario-tabs {
    flex-direction: column;
    gap: var(--space-2);
  }

  .scenario-tab {
    padding: var(--space-3) var(--space-4);
    font-size: var(--text-sm);
  }

  .financial-metrics {
    grid-template-columns: 1fr;
    gap: var(--space-3);
  }

  .chart-container {
    padding: var(--space-4);
    margin-top: var(--space-4);
  }

  .chart-title {
    font-size: var(--text-lg);
  }

  /* === VALUE CHAIN === */

  .value-chain-item {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-3);
    padding: var(--space-4);
  }

  .value-chain-value {
    font-size: var(--text-2xl);
  }

  /* === TIMELINE === */

  .timeline {
    padding-left: var(--space-8);
  }

  .timeline-item::before {
    left: calc(-1 * var(--space-8) - 6px);
    width: 16px;
    height: 16px;
  }

  /* === ROADMAP === */

  .roadmap-phases {
    gap: var(--space-4);
  }

  .phase-card {
    padding: var(--space-6);
  }

  .phase-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .phase-number {
    width: 50px;
    height: 50px;
    font-size: var(--text-xl);
  }

  .phase-title {
    font-size: var(--text-xl);
  }

  /* === METRIC CARDS === */

  .metric-card {
    padding: var(--space-4);
  }

  .metric-value {
    font-size: var(--text-3xl);
  }

  /* === MODALS === */

  .modal {
    max-width: 95%;
    max-height: 85vh;
  }

  .modal-header {
    padding: var(--space-4);
  }

  .modal-title {
    font-size: var(--text-xl);
  }

  .modal-body {
    padding: var(--space-4);
  }

  .modal-footer {
    padding: var(--space-4);
    flex-direction: column;
    gap: var(--space-2);
  }

  .modal-footer .btn {
    width: 100%;
  }

  /* === COMPARISON TABLE === */

  .comparison-table {
    font-size: var(--text-sm);
  }

  .comparison-table th,
  .comparison-table td {
    padding: var(--space-3) var(--space-4);
  }

  /* === GRID SYSTEM === */

  .grid-cols-2,
  .grid-cols-3,
  .grid-cols-4,
  .grid-cols-6 {
    grid-template-columns: 1fr;
  }

  /* === SPACING === */

  .py-8 {
    padding-top: var(--space-4);
    padding-bottom: var(--space-4);
  }

  .px-8 {
    padding-left: var(--space-4);
    padding-right: var(--space-4);
  }

  .mt-12,
  .mb-12 {
    margin-top: var(--space-6);
    margin-bottom: var(--space-6);
  }

  /* === UTILITIES === */

  .section-container {
    padding: var(--space-6) 0;
  }
}

/* === SMALL MOBILE (max-width: 480px) === */

@media (max-width: 480px) {
  :root {
    --text-6xl: 2rem;
    --text-5xl: 1.75rem;
    --text-4xl: 1.5rem;
    --text-3xl: 1.25rem;
  }

  .hero-title {
    font-size: var(--text-3xl);
  }

  .hero-subtitle {
    font-size: var(--text-base);
  }

  .hero-metric-value {
    font-size: var(--text-2xl);
  }

  .dashboard-section-title {
    font-size: var(--text-xl);
  }

  .loop-impact-value {
    font-size: var(--text-xl);
  }

  .value-chain-value {
    font-size: var(--text-xl);
  }

  .header-logo {
    height: 30px;
  }

  .btn {
    padding: var(--space-2) var(--space-4);
    font-size: var(--text-sm);
  }
}

/* === LANDSCAPE MOBILE (max-height: 500px) === */

@media (max-height: 500px) and (orientation: landscape) {
  #section-hero {
    min-height: auto;
    padding: var(--space-4);
  }

  .hero-metrics {
    margin-top: var(--space-6);
  }

  .hero-title {
    font-size: var(--text-3xl);
    margin-bottom: var(--space-4);
  }

  .hero-subtitle {
    font-size: var(--text-base);
    margin-bottom: var(--space-6);
  }
}

/* === TOUCH OPTIMIZATIONS === */

@media (hover: none) and (pointer: coarse) {
  /* Increase touch targets */
  .btn {
    min-height: 44px;
  }

  .nav-item {
    min-height: 44px;
  }

  .scenario-tab {
    min-height: 44px;
  }

  /* Remove hover effects on touch devices */
  .card:hover,
  .loop-card:hover,
  .context-card:hover,
  .phase-card:hover {
    transform: none;
  }

  /* Better tap highlights */
  * {
    -webkit-tap-highlight-color: rgba(123, 44, 191, 0.1);
  }
}

/* === PRINT STYLES === */

@media print {
  .app-sidebar,
  .app-header,
  .mobile-menu-toggle,
  .scroll-indicator,
  .btn,
  .modal-backdrop {
    display: none !important;
  }

  .app-container {
    grid-template-areas: "main";
    grid-template-columns: 1fr;
  }

  .app-main {
    padding: 0;
  }

  .dashboard-section {
    page-break-inside: avoid;
    box-shadow: none;
    border: var(--border-width) solid var(--border-color);
  }

  .chart-container {
    page-break-inside: avoid;
  }

  body {
    background-color: white;
  }

  /* Ensure colors print */
  * {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
}

/* === REDUCE MOTION === */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
