.chat-layout {
  display: flex;
  height: calc(100vh - 56px);
  position: relative;
}

/* ===== SIDEBAR ===== */
.chat-sidebar {
  width: 300px;
  min-width: 300px;
  background: #fff;
  border-left: 1px solid #e2e8f0;
  display: flex;
  flex-direction: column;
  transition: transform 0.25s ease;
  z-index: 100;
}

.conv-list {
  flex: 1;
  overflow-y: auto;
}

.conv-item {
  padding: 12px 16px;
  cursor: pointer;
  border-bottom: 1px solid #f1f5f9;
  transition: background 0.15s;
}
.conv-item:hover { background: #f8fafc; }
.conv-item.active { background: #eef2ff; border-right: 3px solid #3b82f6; }
.conv-item .title { font-weight: 600; font-size: 0.9rem; color: #1e293b; }
.conv-item .meta { font-size: 0.75rem; color: #94a3b8; }

/* ===== MAIN ===== */
.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: #f4f6fb;
  min-width: 0;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.chat-empty-state {
  margin: auto;
}

.msg-bubble {
  max-width: 75%;
  padding: 12px 16px;
  border-radius: 14px;
  line-height: 1.5;
  white-space: pre-wrap;
  font-size: 0.92rem;
  word-break: break-word;
}
.msg-user {
  align-self: flex-end;
  background: #3b82f6;
  color: #fff;
  border-bottom-left-radius: 4px;
}
.msg-user a { color: #fff; text-decoration: underline; }
.msg-assistant a { color: #1d4ed8; }
.msg-assistant {
  align-self: flex-start;
  background: #fff;
  border: 1px solid #e2e8f0;
  color: #1e293b;
  border-bottom-right-radius: 4px;
}
.msg-pending {
  align-self: flex-start;
  color: #94a3b8;
  font-size: 0.85rem;
}

/* ===== INPUT BAR ===== */
.chat-input-bar {
  background: #fff;
  border-top: 1px solid #e2e8f0;
  padding: 10px 12px;
}
.chat-input-bar textarea {
  resize: none;
  max-height: 140px;
  font-size: 1rem;
}
#attach-preview {
  font-size: 0.8rem;
  color: #3b82f6;
  margin-bottom: 6px;
}

/* ===== כפתור toggle sidebar במובייל ===== */
.btn-sidebar-toggle {
  display: none;
  position: fixed;
  bottom: 80px;
  left: 16px;
  z-index: 200;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: #3b82f6;
  color: #fff;
  border: none;
  font-size: 1.3rem;
  box-shadow: 0 2px 10px rgba(0,0,0,0.25);
  cursor: pointer;
}

/* overlay כהה מאחורי sidebar פתוח במובייל */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 99;
}
.sidebar-overlay.active { display: block; }

/* ===== MOBILE ===== */
@media (max-width: 640px) {
  .chat-sidebar {
    position: fixed;
    top: 56px;
    right: 0;
    bottom: 0;
    width: 80vw;
    max-width: 300px;
    transform: translateX(100%);
    box-shadow: -4px 0 16px rgba(0,0,0,0.15);
  }
  .chat-sidebar.open {
    transform: translateX(0);
  }

  .chat-main {
    width: 100%;
  }

  .chat-messages {
    padding: 12px 10px;
  }

  .msg-bubble {
    max-width: 90%;
    font-size: 0.95rem;
    padding: 10px 13px;
  }

  .chat-input-bar {
    padding: 8px 10px;
  }

  .chat-input-bar textarea {
    font-size: 16px; /* מונע zoom ב-iOS */
  }

  .btn-sidebar-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
  }
}
