:root {
  --whatsapp-green: #25d366;
  --whatsapp-light-green: #dcf8c6;
  --whatsapp-dark-green: #128c7e;
  --sender-bubble: #e0e0e0;
  /* Grey bubble for "others" */
  --receiver-bubble: var(--whatsapp-light-green);
  /* Green bubble for "you" (first sender) */
  --background-color: #f0f2f5;
  /* Light grey/blue for overall background */
  --chat-bg-pattern: url('data:image/svg+xml;utf8,<svg viewBox="0 0 400 400" xmlns="http://www.w3.org/2000/svg"><filter id="noiseFilter"><feTurbulence type="fractalNoise" baseFrequency="0.65" numOctaves="3" stitchTiles="stitch" result="noise"></feTurbulence><feBlend in="SourceGraphic" in2="noise" mode="multiply"></feBlend></filter><rect width="100%" height="100%" fill="%23e0e0e0" filter="url(%23noiseFilter)"></rect></svg>');
  --text-color: #333;
  --light-text-color: #666;
  --border-color: #ddd;
  --card-background: #fff;
  --shadow-color: rgba(0, 0, 0, 0.1);
  --icon-color: #888;
}

/* Basic Reset & Body */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Roboto', 'Inter', sans-serif;
  background-color: var(--background-color);
  color: var(--text-color);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.container {
  max-width: 900px;
  width: 100%;
  margin: 2rem auto;
  padding: 0 1rem;
  flex-grow: 1;
}

header {
  background-color: var(--whatsapp-dark-green);
  color: white;
  padding: 2rem 1rem;
  text-align: center;
  width: 100%;
  box-shadow: 0 4px 8px var(--shadow-color);
}

header h1 {
  font-size: 2.5rem;
  margin-bottom: 0.5rem;
  font-weight: 700;
}

header p {
  font-size: 1.1rem;
  max-width: 700px;
  margin: 0 auto;
}

.card {
  background-color: var(--card-background);
  padding: 2rem;
  border-radius: 12px;
  box-shadow: 0 6px 12px var(--shadow-color);
  margin-bottom: 2rem;
}

.card h2 {
  text-align: center;
  color: var(--whatsapp-dark-green);
  margin-bottom: 1.5rem;
  font-size: 1.8rem;
}

/* File Upload */
.file-upload-area {
  border: 2px dashed var(--whatsapp-green);
  border-radius: 12px;
  padding: 2rem;
  text-align: center;
  cursor: pointer;
  transition: background-color 0.3s ease;
  margin-bottom: 1.5rem;
}

.file-upload-area:hover {
  background-color: rgba(37, 211, 102, 0.05);
}

.file-upload-area.drag-over {
  background-color: rgba(37, 211, 102, 0.1);
  border-color: var(--whatsapp-dark-green);
}

.file-upload-area input[type="file"] {
  display: none;
}

.file-upload-area p {
  font-size: 1.1rem;
  color: var(--light-text-color);
  margin-top: 1rem;
}

.file-upload-area .icon {
  font-size: 3rem;
  color: var(--whatsapp-green);
}

/* Dummy File Download Link */
.dummy-file-section {
  text-align: center;
  margin-top: 2rem;
  /* Space from upload area */
  font-size: 1rem;
  color: var(--whatsapp-text-dark);
}

.dummy-file-section p {
  margin-bottom: 1rem;
}

.dummy-file-section a.button {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  background-color: var(--whatsapp-green);
  color: white;
  padding: 0.8rem 1.5rem;
  border-radius: 8px;
  text-decoration: none;
  font-weight: 600;
  transition: background-color 0.3s ease, transform 0.2s ease;
  box-shadow: 0 3px 8px var(--whatsapp-shadow-light);
}

.dummy-file-section a.button:hover {
  background-color: var(--whatsapp-dark-green);
  transform: translateY(-2px);
  box-shadow: 0 5px 12px var(--whatsapp-shadow-medium);
}

.dummy-file-section a.button svg {
  fill: white;
  height: 18px;
  width: 18px;
}

.message {
  margin-top: 1rem;
  padding: 0.8rem 1rem;
  border-radius: 8px;
  font-size: 0.95rem;
  text-align: center;
  display: none;
  /* Hidden by default */
}

.success-message {
  background-color: rgba(37, 211, 102, 0.1);
  color: var(--whatsapp-dark-green);
  border: 1px solid var(--whatsapp-dark-green);
}

.error-message {
  background-color: rgba(244, 67, 54, 0.1);
  color: #f44336;
  border: 1px solid #f44336;
}

/* Chat Viewer */
.chat-viewer-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1.5rem;
  align-items: center;
}

.chat-viewer-controls label {
  font-weight: 500;
  color: var(--light-text-color);
}

.chat-viewer-controls input[type="text"],
.chat-viewer-controls input[type="date"] {
  padding: 0.6rem 0.8rem;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  font-size: 0.95rem;
}

.chat-viewer-controls button {
  background-color: var(--whatsapp-green);
  color: white;
  padding: 0.7rem 1.2rem;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 500;
  transition: background-color 0.3s ease;
}

.chat-viewer-controls button:hover {
  background-color: var(--whatsapp-dark-green);
}

