/* public/style.css */
* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: #f5f5f5;
  height: 100vh;
  overflow: hidden;
}

.container { display: flex; height: 100vh; }

/* Sidebar */
.sidebar {
  width: 250px;
  background: #1a1d26;
  color: white;
  display: flex;
  flex-direction: column;
  border-right: 1px solid #2a2f3a;
}
.sidebar-header {
  padding: 20px;
  border-bottom: 1px solid #2a2f3a;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.sidebar-header h1 { font-size: 18px; font-weight: 600; }
.search-icon-btn {
  background: none;
  border: none;
  color: #aaa;
  cursor: pointer;
  font-size: 18px;
  padding: 0 4px;
}
.search-icon-btn:hover { color: white; }
.rooms-list { flex: 1; overflow-y: auto; padding: 10px; }
.room-item {
  padding: 10px 15px;
  margin: 5px 0;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.2s;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.room-item:hover { background: #2a2f3a; }
.room-item.active { background: #4a9eff; font-weight: 600; }
.room-bell-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 14px;
  padding: 0 2px;
  opacity: 0.35;
  line-height: 1;
  flex-shrink: 0;
}
.room-bell-btn:hover { opacity: 0.7; }
.room-bell-btn.active { opacity: 1; }

/* iOS install banner */
.ios-banner {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: #1a1d26;
  color: white;
  padding: 14px 16px;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 10px;
  z-index: 999;
  border-top: 1px solid #2a2f3a;
}
.ios-banner span { flex: 1; }
.ios-banner-close {
  background: none;
  border: none;
  color: #aaa;
  cursor: pointer;
  font-size: 18px;
  padding: 0 4px;
}
.ios-banner-close:hover { color: white; }
.new-room-btn {
  margin: 10px;
  padding: 10px;
  background: #4a9eff;
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
  font-size: 13px;
}
.new-room-btn:hover { background: #357abd; }
.sidebar-footer {
  padding: 15px;
  border-top: 1px solid #2a2f3a;
  display: flex;
  align-items: center;
  gap: 10px;
}
.user-avatar { width: 40px; height: 40px; border-radius: 50%; background: #4a9eff; }
.user-info { flex: 1; min-width: 0; }
.user-info p { font-size: 13px; color: #aaa; }
.user-info strong {
  display: block;
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.logout-btn { background: none; border: none; color: #999; cursor: pointer; font-size: 16px; }

/* Main content */
.main-content { flex: 1; display: flex; flex-direction: column; background: white; overflow: hidden; }
.chat-header { padding: 20px; background: white; border-bottom: 1px solid #e5e5e5; }
.chat-header h2 { font-size: 18px; color: #1a1d26; }
.messages-container {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Messages */
.message { display: flex; gap: 10px; margin-bottom: 4px; position: relative; }
.message:hover .message-actions { opacity: 1; }
.message-avatar { width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0; }
.message-body { flex: 1; }
.message-header { display: flex; align-items: baseline; gap: 8px; margin-bottom: 4px; }
.message-author { font-weight: 600; font-size: 14px; color: #1a1d26; }
.message-time { font-size: 12px; color: #999; }
.message-edited { font-size: 11px; color: #bbb; font-style: italic; }
.message-text { color: #1a1d26; line-height: 1.4; word-wrap: break-word; }
.message-text.deleted { color: #bbb; font-style: italic; }

/* Edit/delete actions */
.message-actions {
  opacity: 0;
  transition: opacity 0.15s;
  display: flex;
  gap: 4px;
  margin-left: auto;
  align-self: flex-start;
}
.message-actions button {
  background: none;
  border: 1px solid #e5e5e5;
  border-radius: 4px;
  padding: 2px 6px;
  cursor: pointer;
  font-size: 13px;
  color: #666;
}
.message-actions button:hover { background: #f5f5f5; }

/* Edit input */
.edit-input {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid #4a9eff;
  border-radius: 4px;
  font-size: 14px;
  font-family: inherit;
}

/* Reactions */
.reactions { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.reaction-pill {
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 2px 7px;
  border-radius: 12px;
  border: 1px solid #e5e5e5;
  background: #f9f9f9;
  cursor: pointer;
  font-size: 13px;
  transition: background 0.15s;
}
.reaction-pill:hover { background: #eef4ff; border-color: #4a9eff; }
.reaction-pill.mine { background: #eef4ff; border-color: #4a9eff; }
.reaction-pill .count { font-size: 12px; color: #555; }
.react-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 16px;
  padding: 0 4px;
  color: #aaa;
  opacity: 0;
  transition: opacity 0.15s;
}
.message:hover .react-btn { opacity: 1; }
.react-btn:hover { color: #555; }

/* Emoji picker popover */
.emoji-picker-popover {
  position: absolute;
  z-index: 100;
  box-shadow: 0 4px 20px rgba(0,0,0,0.15);
  border-radius: 8px;
}

/* Highlight for search jump */
.message.highlight { background: #fffbe6; border-radius: 6px; transition: background 2s; }

/* Input area */
.input-area { padding: 20px; border-top: 1px solid #e5e5e5; background: white; }
.input-form { display: flex; gap: 10px; }
.input-form input {
  flex: 1;
  padding: 10px 15px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 14px;
}
.input-form input:focus { outline: none; border-color: #4a9eff; box-shadow: 0 0 0 3px rgba(74,158,255,0.1); }
.input-form button {
  padding: 10px 20px;
  background: #4a9eff;
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
  font-size: 13px;
}
.input-form button:hover { background: #357abd; }

/* Auth */
.auth-container {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100vh;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}
.auth-box {
  background: white;
  padding: 40px;
  border-radius: 12px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.2);
  width: 100%;
  max-width: 380px;
}
.auth-box h1 { margin-bottom: 30px; color: #1a1d26; text-align: center; }
.auth-form { display: flex; flex-direction: column; gap: 15px; }
.auth-form input { padding: 12px; border: 1px solid #ddd; border-radius: 6px; font-size: 14px; }
.auth-form input:focus { outline: none; border-color: #667eea; box-shadow: 0 0 0 3px rgba(102,126,234,0.1); }
.auth-form button {
  padding: 12px;
  background: #667eea;
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
}
.auth-form button:hover { background: #5568d3; }
.auth-toggle { text-align: center; font-size: 13px; color: #666; margin-top: 15px; }
.auth-toggle a { color: #667eea; cursor: pointer; text-decoration: underline; }
.error { padding: 12px; background: #fee; color: #c33; border-radius: 6px; font-size: 13px; }
.hidden { display: none; }

/* Search panel */
.search-bar-wrapper { padding: 12px 20px; border-bottom: 1px solid #e5e5e5; display: flex; gap: 8px; }
.search-bar-wrapper input {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 14px;
}
.search-bar-wrapper input:focus { outline: none; border-color: #4a9eff; }
.search-close-btn { background: none; border: none; font-size: 18px; cursor: pointer; color: #999; }
.search-results { flex: 1; overflow-y: auto; padding: 16px; }
.search-result {
  padding: 12px;
  margin-bottom: 8px;
  border: 1px solid #e5e5e5;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s;
}
.search-result:hover { background: #f5f9ff; border-color: #4a9eff; }
.search-result-meta { font-size: 12px; color: #999; margin-bottom: 4px; }
.search-result-text { font-size: 14px; color: #1a1d26; }
.search-result-text strong { background: #fff3cd; padding: 0 2px; border-radius: 2px; }
.search-empty { color: #999; font-size: 14px; text-align: center; margin-top: 40px; }

/* Scrollbar */
.scrollable::-webkit-scrollbar { width: 6px; }
.scrollable::-webkit-scrollbar-track { background: transparent; }
.scrollable::-webkit-scrollbar-thumb { background: #ddd; border-radius: 3px; }
.scrollable::-webkit-scrollbar-thumb:hover { background: #bbb; }
