/* 
 * Mobile-first stylesheet for photo upload form
 * Designed for cross-compatibility from old Android to new iPhones
 */

/* Reset and base styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: #333;
  background-color: #f7f7f7;
  height: 100%;
  height: calc(var(--vh, 1vh) * 100); /* Fix for iOS */
  width: 100%;
  overflow: hidden;
  position: fixed;
}

strong {
  font-weight: 600;
}

req {
  color: #f00;
  font-weight: 500;
  font-size: 0.9rem;
}

.required {
  color: #f00;
  font-weight: bold;
}

input:invalid, 
input.invalid,
textarea.invalid {
  border: 1px solid #ff6b6b;
  background-color: rgba(255, 107, 107, 0.05);
}

input:focus,
textarea:focus {
  outline: none;
  border-color: #00b3e0;
  box-shadow: 0 0 0 2px rgba(0, 179, 224, 0.2);
}

/* Main layout */
form {
  width: 100%;
  height: 100%;
}

/* Progress bar */
#progress-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  background-color: #f7f7f7;
  z-index: 10;
}

#progress-bar {
  height: 100%;
  width: 0;
  background-color: #00ccff;
  transition: width 0.5s ease-in-out;
}

#progress-text {
  color: #fff;
  padding: 8px;
  border-radius: 99px;
  border: 3px solid #0cf;
  background-color: rgba(0, 204, 255, 0.8);
  font-size: 14px;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 11;
}

/* Preloading images (hidden) */
#preload_images {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  opacity: 0;
}

/* Content container */
#content-container {
  width: 92%;
  max-width: 600px;
  height: calc(100% - 130px); /* Leave room for buttons at bottom */
  margin: 60px auto 70px; /* 60px top margin, 70px bottom margin */
  background-color: #fff;
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
  position: relative; /* Create positioning context */
}

/* Page styling */
.page {
  display: none;
  width: 100%;
  min-height: 100%;
}

.camera-tip {
  margin-top: 10px;
  padding: 8px 12px;
  background-color: #f5f5f5;
  border-left: 3px solid #00ccff;
  font-size: 0.9rem;
}

.page.active {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
}

.page.landing_page {
  text-align: left;
}

.page.landing_page ol {
  padding-left: 20px;
  margin-top: 20px;
}

.page.landing_page li {
  margin-bottom: 16px;
}

.page.landing_page li strong {
  display: block;
  margin-bottom: 4px;
}

.page .house_view {
  height: auto;
  width: 150px;
  max-width: 80%;
  margin: 20px 0;
}

h2 {
  font-weight: 600;
  font-size: 1.5rem;
  margin-bottom: 10px;
  color: #444;
  width: 100%;
  text-align: center;
}

/* Form inputs */
#house-details {
  width: 100%;
  /* No extra padding - the container's margin will handle spacing */
}

input[type="text"],
input[type="email"],
input[type="tel"],
textarea {
  width: 100%;
  padding: 15px; /* Larger touch target */
  margin: 8px 0 22px; /* More space between fields */
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 16px; /* Prevents zoom on iOS */
  -webkit-tap-highlight-color: rgba(0, 204, 255, 0.2); /* Highlight on tap for mobile */
  -webkit-appearance: none; /* Removes default iOS styling */
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05); /* Subtle shadow for depth */
}

textarea {
  min-height: 80px;
  resize: vertical;
}

label {
  display: block;
  text-align: left;
  font-weight: 500;
  color: #555;
}

/* Image upload styling */
.upload-btn-wrapper {
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  margin: 10px 0;
}

.image_upload_box {
  border: 2px dashed #ccc;
  color: #666;
  background-color: #fafafa;
  border-radius: 12px;
  font-weight: 500;
  width: 100%;
  max-width: 280px;
  height: 160px;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  background-image: url('assets/images/camera-default.webp');
  background-repeat: no-repeat;
  background-position: center;
  background-size: 80px 80px;
  transition: all 0.2s ease;
}

.image_upload_box:active,
.image_upload_box.active {
  background-color: #f0f0f0;
  border-color: #00ccff;
}

.image_upload_box.success {
  border: 2px solid #91eab1;
  background-color: rgba(145, 234, 177, 0.1);
  background-image: url(assets/images/camera-success.webp);
  background-size: 80px 80px;
}

.image_upload_box.fail {
  border: 2px solid #ff6b6b;
  background-color: rgba(255, 107, 107, 0.1);
  background-image: url(assets/images/camera-fail.webp);
  background-size: 80px 80px;
}

.upload-btn-wrapper input[type="file"] {
  position: absolute;
  left: 0;
  top: 0;
  opacity: 0;
  width: 100%;
  height: 160px;
  cursor: pointer;
}

.upload-btn-wrapper req {
  align-self: flex-end;
  margin-right: 10%;
  margin-top: 5px;
}

/* Navigation buttons */
.nav_element-container {
  position: fixed;
  bottom: 12px;
  bottom: max(12px, env(safe-area-inset-bottom, 12px)); /* iOS safe area */
  left: 0;
  width: 100%;
  display: flex;
  justify-content: center;
  gap: 20px;
  padding: 0 16px;
  z-index: 50; /* Higher z-index to ensure it's above content */
  background-color: rgba(247, 247, 247, 0.9); /* Semi-transparent background */
  padding-top: 10px;
  padding-bottom: 10px;
}

.nav_element {
  background-color: #00b3e0;
  color: #fff;
  width: 120px;
  height: 44px;
  border-radius: 8px;
  border: none;
  font-weight: 500;
  font-size: 16px;
  letter-spacing: 1px;
  text-transform: uppercase;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
  transition: all 0.2s ease;
}

.nav_element:active {
  transform: translateY(1px);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
  background-color: #0095bf;
}

/* Buttons will be shown/hidden by JavaScript */
/* #back-btn, #next-btn {
  display: none;
} */

/* Tooltip for errors and instructions */
.nav_tooltip {
  position: fixed;
  bottom: 75px;
  left: 50%;
  transform: translateX(-50%);
  background-color: #ffea00;
  border: 2px solid #dcca00;
  color: #555;
  padding: 12px 16px;
  width: 85%;
  max-width: 320px;
  border-radius: 8px;
  opacity: 0;
  text-align: center;
  transition: opacity 0.3s ease;
  z-index: 20;
  font-size: 0.9rem;
}

/* Success animation */
.animated-line {
  position: fixed;
  left: 0;
  bottom: 0;
  width: 100%;
  height: 0;
  background-color: #00ccff;
  z-index: 99;
  transition: height 2s cubic-bezier(0.19, 1, 0.22, 1);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.animated-line p {
  transform: scale(0);
  animation: bounceEffect 0.7s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
  animation-play-state: paused;
  color: white;
  margin-top: 20px;
  font-weight: 500;
  text-align: center;
  display: none;
}

.upload_in_progress {
  display: none;
  color: #fff;
  opacity: 0;
  transition: opacity 0.5s;
}

.animated-line img {
  width: 120px;
  height: auto;
  margin-bottom: 16px;
}

@keyframes bounceEffect {
  0% { transform: scale(0); }
  70% { transform: scale(1.1); }
  100% { transform: scale(1); }
}

/* Ensure buttons work properly on touch devices */
button {
  cursor: pointer;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
}

/* Specific adjustment for iOS devices */
@supports (-webkit-touch-callout: none) {
  input, textarea, select, button {
    font-size: 16px; /* Prevent zoom on focus */
  }
}