.toggle-switch {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.switch {
  position: relative;
  display: inline-block;
  width: 40px;
  height: 24px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #ccc;
  transition: .4s;
  border-radius: 24px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 16px;
  width: 16px;
  left: 4px;
  bottom: 4px;
  background-color: white;
  transition: .4s;
  border-radius: 50%;
}

input:checked+.slider {
  background-color: var(--whatsapp-green);
}

input:checked+.slider:before {
  transform: translateX(16px);
}

.chat-view {
  max-height: 500px;
  overflow-y: auto;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 1rem;
  background-color: var(--background-color);
  position: relative;
  /* For the "No chats..." message */

  /* WhatsApp-like background */
  background-color: #e0e0e0;
  /* Fallback */
  background-image: var(--chat-bg-pattern);
  background-size: cover;
  background-repeat: no-repeat;
  background-position: center;
}

.chat-view-placeholder {
  text-align: center;
  color: var(--light-text-color);
  padding: 2rem;
}

.chat-message {
  display: flex;
  margin-bottom: 0.5rem;
  align-items: flex-end;
}

.chat-message.sender {
  /* This user (the one exporting) */
  justify-content: flex-end;
}

.chat-message.receiver {
  /* The other person/group members */
  justify-content: flex-start;
}

.message-bubble {
  max-width: 75%;
  padding: 0.6rem 0.8rem;
  border-radius: 10px;
  font-size: 0.95rem;
  word-wrap: break-word;
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.08);
  position: relative;
  line-height: 1.3;
  /* Triangles for chat bubbles */
  z-index: 1;
  /* Ensure bubble is above background */
}

.message-bubble.sender {
  background-color: var(--receiver-bubble);
  /* Green bubble for "you" */
  margin-left: auto;
  /* Push to right */
  border-bottom-right-radius: 2px;
}

.message-bubble.sender::after {
  content: '';
  position: absolute;
  right: 0;
  bottom: 0;
  width: 0;
  height: 0;
  border: 8px solid transparent;
  border-bottom-color: var(--receiver-bubble);
  border-right-color: var(--receiver-bubble);
  border-bottom-right-radius: 5px;
  /* Adjust for more curved corner */
  transform: translateX(100%) translateY(0) rotate(45deg);
  z-index: 0;
}

.message-bubble.receiver {
  background-color: var(--sender-bubble);
  /* Grey bubble for others */
  margin-right: auto;
  /* Push to left */
  border-bottom-left-radius: 2px;
}

.message-bubble.receiver::after {
  content: '';
  position: absolute;
  left: 0;
  bottom: 0;
  width: 0;
  height: 0;
  border: 8px solid transparent;
  border-bottom-color: var(--sender-bubble);
  border-left-color: var(--sender-bubble);
  border-bottom-left-radius: 5px;
  /* Adjust for more curved corner */
  transform: translateX(-100%) translateY(0) rotate(-45deg);
  z-index: 0;
}


.message-info {
  font-size: 0.75rem;
  color: var(--light-text-color);
  margin-top: 0.3rem;
  display: flex;
  justify-content: flex-end;
  /* Always right-align timestamp within bubble */
  gap: 1rem;
  padding: 0 0.2rem;
}

.message-info .name {
  font-weight: 500;
  color: var(--whatsapp-dark-green);
  /* Example: Name color */
  margin-right: auto;
  /* Push name to left, timestamp to right */
}

.message-info .timestamp {
  white-space: nowrap;
}

/* Specific coloring for sender names in bubbles */
.message-bubble.receiver .message-info .name {
  color: #008069;
  /* A common WhatsApp receiver name color */
}

.message-bubble.sender .message-info .name {
  color: #1a6dff;
  /* A common WhatsApp sender name color */
}

.raw-chat-view {
  white-space: pre-wrap;
  font-family: monospace;
  font-size: 0.9rem;
  background-color: #eee;
  padding: 1rem;
  border-radius: 8px;
}

/* Export Options */
.export-options {
  margin-top: 2rem;
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  justify-content: center;
}

.export-options button {
  background-color: var(--whatsapp-green);
  color: white;
  padding: 0.8rem 1.5rem;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 1rem;
  font-weight: 500;
  transition: background-color 0.3s ease;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.export-options button:hover {
  background-color: var(--whatsapp-dark-green);
}

.export-options button svg {
  fill: white;
  height: 18px;
  width: 18px;
}

/* Monetization / Footer */
.adsense-placeholder {
  margin-top: 2rem;
  text-align: center;
  min-height: 100px;
  background-color: #e0e0e0;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--light-text-color);
  font-size: 0.9rem;
  width: 100%;
  max-width: 728px;
  /* Typical leaderboard ad size */
  margin-left: auto;
  margin-right: auto;
}

footer {
  margin-top: 3rem;
  padding: 1.5rem 1rem;
  text-align: center;
  background-color: var(--card-background);
  border-top: 1px solid var(--border-color);
  font-size: 0.9rem;
  color: var(--light-text-color);
  width: 100%;
}

footer a {
  color: var(--whatsapp-dark-green);
  text-decoration: none;
  margin: 0 0.5rem;
}

footer a:hover {
  text-decoration: underline;
}

.legal-disclaimer {
  margin-top: 1rem;
  font-size: 0.8rem;
  color: #999;
}

/* Responsive adjustments */
@media (max-width: 768px) {
  header h1 {
    font-size: 2rem;
  }

  header p {
    font-size: 1rem;
  }

  .card {
    padding: 1.5rem;
  }

  .chat-viewer-controls {
    flex-direction: column;
    align-items: stretch;
  }

  .chat-viewer-controls>div {
    width: 100%;
  }

  .chat-message.sender,
  .chat-message.receiver {
    margin-left: 0;
    margin-right: 0;
  }

  .dummy-file-section {
    margin-top: 1.5rem;
  }
}

@media (max-width: 480px) {
  header {
    padding: 1.5rem 1rem;
  }

  header h1 {
    font-size: 1.8rem;
  }

  .container {
    margin: 1.5rem auto;
  }

  .card {
    padding: 1rem;
  }

  .file-upload-area {
    padding: 1.5rem;
  }

  .file-upload-area p {
    font-size: 1rem;
  }

  .message-bubble {
    max-width: 90%;
  }

  .export-options button {
    width: 100%;
  }
}