/* Harpenin Mobile Web - Responsive Styling */

/* ============================================
   Theme Variables (from Flutter theme)
   - surfacePrimary (light): #ffffff
   - surfacePrimary (dark):  #111111
   - surfaceSecondary (light): #f6f8fc
   - surfaceSecondary (dark):  #1a1a1a
   - accent: #ee9d24
   ============================================ */

:root {
  color-scheme: light dark;
  --surface-primary: #ffffff;   /* AppColorExtension.light.surfacePrimary */
  --surface-secondary: #f6f8fc; /* AppColorExtension.light.surfaceSecondary */
  --accent: #ee9d24;            /* AppColorExtension.accent */
}

@media (prefers-color-scheme: dark) {
  :root {
    --surface-primary: #111111;   /* AppColorExtension.dark.surfacePrimary */
    --surface-secondary: #1a1a1a; /* AppColorExtension.dark.surfaceSecondary */
    --accent: #ee9d24;
  }
}

/* ============================================
   Base Reset & Mobile-First Styling
   ============================================ */

* {
  -webkit-box-sizing: border-box;
  -moz-box-sizing: border-box;
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  background: var(--surface-secondary);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  overflow: hidden;
}

body {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  background: var(--surface-secondary);
}

/* ============================================
   Main App Container - Mobile Width Lock
   ============================================ */

#app-container {
  width: 100%;
  height: 100%;
  max-width: 390px;
  margin: 0 auto;
  background-color: var(--surface-primary);
  position: relative;
  overflow: hidden;
  -webkit-overflow-scrolling: touch;
}

/* Remove scrollbars while maintaining scroll functionality */
#app-container {
  -ms-overflow-style: none;
  scrollbar-width: none;
}

#app-container::-webkit-scrollbar {
  display: none;
}

/* ============================================
   Mobile Devices (≤ 480px)
   ============================================ */

@media (max-width: 480px) {
  html, body {
    width: 100vw;
    height: 100vh;
  }

  body {
    background: var(--surface-secondary);
  }

  #app-container {
    max-width: 100%;
    width: 100vw;
    height: 100vh;
    box-shadow: none;
    margin: 0;
  }

  /* Prevent rubber-band scrolling on iOS */
  body, #app-container {
    position: fixed;
    overflow: hidden;
  }
}

/* ============================================
   Tablets & Desktop (> 480px)
   ============================================ */

@media (min-width: 481px) {
  body {
    width: 100vw;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    background: var(--surface-secondary);
    padding: 20px;
  }

  #app-container {
    height: 100vh;
    max-height: calc(100vh - 40px);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    border-radius: 8px;
    overflow: hidden;
  }

  /* Tablet-specific adjustments */
  @media (min-width: 768px) {
    body {
      padding: 30px;
    }

    #app-container {
      max-height: calc(100vh - 60px);
      box-shadow: 0 15px 50px rgba(0, 0, 0, 0.2);
      border-radius: 12px;
    }
  }

  /* Large desktop adjustments */
  @media (min-width: 1024px) {
    body {
      padding: 40px;
    }

    #app-container {
      max-height: calc(100vh - 80px);
      box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
    }
  }
}

/* ============================================
   Landscape Orientation Handling
   ============================================ */

@media (max-height: 600px) and (orientation: landscape) {
  html, body {
    height: 100vh;
  }

  #app-container {
    max-height: 100vh;
    overflow-y: auto;
  }
}

/* ============================================
   High Resolution Display Support
   ============================================ */

@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
  body, #app-container {
    -webkit-font-smoothing: subpixel-antialiased;
  }
}

/* ============================================
   Dark Mode Support
   ============================================ */

@media (prefers-color-scheme: dark) {
  html, body {
    background: var(--surface-secondary);
  }

  #app-container {
    background-color: var(--surface-primary);
  }
}

/* ============================================
   Final Theme Bindings (strong override)
   ============================================ */

html, body {
  background: var(--surface-secondary) !important;
}

#app-container {
  background-color: var(--surface-primary) !important;
}

/* ============================================
   Print Styles
   ============================================ */

@media print {
  body, #app-container {
    background: white;
    box-shadow: none;
  }

  #app-container {
    max-width: 100%;
  }
}

/* ============================================
   Accessibility & Reduced Motion
   ============================================ */

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

/* ============================================
   iOS Safe Area & Notch Support
   ============================================ */

@supports (padding: max(0px)) {
  body {
    padding-left: max(16px, env(safe-area-inset-left));
    padding-right: max(16px, env(safe-area-inset-right));
    padding-top: max(0px, env(safe-area-inset-top));
    padding-bottom: max(0px, env(safe-area-inset-bottom));
  }

  @media (max-width: 480px) {
    body {
      padding: 0;
    }
  }
}

/* ============================================
   Status Bar & Navigation Bar Fixes
   ============================================ */

/* Prevent input focus zooming on iOS */
input, select, textarea {
  font-size: 16px !important;
}

/* Fix viewport height issues on mobile */
::-webkit-autofill {
  -webkit-box-shadow: 0 0 0 30px white inset !important;
  -webkit-text-fill-color: #333 !important;
}
