* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  /* Prevent iOS bounce scrolling */
  overflow: hidden;
  position: fixed;
  height: 100%;
  width: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    height: 100dvh; /* Dynamic viewport height for better mobile support */
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px; /* Overridden on mobile */
    overflow: hidden;
    margin: 0;
}



.phone-container {
  width: 100%;
  max-width: 400px;
  height: 700px;
  max-height: calc(100vh - 40px); /* Ensure it fits within viewport */
  position: relative;
}

.phone-frame {
  width: 100%;
  height: 100%;
  background: #fff;
  border-radius: 25px;
  /* box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3); */
  overflow: hidden;
  display: flex;
  flex-direction: column;
  position: relative;
}

/* .phone-frame::before {
  content: '';
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  width: 60px;
  height: 4px;
  background: #000;
  border-radius: 2px;
  opacity: 0.3;
  z-index: 10;
} */

.phone-header {
  background: #4a90e2;
  color: white;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  padding: 0 20px;
  min-height: 60px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.contact-info {
  display: flex;
  align-items: center;
  gap: 15px;
  height: 100%; /* Take full height of parent */
  min-height: 60px; /* Minimum height for proper centering */
}

.profile-pic {
  width: 45px;
  height: 45px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.3);
}

.contact-details h3 {
  font-size: 18px;
  margin-bottom: 2px;
  font-weight: 600;
}

.status {
  font-size: 13px;
  opacity: 0.9;
}

.status.online::before {
  content: '🟢 ';
  font-size: 10px;
}

.messages-container {
  flex: 1;
  background: #f8f9fa;
  background-image: 
    radial-gradient(circle at 25px 25px, rgba(255,255,255,0.2) 2%, transparent 0%), 
    radial-gradient(circle at 75px 75px, rgba(255,255,255,0.2) 2%, transparent 0%);
  background-size: 100px 100px;
  overflow-y: auto;
  padding: 20px;
}

.messages-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.message {
  max-width: 85%;
  padding: 12px 16px;
  border-radius: 18px;
  font-size: 15px;
  line-height: 1.4;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  animation: slideInMessage 0.3s ease-out;
  align-self: flex-start;
  background: #fff;
  color: #333;
  border-bottom-left-radius: 4px;
}

.message a {
  color: #4a90e2;
  text-decoration: none;
  font-weight: 500;
}

.message a:hover {
  text-decoration: underline;
}

.contact-links {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
}

.contact-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: rgba(74, 144, 226, 0.1);
  border-radius: 12px;
  transition: background-color 0.2s ease;
}

.contact-link:hover {
  background: rgba(74, 144, 226, 0.2);
  text-decoration: none !important;
}

.contact-icon {
  font-size: 16px;
}

.typing-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  background: #fff;
  border-radius: 18px;
  border-bottom-left-radius: 4px;
  max-width: 80px;
  align-self: flex-start;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.typing-dots {
  display: flex;
  gap: 3px;
}

.typing-dot {
  width: 6px;
  height: 6px;
  background: #999;
  border-radius: 50%;
  animation: typingDot 1.4s infinite;
}

.typing-dot:nth-child(2) {
  animation-delay: 0.2s;
}

.typing-dot:nth-child(3) {
  animation-delay: 0.4s;
}

.input-area {
  background: #fff;
  padding: 15px 20px;
  border-top: 1px solid #e1e8ed;
  flex-shrink: 0; /* Never allow this to shrink */
  min-height: 60px; /* Ensure minimum height */
}

.input-container {
  background: #f1f3f4;
  border-radius: 20px;
  padding: 12px 16px;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 50px; /* Ensure proper height for vertical centering */
}

.input-placeholder {
  color: #666;
  font-size: 14px;
  font-style: italic;
}

