* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --bg: #ffffff;
  --chat-bg: #f5f5f5;
  --bubble-in: #ffffff;
  --header-bg: #ffffff;
  --text: #1a1a1a;
  --muted: #6b7280;
  --accent: #2563eb;
  --new: #f59e0b;
  --danger: #ef4444;
  --border: #e5e7eb;
  --time: #9ca3af;
}
body {
  font-family: 'Segoe UI', 'Heebo', Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  overflow: hidden;
}

.chat-app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  width: 100%;
  background: var(--chat-bg);
}

.chat-header {
  background: var(--header-bg);
  border-bottom: 1px solid var(--border);
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-shrink: 0;
  z-index: 10;
}
.chat-header-info {
  display: flex;
  align-items: center;
  gap: 12px;
}
.chat-header-info h1 {
  font-size: 1.1rem;
  font-weight: 600;
}
.chat-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.status {
  font-size: 0.75rem;
  color: var(--muted);
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(134,150,160,0.15);
}
.status.ok { color: var(--accent); background: rgba(0,168,132,0.15); }
.status.err { color: var(--danger); background: rgba(239,68,68,0.15); }

.filters {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.filter-chip {
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(134,150,160,0.1);
  border: 1px solid var(--border);
  color: var(--muted);
  cursor: pointer;
  font-size: 0.75rem;
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all 0.15s;
}
.filter-chip:hover { background: rgba(134,150,160,0.2); color: var(--text); }
.filter-chip.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  font-weight: 600;
}
.filter-chip .count {
  background: rgba(0,0,0,0.25);
  padding: 1px 6px;
  border-radius: 999px;
  font-size: 0.65rem;
}

.errors {
  background: rgba(239,68,68,0.1);
  border-bottom: 1px solid rgba(239,68,68,0.3);
  padding: 8px 16px;
  font-size: 0.8rem;
  flex-shrink: 0;
}
.errors.hidden { display: none; }

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: var(--chat-bg);
}

.msg {
  display: flex;
  gap: 8px;
  max-width: 95%;
  align-self: flex-start;
  animation: msgIn 0.2s ease-out;
}
.msg.new-msg {
  animation: msgIn 0.35s ease-out;
}

@keyframes msgIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.msg-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
  margin-top: 4px;
  background: var(--bubble-in);
  border: 1px solid var(--border);
}

.msg-bubble {
  background: var(--bubble-in);
  border-radius: 0 8px 8px 8px;
  padding: 6px 10px 4px;
  min-width: 80px;
  position: relative;
  box-shadow: 0 1px 2px rgba(0,0,0,0.06), 0 1px 3px rgba(0,0,0,0.1);
  border: 1px solid var(--border);
}
.msg-bubble::before {
  content: '';
  position: absolute;
  top: -1px;
  right: -7px;
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 0 0 8px 8px;
  border-color: transparent transparent transparent var(--bubble-in);
}

.msg-source {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 2px;
}

.msg-channel {
  font-size: 0.7rem;
  color: #6366f1;
  margin-bottom: 2px;
}

.msg-text {
  font-size: 0.9rem;
  line-height: 1.45;
  color: var(--text);
  word-break: break-word;
  white-space: pre-wrap;
}

.msg-images {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
}
.msg-images img {
  max-width: 400px;
  max-height: 300px;
  border-radius: 6px;
  object-fit: cover;
  cursor: pointer;
  transition: transform 0.15s;
}
.msg-images img:hover {
  transform: scale(1.02);
}

.msg-video {
  margin-top: 6px;
}
.msg-video .vid-container {
  max-width: 320px;
  border-radius: 8px;
  overflow: hidden;
  background: #000;
  position: relative;
  cursor: pointer;
}
.msg-video .vid-container video {
  width: 100%;
  max-height: 200px;
  display: block;
  border-radius: 8px;
}

.msg-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  margin-top: 2px;
}
.msg-time {
  font-size: 0.65rem;
  color: var(--time);
}
.msg-new-badge {
  font-size: 0.6rem;
  background: var(--new);
  color: #000;
  padding: 1px 5px;
  border-radius: 3px;
  font-weight: 700;
}

.empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--muted);
  font-size: 1rem;
  margin: auto;
}

.img-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  cursor: zoom-out;
}
.img-overlay img {
  max-width: 95vw;
  max-height: 95vh;
  border-radius: 8px;
}

/* סימון מיקום קריאה אחרון */
.last-read-marker {
  border-right: 3px solid var(--accent);
  border-radius: 0 8px 8px 0;
}
.last-read-marker::after {
  content: "▸ המשך קריאה מכאן";
  display: block;
  font-size: 0.65rem;
  color: var(--accent);
  text-align: center;
  padding: 2px 0;
  margin-top: 2px;
}

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--muted); }
