/* Custom CSS for Instacopilot chat window */
:root {
  --background-color: #f2f2f7; /* Light gray background */
  --chat-bubble-user: #007aff; /* iPhone's blue for user messages */
  --chat-bubble-assistant: #e5e5ea; /* iPhone's light gray for assistant messages */
  --text-dark: #000000; /* Black text for contrast */
  --text-light: #ffffff; /* White text for contrast */
  --input-bg: #ffffff; /* White input background */
  --button-color: #007aff; /* iOS blue for buttons */
  --shadow-color: rgba(0, 0, 0, 0.1);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica,
    Arial, sans-serif;
  line-height: 1.5;
  color: var(--text-dark);
  background-color: var(--background-color);
  font-size: 18px; /* Increased from 16px */
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

#instacopilot-chat-window-container {
  max-width: 100%;
  margin: 0 auto;
  padding: 10px;
  height: 100vh;
  height: -webkit-fill-available;
  display: flex;
  flex-direction: column;
}

#instacopilot-chat-window {
  flex-grow: 1;
  overflow-y: auto;
  margin-bottom: 10px;
  background-color: var(--background-color);
  border-radius: 15px;
  padding: 15px;
}

.welcome-title {
  font-size: 30px; /* Increased from 28px */
  font-weight: 700;
  color: var(--text-dark);
  margin-bottom: 20px;
  text-align: center;
  letter-spacing: -0.5px;
}

.welcome-content {
  background-color: var(--chat-bubble-assistant);
  border-radius: 20px;
  padding: 20px;
  margin-bottom: 20px;
  color: var(--text-dark);
  font-size: 20px; /* Increased from 18px */
  line-height: 1.6;
}

.penny-avatar {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  margin: 0 auto 15px;
  display: block;
  border: 3px solid var(--text-light);
}

.options-container {
  margin-top: 20px;
}

.option-button {
  display: block;
  width: 100%;
  padding: 14px;
  margin-bottom: 10px;
  background-color: var(--button-color);
  color: var(--text-light);
  border: none;
  border-radius: 20px;
  font-size: 19px; /* Increased from 18px */
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.3s ease;
}

.option-button:hover,
.option-button:focus {
  opacity: 0.8;
}

#clear-history-button {
  background-color: var(--button-color);
  color: var(--text-light);
  border: none;
  border-radius: 50%;
  width: 36px;
  height: 36px;
  font-size: 16px; /* Increased from 14px */
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
  margin-right: 8px;
  transition: opacity 0.3s ease;
}

#clear-history-button:hover,
#clear-history-button:focus {
  opacity: 0.8;
}

#instacopilot-chat-input-container {
  display: flex;
  align-items: center;
  background-color: var(--input-bg);
  border-radius: 25px;
  padding: 12px; /* Increased padding */
  padding-left: 15px; /* Add side padding */
  padding-right: 15px; /* Add side padding */
  box-shadow: 0 2px 6px var(--shadow-color); /* Slightly increased shadow for visibility */
  position: sticky;
  bottom: env(safe-area-inset-bottom);
  margin-bottom: env(safe-area-inset-bottom);
  margin-left: 10px; /* Ensures the container doesn't touch the screen edge */
  margin-right: 10px; /* Ensures the container doesn't touch the screen edge */
}

#instacopilot-chat-input {
  flex-grow: 1;
  padding: 12px 14px; /* Increased padding inside input */
  border: none;
  font-size: 19px;
  line-height: 1.4;
  background: transparent;
  resize: none;
  min-height: 44px; /* Slightly increased minimum height */
  max-height: 120px;
  overflow-y: auto;
  color: var(--text-dark);
  border-radius: 20px; /* Optional: rounding input corners slightly */
  border: 1px solid rgba(0, 0, 0, 0.1); /* Optional: adding a subtle border */
}

#instacopilot-chat-input:focus {
  outline: none;
}

#instacopilot-send-button {
  background-color: var(--button-color);
  color: var(--text-light);
  border: none;
  border-radius: 50%;
  width: 36px;
  height: 36px;
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
  transition: opacity 0.3s ease;
  margin-left: 8px; /* Adds some spacing between input and button */
}

#instacopilot-send-button:hover,
#instacopilot-send-button:focus {
  opacity: 0.8;
}

.instacopilot-chat-message {
  margin-bottom: 12px;
  padding: 10px 15px;
  border-radius: 20px;
  max-width: 75%;
  word-wrap: break-word;
  font-size: 19px; /* Increased from 17px */
  line-height: 1.6; /* Adjusted for better readability */
  letter-spacing: 0.2px;
  overflow-wrap: break-word; /* Ensures long words wrap correctly */
  box-sizing: border-box; /* Ensures padding is included in width */
}