/* Animations */
@keyframes slideInMessage {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes typingDot {
  0%, 60%, 100% {
    transform: translateY(0);
    opacity: 0.4;
  }
  30% {
    transform: translateY(-10px);
    opacity: 1;
  }
}

/* Small screens - Full width and height (≤ 550px) */
@media (max-width: 550px) {
  body {
    padding: 0; /* Remove all padding */
    margin: 0;  /* Remove all margin */
    background: #f8f9fa;
    overflow: hidden; /* Prevent external scrolling */
    height: 100vh;
    height: 100dvh; /* Use dynamic viewport height */
  }
  
  .phone-container {
    width: 100vw;
    height: 100dvh;
    max-width: none;
    max-height: none;
    margin: 0;
    padding: 0;
  }
  
  .phone-frame {
    border-radius: 0;
    box-shadow: none;
    height: 100dvh;
    min-height: -webkit-fill-available;
    margin: 0;
    padding: 0;
    width: 100%;
  }
  
  .phone-frame::before {
    display: none; /* No notch indicator */
  }
  
  .phone-header {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    padding: 0 20px;
    margin: 0;
    flex-shrink: 0;
    width: 100%;
    min-height: 60px;
    box-sizing: border-box;
  }
  
  .contact-info {
    padding-left: 20px; /* Add internal padding only */
    padding-right: 20px;
    display: flex;
    align-items: center; /* Center vertically */
    justify-content: flex-start;
    height: 100%;
    min-height: 60px; /* Ensure proper height for centering */
  }
  
  .messages-container {
    flex: 1;
    min-height: 0; /* Allow flex item to shrink */
    margin: 0;
    padding: 20px; /* Keep internal padding */
  }
  
  .input-area {
    flex-shrink: 0; /* Prevent input area from shrinking */
    padding-bottom: env(safe-area-inset-bottom, 15px); /* Account for home indicator */
    padding-left: 0;
    padding-right: 0;
    margin: 0;
    width: 100%;
  }
  
  .input-container {
    margin: 0 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 50px;
    height: 100%;
    box-sizing: border-box;
  }
}

/* Larger screens - Show mobile frame (> 550px) */
@media (min-width: 551px) {
  .phone-container {
    max-width: 380px;
    height: 750px;
    max-height: calc(100vh - 40px); /* Ensure it fits within viewport */
  }
  
  .phone-frame {
    border: 8px solid #333;
    border-radius: 35px;
    position: relative;
    height: 100%; /* Use full container height */
  }
  
  .phone-frame::after {
    content: '';
    position: absolute;
    bottom: 8px;
    left: 50%;
    transform: translateX(-50%);
    width: 50px;
    height: 4px;
    background: #333;
    border-radius: 2px;
  }
}

/* Scrollbar styling - Made wider and more visible */
.messages-container::-webkit-scrollbar {
  width: 10px; /* Made wider */
}

.messages-container::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.1);
  border-radius: 5px;
  margin: 10px 0; /* Add some margin to track */
}

.messages-container::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.4); /* More visible */
  border-radius: 5px;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.messages-container::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 0, 0, 0.6); /* Even more visible on hover */
}

/* Ensure smooth scrolling behavior */
.messages-container {
  scroll-behavior: smooth;
}

/* For Firefox - Made wider */
.messages-container {
  scrollbar-width: auto; /* Changed from thin to auto for wider scrollbar */
  scrollbar-color: rgba(0, 0, 0, 0.4) rgba(0, 0, 0, 0.1);
}

/* Additional mobile fixes */
@media (max-width: 550px) {
  /* Ensure full-width layout with no gaps */
  * {
    margin: 0;
    padding: 0;
  }
  
  html, body {
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden;
  }
  
  /* Ensure input area is always visible on mobile */
  .phone-frame {
    position: relative;
    display: flex;
    flex-direction: column;
    width: 100vw;
    height: 100dvh;
  }
  
  /* Handle iOS Safari specific issues */
  @supports (-webkit-appearance: none) {
    .phone-container {
      height: -webkit-fill-available;
    }
    
    .phone-frame {
      height: -webkit-fill-available;
    }
  }
}
