* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial,
    sans-serif;
  -webkit-tap-highlight-color: transparent;
}

body {
  background-color: #ece5dd;
  height: 100vh; /* Fallback for older browsers */
  height: 100dvh; /* The magic fix for mobile UI bars */
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden; /* This stops the entire page from scrolling */
}

/* Base Screen Styling */
.screen {
  display: none;
  width: 100%;
  max-width: 450px;
  height: 100vh; /* Fallback */
  height: 100dvh; /* The magic fix */
  background-color: white;
  flex-direction: column;
  position: relative;
  overflow: hidden; /* Keeps everything locked inside the container */
}

@media (min-width: 451px) {
  .screen {
    height: 90vh;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
  }
}

.screen.active {
  display: flex;
}

.hidden {
  display: none !important;
}

/* Login Card UI */
#login-screen {
  justify-content: center;
  align-items: center;
  background-color: #f0f2f5;
}

.card-container {
  background: white;
  padding: 40px 30px;
  border-radius: 12px;
  text-align: center;
  width: 85%;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

.card-container h2 {
  margin-bottom: 25px;
  color: #111b21;
  font-weight: 500;
}

#pin-input {
  width: 100%;
  padding: 15px;
  font-size: 28px;
  text-align: center;
  letter-spacing: 15px;
  margin-bottom: 20px;
  border: 1px solid #d1d7db;
  border-radius: 8px;
  background-color: #f0f2f5;
  outline: none;
}

#pin-input:focus {
  border-color: #00a884;
}

.primary-btn {
  width: 100%;
  padding: 12px;
  background-color: #00a884;
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 16px;
  font-weight: bold;
  cursor: pointer;
  transition: background-color 0.2s;
}

.primary-btn:active {
  background-color: #008f6f;
}
#error-msg {
  color: #ea0038;
  margin-top: 15px;
  font-size: 14px;
}

/* --- Chat Screen --- */
header {
  background-color: #00a884;
  color: white;
  padding: 10px 15px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 500;
  font-size: 17px;
}
.avatar {
  width: 40px;
  height: 40px;
  background-color: #dfe5e7;
  color: #8696a0;
  border-radius: 50%;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 20px;
}

#logout-btn {
  background: none;
  border: none;
  color: white;
  font-size: 18px;
  cursor: pointer;
  padding: 5px;
}

#chat-messages {
  flex: 1;
  background-color: #efeae2;
  padding: 15px 5%;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  /* Basic WhatsApp-style background pattern */
  background-image: url("https://user-images.githubusercontent.com/15075759/28719144-86dc0f70-73b1-11e7-911d-60d70fcded21.png");
  background-repeat: repeat;
}

.message {
  max-width: 85%;
  padding: 6px 8px 8px 10px;
  border-radius: 8px;
  position: relative;
  word-wrap: break-word;
  font-size: 15px;
  line-height: 1.4;
  color: #111b21;
  box-shadow: 0 1px 0.5px rgba(0, 0, 0, 0.13);
}

.message.sent {
  background-color: #d9fdd3;
  align-self: flex-end;
  border-top-right-radius: 0;
}

.message.received {
  background-color: white;
  align-self: flex-start;
  border-top-left-radius: 0;
}

.message img {
  max-width: 100%;
  border-radius: 6px;
  margin-bottom: 2px;
  /* Download/selection deterrents */
  pointer-events: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

.timestamp {
  display: inline-block;
  font-size: 11px;
  color: #667781;
  float: right;
  margin: 10px 0 -4px 10px;
}

footer {
  display: flex;
  padding: 10px;
  background-color: #f0f2f5;
  gap: 8px;
  align-items: center;
}

#message-input {
  flex: 1;
  padding: 12px 20px;
  border: none;
  border-radius: 24px;
  outline: none;
  font-size: 15px;
  background-color: white;
}

.icon-btn {
  background: transparent;
  color: #54656f;
  border: none;
  font-size: 22px;
  cursor: pointer;
  padding: 8px;
}

.send-icon {
  background-color: #00a884;
  color: white;
  width: 45px;
  height: 45px;
  border-radius: 50%;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 18px;
}
