/* Reset and Base */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Segoe UI', Tahoma, sans-serif;
  background: linear-gradient(to right, #fbc2eb, #a6c1ee);
  color: #333;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 2rem;
  min-height: 100vh;
  transition: background 0.4s, color 0.4s;
}

header {
  text-align: center;
  margin-bottom: 1rem;
}

header h2 {
  font-size: 1.8rem;
  margin-bottom: 0.5rem;
}

header img {
  width: 100px;
  border-radius: 50%;
  margin-bottom: 1rem;
}

.description {
  text-align: center;
  margin-bottom: 1.5rem;
}

/* Inputs */
input, button {
  font-size: 1rem;
  padding: 10px;
  border-radius: 8px;
  border: 1px solid #ccc;
  outline: none;
  box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

input {
  width: 100%;
  max-width: 400px;
  margin-bottom: 1rem;
}

#emoji-btn {
  margin-left: 10px;
  cursor: pointer;
}

.input-row {
  display: flex;
  align-items: center;
  max-width: 400px;
  width: 100%;
}

/* Chat box */
#box {
  width: 100%;
  max-width: 400px;
  background: white;
  padding: 1rem;
  border-radius: 10px;
  height: 300px;
  overflow-y: auto;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  display: flex;
  flex-direction: column;
}

.message {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  margin-bottom: 0.5rem;
}

.message.mine {
  align-items: flex-end;
}

.bubble {
  max-width: 80%;
  padding: 0.6rem 1rem;
  border-radius: 18px;
  word-wrap: break-word;
  background: #f0f0f0;
}

.message.mine .bubble {
  background: #dcf8c6;
  border-bottom-right-radius: 0;
}

.message.theirs .bubble {
  background: #e6e6e6;
  border-bottom-left-radius: 0;
}

.bubble .user {
  font-weight: bold;
  font-size: 0.9rem;
}

.bubble .text {
  margin: 0.25rem 0;
}

.bubble .timestamp {
  font-size: 0.7rem;
  color: #666;
  text-align: right;
  display: block;
  margin-top: 4px;
}

#typing-indicator {
  font-size: 0.85rem;
  margin: 0.5rem 0;
  color: #555;
  font-style: italic;
}

/* Emoji Picker */
#emoji-picker {
  max-width: 400px;
  margin-bottom: 1rem;
}

.hidden {
  display: none;
}

/* Dark Mode */
body.dark {
  background: #1e1e1e;
  color: #eee;
}

body.dark input,
body.dark #box {
  background: #2e2e2e;
  color: #eee;
  border-color: #444;
}

body.dark .bubble {
  background: #444;
}

body.dark .message.mine .bubble {
  background: #6fcf97;
}

body.dark .message.theirs .bubble {
  background: #555;
}

body.dark .bubble .timestamp {
  color: #aaa;
}

/* Toggle Switch */
.toggle-wrapper {
  margin-top: 1rem;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.5rem;
}

.switch {
  position: relative;
  display: inline-block;
  width: 50px;
  height: 26px;
}

.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: 0.4s;
  border-radius: 26px;
}

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

input:checked + .slider {
  background-color: #2196f3;
}

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

@media (max-width: 500px) {
  body {
    padding: 1rem;
  }

  input, #box, .input-row {
    max-width: 100%;
  }

  header h2 {
    font-size: 1.5rem;
  }
}
