/* Variables */
:root {
  --bg: #f7f7f8;
  --fg: #343541;
  --headerbg: #ffffff;
  --accent: #10a37f;
  --border: #e5e5e5;
  --hover: #f5f5f5;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

[data-theme="dark"] {
  --bg: #343541;
  --fg: #ececf1;
  --headerbg: #40414f;
  --accent: #19c37d;
  --border: #565869;
  --hover: #2a2b32;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, sans-serif;
  background: var(--bg);
  color: var(--fg);
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

header {
  background: var(--headerbg);
  padding: 1rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
}

h1 {
  margin: 0;
  font-size: 1.2rem;
}

.right-tools {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

#search {
  padding: 0.5rem 0.75rem;
  font-size: 0.9rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--fg);
  width: 200px;
}

#search:focus {
  outline: none;
  border-color: var(--accent);
}

#themeToggle {
  background: var(--hover);
  border: 1px solid var(--border);
  cursor: pointer;
  font-size: 1.2rem;
  padding: 0.5rem;
  border-radius: 8px;
  transition: all 0.2s;
}

#themeToggle:hover {
  background: var(--accent);
  color: white;
}

main#board {
  flex: 1 1 auto;
  overflow-y: auto;
  display: flex;
  flex-direction: column-reverse; /* latest at top */
  padding: 1rem;
  gap: 0.75rem;
  min-height: 0; /* allow flex shrinking */
}

.message {
  background: var(--headerbg);
  padding: 1rem 1.25rem;
  border-radius: 12px;
  word-wrap: break-word;
  position: relative;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  transition: all 0.2s;
  margin-bottom: 0.5rem;
}

.message:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  transform: translateY(-1px);
}

.message:hover .message-menu {
  opacity: 1;
}

.message-menu {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  opacity: 0;
  transition: opacity 0.2s;
}

.menu-dots {
  background: var(--hover);
  border: 1px solid var(--border);
  color: var(--fg);
  font-size: 1rem;
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  border-radius: 6px;
  transition: all 0.2s;
  font-weight: bold;
}

.menu-dots:hover {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.menu-dropdown {
  position: absolute;
  right: 0;
  top: 100%;
  background: var(--headerbg);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
  min-width: 120px;
  z-index: 100;
  overflow: hidden;
}

.menu-dropdown button {
  display: block;
  width: 100%;
  padding: 0.75rem 1rem;
  background: none;
  border: none;
  text-align: left;
  cursor: pointer;
  color: var(--fg);
  transition: background 0.2s;
  font-size: 0.9rem;
}

.menu-dropdown button:hover {
  background: var(--hover);
}

.menu-dropdown button:first-child {
  border-bottom: 1px solid var(--border);
}

.hidden {
  display: none !important;
}

/* Edit mode */
.message.editing {
  border: 2px solid var(--accent);
  background: var(--hover);
}

.message.editing .message-content {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.5rem;
  background: var(--bg);
  min-height: 2rem;
  outline: none;
}

.edit-actions {
  margin-top: 0.5rem;
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
}

.edit-actions button {
  padding: 0.4rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.85rem;
  transition: all 0.2s;
}

.edit-actions .save-btn {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.edit-actions .cancel-btn {
  background: var(--hover);
  color: var(--fg);
}

.edit-actions button:hover {
  transform: translateY(-1px);
}

.message time {
  display: block;
  font-size: 0.75rem;
  opacity: 0.6;
  margin-top: 0.4rem;
}

footer {
  padding: 1rem 1.5rem;
  background: var(--headerbg);
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  flex-shrink: 0; /* keep footer at bottom */
  box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.1);
}

#formatting {
  display: flex;
  gap: 0.5rem;
}

#formatting button {
  padding: 0.5rem 0.75rem;
  font-size: 0.9rem;
  background: var(--hover);
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
  color: var(--fg);
}

#formatting button:hover {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

#inputContainer {
  display: flex;
  gap: 0.5rem;
}

#input {
  flex: 1 1 auto;
  min-height: 3rem;
  max-height: 8rem;
  overflow-y: auto;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg);
  color: var(--fg);
  transition: border-color 0.2s;
  line-height: 1.5;
}

#input:focus {
  outline: none;
  border-color: var(--accent);
}

#input:empty:before {
  content: attr(placeholder);
  color: #999;
  opacity: 0.7;
}

#send {
  flex: 0 0 auto;
  padding: 0.75rem 1.5rem;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  font-weight: 500;
  transition: all 0.2s;
}

#send:hover {
  background: #0d8f6f;
  transform: translateY(-1px);
}

#send:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Login overlay */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  justify-content: center;
  align-items: center;
}
/* Image styles */
.message img {
  max-width: 150px;
  max-height: 150px;
  cursor: pointer;
  border-radius: 4px;
  margin: 0.5rem 0;
}

.image-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  cursor: pointer;
}

.image-overlay img {
  max-width: 90vw;
  max-height: 90vh;
  border-radius: 8px;
}

.login-box {
  background: var(--headerbg);
  padding: 2rem;
  border-radius: 6px;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  width: 90%;
  max-width: 320px;
}

.login-box input {
  padding: 0.5rem;
  font-size: 1rem;
}

.login-box button {
  padding: 0.6rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 4px;
  cursor: pointer;
}

.error {
  color: red;
  font-size: 0.85rem;
}

/* Responsive tweaks */
@media (min-width: 600px) {
  h1 {
    font-size: 1.5rem;
  }
  #input {
    min-height: 3rem;
  }
} 