/* Additional styling for lists inside message bubbles */
.instacopilot-chat-message ol,
.instacopilot-chat-message ul {
  padding-left: 20px; /* Ensures list items are indented */
  margin: 0; /* Removes any default margins that might cause overflow */
  box-sizing: border-box; /* Ensure padding doesn't cause overflow */
}

.instacopilot-chat-message li {
  margin-bottom: 5px; /* Adds some spacing between list items */
  line-height: 1.5; /* Makes sure list items are easy to read */
}

.instacopilot-user-message {
  background-color: var(--chat-bubble-user);
  color: var(--text-light);
  align-self: flex-end;
  margin-left: auto;
  border-bottom-right-radius: 5px;
}

.instacopilot-assistant-message {
  background-color: var(--chat-bubble-assistant);
  color: var(--text-dark);
  align-self: flex-start;
  margin-right: auto;
  border-bottom-left-radius: 5px;
}

.instacopilot-loading-spinner {
  display: flex;
  justify-content: center;
  align-items: center;
  margin: 15px 0;
}

.instacopilot-loading-spinner i {
  font-size: 20px;
  color: var(--button-color);
  animation: spin 1s linear infinite;
}

/* Button Row */
.button-row {
  display: flex;
  gap: 10px;
  margin-top: 20px;
}

.button-row button {
  background-color: var(--button-color);
  color: var(--text-light);
  border: none;
  border-radius: 8px;
  padding: 10px 15px;
  font-size: 16px;
  cursor: pointer;
}

.button-row button:hover {
  opacity: 0.8;
}

/* Affirmation Modal Styles */
#affirmationModal {
  display: none;
  position: fixed;
  z-index: 2000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
}

#affirmationModalContent {
  background-color: white;
  margin: 20% auto;
  padding: 20px;
  border: 1px solid #888;
  width: 80%;
  font-size: 18px;
  line-height: 1.5;
  border-radius: 10px;
}

#affirmationModalClose {
  color: #aaa;
  float: right;
  font-size: 28px;
  font-weight: bold;
}

#affirmationModalClose:hover,
#affirmationModalClose:focus {
  color: black;
  text-decoration: none;
  cursor: pointer;
}

/* Privacy Modal styled like Affirmation Modal */
#privacyModal {
  display: none;
  position: fixed;
  z-index: 2000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
}

#privacyModalContent {
  background-color: white;
  margin: 20% auto;
  padding: 20px;
  border: 1px solid #888;
  width: 80%;
  font-size: 18px;
  line-height: 1.5;
  border-radius: 10px;
}

#privacyModalClose {
  color: #aaa;
  float: right;
  font-size: 28px;
  font-weight: bold;
}

#privacyModalClose:hover,
#privacyModalClose:focus {
  color: black;
  text-decoration: none;
  cursor: pointer;
}

#privacyButton,
#showAffirmationButton {
  background-color: transparent;
  color: #555; /* A subdued gray instead of bright white */
  border: 1px solid #ccc; /* A light gray border for a subdued look */
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 16px;
  cursor: pointer;
  transition: background-color 0.3s ease, color 0.3s ease;
}

/* On hover, slightly darken the background for feedback */
#privacyButton:hover,
#showAffirmationButton:hover {
  background-color: #f2f2f2;
  color: #333; /* Slightly darker text on hover */
}

/* On focus, add a subtle outline for accessibility */
#privacyButton:focus,
#showAffirmationButton:focus {
  outline: 2px solid #aaa;
  outline-offset: 2px;
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

@media (max-width: 600px) {
  body {
    font-size: 18px; /* Increased from 16px */
  }

  #instacopilot-chat-window-container {
    padding: 10px 10px calc(10px + env(safe-area-inset-bottom));
  }

  .welcome-title {
    font-size: 28px; /* Increased from 24px */
  }

  .welcome-content {
    font-size: 18px; /* Increased from 16px */
  }

  .option-button {
    font-size: 18px; /* Increased from 16px */
    padding: 12px;
  }

  #instacopilot-chat-input {
    font-size: 18px; /* Increased from 16px */
  }

  .instacopilot-chat-message {
    font-size: 18px; /* Increased from 16px */
  }
}

@supports (-webkit-touch-callout: none) {
  #instacopilot-chat-window-container {
    height: -webkit-fill-available;
  }
}

@media (prefers-contrast: more) {
  :root {
    --text-dark: #000000;
    --text-light: #ffffff;
    --chat-bubble-user: #0056b3; /* Darker blue for better contrast */
    --chat-bubble-assistant: #a1a1aa; /* Darker gray for better contrast */
    --background-color: #f2f2f7;
    --button-color: #0056b3; /* Darker blue for better contrast */
  }

  .instacopilot-chat-message {
    border: 1px solid var(--text-dark);
  }
}
